gleam-lang / stdlib

🎁 Gleam's standard library

Home Page:https://hexdocs.pm/gleam_stdlib/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Return index of undecodable element in dynamic.list DecodeError path

johtso opened this issue · comments

pub fn list(
of decoder_type: fn(Dynamic) -> Result(inner, DecodeErrors),
) -> Decoder(List(inner)) {
fn(dynamic) {
use list <- result.try(shallow_list(dynamic))
list
|> list.try_map(decoder_type)
|> map_errors(push_path(_, "*"))
}
}

I think it would be nice to return the index of the offending element instead of just "*"

I'm new to gleam, but I had a little play around trying to implement this and could open a pull request..

Fab idea! Thank you