Open
Description
Context
Given that
- the
decode
API is used with formats like JSON, where there is no distinction between floats and ints, and - the target (Erlang vs ES) is a somewhat leaky abstraction when it comes to handling numbers,
it can be confusing that on the Erlang target decode.float
will not accept e.g. 1
, but requires 1.0
to work properly.
Suggestion
Add decode.number: Decoder(Float)
, which would work equivalently to
decode.one_of(decode.float, or: [decode.int |> decode.map(int.to_float)])
This would both make it more convenient to decode formats where there's no distinction between ints and floats, and act as documentation about the context outlined above.
If this sounds like a good idea, I'd be happy to create a PR for it.
Metadata
Metadata
Assignees
Labels
No labels