diff options
author | Louis Pilfold <louis@lpil.uk> | 2022-01-01 21:03:42 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-01-01 21:08:50 +0000 |
commit | 5c07c721e2302b73b20f27a58634a8a3dfa7a6c3 (patch) | |
tree | 42ed76f4463b72e1d67faa5b77cda56b79640ec1 /src | |
parent | 284b9f0ff406d40a8eaf2b6d8faaef8813594153 (diff) | |
download | gleam_stdlib-5c07c721e2302b73b20f27a58634a8a3dfa7a6c3.tar.gz gleam_stdlib-5c07c721e2302b73b20f27a58634a8a3dfa7a6c3.zip |
Change dynamic convention
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/dynamic.gleam | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/gleam/dynamic.gleam b/src/gleam/dynamic.gleam index a3c43d8..c500640 100644 --- a/src/gleam/dynamic.gleam +++ b/src/gleam/dynamic.gleam @@ -213,20 +213,20 @@ if javascript { } /// Checks to see whether a `Dynamic` value is a list, and returns that list if it -/// is. +/// is. The types of the elements are not checked. /// -/// If you wish to decode all the elements in the list use the `typed_list` +/// If you wish to decode all the elements in the list use the `list` /// instead. /// /// ## Examples /// -/// > list(from(["a", "b", "c"])) +/// > shallow_list(from(["a", "b", "c"])) /// Ok([from("a"), from("b"), from("c")]) /// -/// > list(1) +/// > shallow_list(1) /// Error(DecodeError(expected: "Int", found: "Int")) /// -pub fn list(from value: Dynamic) -> Result(List(Dynamic), DecodeError) { +pub fn shallow_list(from value: Dynamic) -> Result(List(Dynamic), DecodeError) { decode_list(value) } @@ -318,21 +318,21 @@ pub fn typed_result( /// /// ## Examples /// -/// > typed_list(from(["a", "b", "c"]), of: string) +/// > list(from(["a", "b", "c"]), of: string) /// Ok(["a", "b", "c"]) /// -/// > typed_list(from([1, 2, 3]), of: string) +/// > list(from([1, 2, 3]), of: string) /// Error(DecodeError(expected: "String", found: "Int")) /// -/// > typed_list(from("ok"), of: string) +/// > list(from("ok"), of: string) /// Error(DecodeError(expected: "List", found: "String")) /// -pub fn typed_list( +pub fn list( from dynamic: Dynamic, of decoder_type: fn(Dynamic) -> Result(inner, DecodeError), ) -> Result(List(inner), DecodeError) { dynamic - |> list + |> shallow_list |> result.then(list.try_map(_, decoder_type)) } |