ihp-router-1.0.0: Trie-based routing with a Yesod-style DSL for WAI
Safe HaskellNone
LanguageGHC2021

IHP.Router.DSL.Parser

Description

The parser consumes the textual body of a [routes| ... |] block and produces a Routes AST. Errors carry the source line number so the TH splice can report them with useful context.

The parser is intentionally hand-rolled — the DSL is small (~7 production rules) and we want precise control over error messages.

Synopsis

Documentation

parseRoutes :: Text -> Either ParseError Routes Source #

Parse a raw [routes|...|] body into a Routes AST.

The input is the text between the opening | and the closing |] (the quoter strips those).

The block may optionally start with a controller-name header — a bare uppercase identifier on its own line before any route lines. If absent, the block is multi-controller and the splice groups routes by reifying each action constructor to find its parent type.

data ParseError Source #

Parse error from the DSL parser.

The Int is the 1-based source line number inside the quasi-quote body (the controller header is line 1).

Constructors

ParseError 

Fields

Instances

Instances details
Show ParseError Source # 
Instance details

Defined in IHP.Router.DSL.Parser

Eq ParseError Source # 
Instance details

Defined in IHP.Router.DSL.Parser