HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulederp-0.1.6Haskell98

Text.Derp

Contents
  1. Data Types
  2. Parser construction
  3. Parser computation steps
  4. Full parsing and result extraction
  5. Demos
Synopsis
  • Packagederp-0.1.6
  • Exports33
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceDerp.hs

Data Types

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

Parser computation steps

Full parsing and result extraction

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