HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

  • Packagederp-0.1.6
  • Exports33
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceDerp.hs

Data Types

2 declarations
datadata Parser t a
#

Represents both a formal context-free language and the reduction of a member of that language to a value of type a.

Instances1Show
  • Show (Parser t a)Defined in derp-0.1.6 · Text.Derp

Parser construction

7 declarations

Parser computation steps

3 declarations

Full parsing and result extraction

10 declarations

The number of compact steps that usually keeps a parser constant in size while parsing.

valuerunParse :: (Ord t, Ord a) => Parser t a -> [Token t] -> Set a
#

Parse using the default number of intermediate compactions. This is the main parsing function. Examples:

let e =     ter "num"
        <|> e <~> ter "+" <~> e ==> (\(x1,(o,x2)) -> "(" ++ x1 ++ o ++ x2 ++ ")")
in runParse e [Token "num" "1", Token "+" "+", Token "num" 3", Token "+" "+", Token "num" "5"]

evaluates to:

Set.fromList ["((1+3)+5)", "(1+(3+5))"]
let e =     ter "num" ==> read 
        <|> e <~> ter "+" <~> e ==> (\(x1,(_,x2)) -> x1 + x2)
in runParse e [Token "num" "1", Token "+" "+", Token "num" 3", Token "+" "+", Token "num" "5"]

evaluates to:

Set.fromList [9]

Demos

11 declarations