Now you can describe a number of nested objects, for example
(struct_set Note
text RgaString
tags (RGA (ObjectRef Tag))
value Integer)
means that Note object chunk and chunks for all objects representing its fields (RGA for text and RGA for tags) will be stored inside the document frame.
All referenced objects (Tag in this example) will not be stored in this document, and the user has to put the explicitly into other documents.
This will generate a type like this:
data Note = Note
{ text :: RgaString, -- ~ [Char]
tags :: RGA (ObjectRef Tag), -- ~ [UUID]
value :: Integer
}
RGA a is meant just to represent a value, so it is just a wrapper around [a].
A user can get the whole document state with the readObject function, with all internal objects decoded but without external object-refs resolved.
To resolve referenced objects, the user must take ObjectRefs and call loadDocument (involving IO) and readObject (in "pure" State) for them.
Problem
This seems unclear and complicated.
Proposal
Put each object in its own document.
Remove explicit ObjectRef from Schema, always considering a nested object a reference. Generated code will always contain references for objects.
Example
(struct_set Note
text RgaString
tags (RGA Tag)
value Integer)
data Note = Note
{ text :: ObjectRef RgaString, -- ~ UUID
tags :: ObjectRef RGA Tag, -- ~ UUID
value :: Integer
}
Open questions
Does readObject load data from backend each time?
What about transactions if there are no documents?
Current state
Now you can describe a number of nested objects, for example
means that Note object chunk and chunks for all objects representing its fields (RGA for text and RGA for tags) will be stored inside the document frame.
All referenced objects (Tag in this example) will not be stored in this document, and the user has to put the explicitly into other documents.
This will generate a type like this:
RGA a
is meant just to represent a value, so it is just a wrapper around[a]
.A user can get the whole document state with the
readObject
function, with all internal objects decoded but without external object-refs resolved.To resolve referenced objects, the user must take
ObjectRef
s and callloadDocument
(involving IO) andreadObject
(in "pure" State) for them.Problem
This seems unclear and complicated.
Proposal
Example
Open questions
readObject
load data from backend each time?