This library allows a variable to hold a value of any type. The name of the
module is derived from the Autoboxing concept in Java. Boxed
values can be
useful when receiving external data that you do not want to thoroughly check for
errors, but rather disregard the type of some of the values obtained. For
example, you might be more interested in the structure of the received data than
the type of all of the member values. The decoder found at Boxed.Json
lets
any kind of value through, allowing you to focus on the shape of the whole data
structure.
Some helper functions are provided to extract native Elm values, for example:
filterMap asFloat (Lst [Integer 1, Str "b", Double 3.01])
-- It returns [1,3.01]
Note: Dict has been limited to use only String
as keys
Boxed
is currently holding an encapsulation of said type. (Exception made on asFloat
).asBool : Boxed c -> Maybe Basics.Bool
asFloat : Boxed c -> Maybe Basics.Float
Note: Both Integer
and Double
will be able to pass as Float
asInt : Boxed c -> Maybe Basics.Int
asString : Boxed c -> Maybe String
asValue : Boxed c -> Maybe Json.Encode.Value
asList : Boxed c -> List (Boxed c)
Always returns a List
. Consider using it along with isList.
asDict : Boxed c -> Dict String (Boxed c)
Always returns a Dict
. Consider using it along with isDict.
isTrue : Boxed c -> Basics.Bool
Return value of boxed Bool
. If Boxed
is holding any other type,
return False.
isBool : Boxed c -> Basics.Bool
isFloat : Boxed c -> Basics.Bool
isInt : Boxed c -> Basics.Bool
isString : Boxed c -> Basics.Bool
isValue : Boxed c -> Basics.Bool
isList : Boxed c -> Basics.Bool
isDict : Boxed c -> Basics.Bool
isTuple : Boxed c -> Basics.Bool
isCustom : Boxed c -> Basics.Bool
isNull : Boxed c -> Basics.Bool