zwilias / json-decode-exploration / Json.Decode.Exploration.Located

A type that gives one or more pieces of information, tagged with a path through a datastructure with fields and indices.

Most importantly, it is used for both Warnings and Errors in Json.Decode.Exploration.


type Located a
    = InField String (List.Nonempty.Nonempty (Located a))
    | AtIndex Basics.Int (List.Nonempty.Nonempty (Located a))
    | Here a

toString : (a -> List String) -> List.Nonempty.Nonempty (Located a) -> List String

Allows turning a non-empty list of Located a into a flat list of human readable strings, provided we have a way to turn an a into some lines of text.

Each string represents a line. This allows arbitrary indentation by mapping over the lines and prepending some whitespace.

map : (a -> b) -> Located a -> Located b