FR
PréludeChargé par défaut — aucun import nécessaire.

Parse — parse a value back from its show text (the dual of Show)

Synopsis
dropWs : List Char -> List Char

Drop leading whitespace.

allBlank : List Char -> Bool

Is the rest only whitespace? (parse requires it after the value.)

orElse : Maybe (a, List Char) -> Maybe (a, List Char) -> Maybe (a, List Char)

The first parser that succeeds (used for constructor alternatives).

isIdentChar : Char -> Bool
pName : String -> List Char -> Maybe (List Char)

Expect the exact constructor name at the front (after spaces), as a WHOLE token — the following char, if any, must not continue an identifier, so Red does not match the prefix of RedX. Returns the unconsumed rest.

optParen : (List Char -> Maybe (a, List Char)) -> List Char -> Maybe (a, List Char)

Run p, accepting one optional layer of surrounding parentheses (show adds them around a compound or negative argument).

pChar : Char -> List Char -> Maybe (List Char)

Expect a single literal character (after spaces); return the rest.

intP : List Char -> Maybe (Int, List Char)

Parse a signed integer from the front.

fixedP : (Int -> w) -> (w -> Int) -> List Char -> Maybe (w, List Char)

Parse a signed integer prefix, then NARROW it to a fixed-width scalar via the supplied wrap : Int -> w / val : w -> Int. Succeeds only when the value ROUND-TRIPS (val (wrap n) == n) — i.e. it lies in the type's range; an out-of-range literal (256/-1 for Word8, 128 for Int8) fails with Nothing, exactly like tryCast : Int -> Maybe wN. Accepts one optional paren layer (Show's showParen wraps a negative IntN at precedence > 6), mirroring Parse Int. Parametric in w (no dictionary): the caller supplies the target width's own wrap/val pair.

doubleP : List Char -> Maybe (Double, List Char)

Consume a Double LEXEME — [+-]?(digits(.digits?)?|.digits)([eE][+-]?digits)? — from the FRONT, then convert exactly that lexeme with parseDouble (finite, bit-exact across backends). Returns the value with the unconsumed rest, so a Double COMPOSES inside a tuple/list parse — unlike parseDouble, which demands the WHOLE string. A lone . (no digits), or an e not followed by exponent digits, is not part of the number (that e is left for the caller). The lexeme is built to the same grammar the JS backend's parseDouble regex accepts, so the three parseDouble implementations (OCaml/JS/C) never disagree on it.

charP : List Char -> Maybe (Char, List Char)

Parse a 'c'-style character literal (with show's escapes).

unescape : Char -> Maybe Char
strP : List Char -> Maybe (String, List Char)

Parse a "…"-style string literal, un-escaping \" \\ \n \t \r (the inverse of Show String's escaping, so parse (show s) == Just s).

unescStr : Char -> Maybe Char
parseListElems : (List Char -> Maybe (a, List Char)) -> List Char -> Maybe (List a, List Char)

Parse the elements of a list after the opening [ — empty ], or a comma-separated sequence ending in ]. The element parser rd is supplied by the caller.