lerzegov/elm-markup-fork/1.0.0

NOTE: the latest version is 2.0.0

Formerly lerzegov/elm-markup. Search finds this package by either name.

Mrk.Internal.TolerantParser

type alias Parser context problem data =
Parser context problem (Result (List problem) data)
try : Parser c p d -> Parser c p d

This might be a little odd, but it essentially means the parser its attached to should run normally, meaning it's ok if it fails.

This is generally useful with a oneOf, to ensure that an option can fail in the normal way and skip to try the next option.

type alias Token problem =
{ match : String
, problem : problem
, onError : OnError problem
}
token : Token problem -> Parser context problem ()
keyword : Token problem -> Parser context problem ()
symbol : Token problem -> Parser context problem ()
type OnError error
= FastForwardTo (List Char)
| Skip
| StopWith error
fastForwardTo : List Char -> OnError error
stopWith : a -> OnError a
succeed : data -> Parser context problem data
ignore : Parser c p ignore -> Parser c p keep -> Parser c p keep
keep : Parser c p a -> Parser c p (a -> b) -> Parser c p b

Almost like |=, except

problem
-> List (Parser context problem data)
-> Parser context problem data

A tolerant oneOf means it has to succeed.

So, you provide an error to return if everything else fails.

chompWhile : (Char -> Bool) -> Parser c x (Result error ())
map : (a -> b) -> Parser c p a -> Parser c p b