diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-12-16 17:33:34 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-12-16 17:37:34 +0000 |
commit | c9740d8b7303dbea5608b3c8f92efe152e767066 (patch) | |
tree | adba2a8b0eb2db0f4200194dc72cbcf2ea0943f9 /gen/src/gleam@dynamic.erl | |
parent | 83bac4a44cbed306f90cdbb701564af3706bbaab (diff) | |
download | gleam_stdlib-c9740d8b7303dbea5608b3c8f92efe152e767066.tar.gz gleam_stdlib-c9740d8b7303dbea5608b3c8f92efe152e767066.zip |
Any -> Dynamic
Closes https://github.com/gleam-lang/stdlib/issues/8
Diffstat (limited to 'gen/src/gleam@dynamic.erl')
-rw-r--r-- | gen/src/gleam@dynamic.erl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gen/src/gleam@dynamic.erl b/gen/src/gleam@dynamic.erl new file mode 100644 index 0000000..e20db87 --- /dev/null +++ b/gen/src/gleam@dynamic.erl @@ -0,0 +1,40 @@ +-module(gleam@dynamic). +-compile(no_auto_import). + +-export([from/1, unsafe_coerce/1, string/1, int/1, float/1, atom/1, bool/1, thunk/1, list/2, field/2]). + +from(A) -> + gleam_stdlib:identity(A). + +unsafe_coerce(A) -> + gleam_stdlib:identity(A). + +string(A) -> + gleam_stdlib:decode_string(A). + +int(A) -> + gleam_stdlib:decode_int(A). + +float(A) -> + gleam_stdlib:decode_float(A). + +atom(A) -> + gleam_stdlib:decode_atom(A). + +bool(A) -> + gleam_stdlib:decode_bool(A). + +thunk(A) -> + gleam_stdlib:decode_thunk(A). + +list_dynamic(A) -> + gleam_stdlib:decode_list(A). + +list(Dynamic, DecoderType) -> + gleam@result:then( + list_dynamic(Dynamic), + fun(Capture1) -> gleam@list:traverse(Capture1, DecoderType) end + ). + +field(A, B) -> + gleam_stdlib:decode_field(A, B). |