diff options
author | Louis Pilfold <louis@lpil.uk> | 2022-01-09 18:52:02 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-01-09 18:52:02 +0000 |
commit | 855d5021bd991ddc6bfd2a2a1499c3ddce94b675 (patch) | |
tree | 5e4f37bbd657a264545ba131db1c4987b3a87f9c /src | |
parent | b68260179e2e17930dfb0604fc2b26355fc79173 (diff) | |
download | gleam_stdlib-855d5021bd991ddc6bfd2a2a1499c3ddce94b675.tar.gz gleam_stdlib-855d5021bd991ddc6bfd2a2a1499c3ddce94b675.zip |
Curry list
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/dynamic.gleam | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/gleam/dynamic.gleam b/src/gleam/dynamic.gleam index 44e6852..1cf8991 100644 --- a/src/gleam/dynamic.gleam +++ b/src/gleam/dynamic.gleam @@ -67,7 +67,7 @@ if javascript { /// when you need to give a decoder function but you don't actually care what /// the to-decode value is. /// -pub fn dynamic(term: Dynamic) -> Decoder(Dynamic) { +pub fn dynamic() -> Decoder(Dynamic) { Ok } @@ -342,24 +342,28 @@ pub fn result( /// ## Examples /// /// ```gleam -/// > list(from(["a", "b", "c"]), of: string) +/// > from(["a", "b", "c"]) +/// > |> list(of: string) /// Ok(["a", "b", "c"]) /// -/// > list(from([1, 2, 3]), of: string) +/// > from([1, 2, 3]) +/// > |> list(of: string) /// Error([DecodeError(expected: "String", found: "Int", path: [])]) /// -/// > list(from("ok"), of: string) +/// > from("ok") +/// > |> list(of: string) /// Error([DecodeError(expected: "List", found: "String", path: [])]) /// ``` /// pub fn list( - from dynamic: Dynamic, of decoder_type: fn(Dynamic) -> Result(inner, DecodeErrors), -) -> Result(List(inner), DecodeErrors) { - try list = shallow_list(dynamic) - list - |> list.try_map(decoder_type) - |> map_errors(push_path(_, "*")) +) -> Decoder(List(inner)) { + fn(dynamic) { + try list = shallow_list(dynamic) + list + |> list.try_map(decoder_type) + |> map_errors(push_path(_, "*")) + } } /// Checks to see if a `Dynamic` value is a nullable version of a particular |