diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-03-17 22:34:47 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-03-17 22:34:47 +0000 |
commit | 336614d8fc815d5eec7461ed271ae45697d9216c (patch) | |
tree | 080d436207f2c6f31f98d470d35cbbe8af46163d | |
parent | 0f0f3df21b71678504cd8c0fb0e55dfd7af5f176 (diff) | |
download | gleam_stdlib-336614d8fc815d5eec7461ed271ae45697d9216c.tar.gz gleam_stdlib-336614d8fc815d5eec7461ed271ae45697d9216c.zip |
Handle module select calls on non-literal modules
-rw-r--r-- | gen/any.erl | 12 | ||||
-rw-r--r-- | src/any.gleam | 18 |
2 files changed, 20 insertions, 10 deletions
diff --git a/gen/any.erl b/gen/any.erl index 951fab9..09d7d9d 100644 --- a/gen/any.erl +++ b/gen/any.erl @@ -2,7 +2,7 @@ -compile(no_auto_import). -include_lib("eunit/include/eunit.hrl"). --export([from/1, unsafeCoerce/1, string/1, int/1, float/1, bool/1, thunk/1, tuple/1, field/2]). +-export([from/1, unsafeCoerce/1, string/1, int/1, float/1, bool/1, thunk/1, list/2, tuple/1, field/2]). from(A) -> gleam__stdlib:identity(A). @@ -57,6 +57,16 @@ bool_test() -> thunk(A) -> gleam__stdlib:thunk(A). +list_any(A) -> + gleam__stdlib:decode_list(A). + +list_module() -> + list. + +list(Any, Decode) -> + result:then(list_any(Any), + fun(X) -> (list_module()):traverse(X, Decode) end). + tuple(A) -> gleam__stdlib:decode_tuple(A). diff --git a/src/any.gleam b/src/any.gleam index 22dd0d5..5deaeb8 100644 --- a/src/any.gleam +++ b/src/any.gleam @@ -172,17 +172,17 @@ pub external fn thunk(Any) -> Result(fn() -> Any, String) //// |> expect:is_error //// } -// external fn list_any(Any) -> Result(List(Any), String) = "gleam__stdlib" "decode_list" +external fn list_any(Any) -> Result(List(Any), String) = "gleam__stdlib" "decode_list" -// fn list_module() { -// list -// } +fn list_module() { + list +} -// pub fn list(any, decode) { -// any -// |> list_any -// |> result:then(_, fn(x) { list_module():traverse(x, decode) }) -// } +pub fn list(any, decode) { + any + |> list_any + |> result:then(_, fn(x) { list_module():traverse(x, decode) }) +} //// test list { //// let _ = [] |