A definition of Typed
data.
Users can control data modifiability by giving permission to the type variable p
.
{ read : Allowed
, write : Unallowed
}
ReadOnly permission prohibits users to call all functions that do constructing and updating such as new
, map
and andThen
.
{ read : Allowed
, write : Allowed
}
ReadWrite permission allows users to call all functions.
{ read : Unallowed
, write : Allowed
}
WriteOnly permission prohibits users to call value
function to get internal implementation.
{ p | read : Allowed }
Policy for allowing read
permission.
{ p | write : Allowed }
Policy for allowing write
permission.
new : a -> Typed tag a ReadWrite
writeOnly : a -> Typed tag a WriteOnly
value : Typed tag a (Readable p) -> a
map : (a -> a) -> Typed tag a (Writable p) -> Typed tag a (Writable p)
andThen : (a -> Typed tag b (Writable p)) -> Typed tag a (Writable p) -> Typed tag b (Writable p)
encode : (a -> Json.Encode.Value) -> Typed tag a p -> Json.Encode.Value
decode : Json.Decode.Decoder a -> Json.Decode.Decoder (Typed tag a p)
encodeStrict : tag -> (a -> Json.Encode.Value) -> Typed tag a p -> Json.Encode.Value
Stricter version of encode
that accepts a tag to check.
decodeStrict : tag -> Json.Decode.Decoder a -> Json.Decode.Decoder (Typed tag a p)
Stricter version of decode
that accepts a tag to check.