sashaafm / eetf / Eetf.Encode

Turns Elm values into Erlang External Term Format (ETF) values. Check out the official documentation to better understand how this library and the Erlang side work.

Encoding

encode : Value -> Bytes

Convert a Value into a Bytes sequence.


type alias Value =
Eetf.Term

Represents an External Term Format value.

Primitives

string : String -> Value

Turn a String into an Erlang binary (UTF-8 encoded byte sequence) in External Term Format.

int : Basics.Int -> Value

Turn an Int into an Erlang integer in External Term Format.

float : Basics.Float -> Value

Turn a Float into an Erlang float in External Term Format.

bool : Basics.Bool -> Value

Turn a Bool into an Erlang boolean in External Term Format.

Data Structures

list : (a -> Value) -> List a -> Value

Turn a List into an Erlang list in External Term Format.

array : (a -> Value) -> Array a -> Value

Turn an Array into an Erlang list in External Term Format.

set : (a -> Value) -> Set a -> Value

Turn a Set into an Erlang list in External Term Format.

dict : (k -> String) -> (v -> Value) -> Dict k v -> Value

Turn a Dict into an Erlang map in External Term Format.

object : List ( String, Value ) -> Value

Turn a List (String, Value) into an Erlang map in External Term Format.

This function exists to provide an API similar to the one in elm/json namely the Json.Encode.object function. To better undestand how to use it you can consult the Json.Encode.object documentation [here][https://package.elm-lang.org/packages/elm/json/latest/Json-Encode#object] .

tuple : (e -> Value) -> e -> Value

Turn a Tuple of arity 1 into an Erlang tuple of arity 1 in External Term Format.

tuple2 : (e1 -> Value) -> (e2 -> Value) -> ( e1, e2 ) -> Value

Turn a Tuple of arity 2 into an Erlang tuple of arity 2 in External Term Format.

tuple3 : (e1 -> Value) -> (e2 -> Value) -> (e3 -> Value) -> ( e1, e2, e3 ) -> Value

Turn a Tuple of arity 3 into an Erlang tuple of arity 3 in External Term Format.