IzumiSy/elm-typed/4.1.0

Typed

Types

type Typed tag a p

A definition of Typed data.

Users can control data modifiability by giving permission to the type variable p.

Permissions

type alias ReadOnly =
{ read : Allowed
, write : Unallowed
}

ReadOnly permission prohibits users to call all functions that do constructing and updating such as new, map and andThen.

type alias ReadWrite =
{ read : Allowed
, write : Allowed
}

ReadWrite permission allows users to call all functions.

type alias WriteOnly =
{ read : Unallowed
, write : Allowed
}

WriteOnly permission prohibits users to call value function to get internal implementation.

Policies

type alias Readable p =
{ p | read : Allowed }

Policy for allowing read permission.

type alias Writable p =
{ p | write : Allowed }

Policy for allowing write permission.

Constructor

new : a -> Typed tag a ReadWrite
writeOnly : a -> Typed tag a WriteOnly

Manipulation

value : Typed tag a (Readable p) -> a
map : (a -> a) -> Typed tag a (Writable p) -> Typed tag a (Writable p)
(a -> Typed tag b (Writable p))
-> Typed tag a (Writable p)
-> Typed tag b (Writable p)

Serialization

encode : (a -> Value) -> Typed tag a p -> Value
decode : Decoder a -> Decoder (Typed tag a p)
encodeStrict : tag -> (a -> Value) -> Typed tag a p -> Value

Stricter version of encode that accepts a tag to check.

decodeStrict : tag -> Decoder a -> Decoder (Typed tag a p)

Stricter version of decode that accepts a tag to check.