symbol-parser-0.3.0: Type level string parser combinators
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Type.Symbol.Parser.Types

Description

Data types and type synonyms for parsers and their defun symbols.

Synopsis

Parsers

type ParserCh s r = Char -> s -> Result s r Source #

Parse a Char with the given state.

The action is always consuming. For this reason, you may need to look ahead for the final case, so as to not consume an extra Char. This prevents many zero-length parsers. It's a bit weird. See Drop for an example.

data Result s r Source #

The result of a single step of a parser.

Constructors

Cont s

OK, continue with the given state

Done r

OK, parse successful with result r

Err E

parse error

Instances

Instances details
type App (FailChSym name e :: FunKind Char (s ~> Result s r) -> Type) (f :: Char) Source # 
Instance details

Defined in Data.Type.Symbol.Parser.Common

type App (FailChSym name e :: FunKind Char (s ~> Result s r) -> Type) (f :: Char)

type ParserEnd s r = s -> Either E r Source #

What a parser should do at the end of a Symbol.

data E Source #

Parser error.

Constructors

EBase

Base parser error.

Fields

EIn

Inner parser error inside combinator.

Fields

Instances

Instances details
type App (EmitEndSym :: FunKind b (Either E b) -> Type) (r :: b) Source # 
Instance details

Defined in Data.Type.Symbol.Parser.Common

type App (EmitEndSym :: FunKind b (Either E b) -> Type) (r :: b) = 'Right r :: Either E b
type App (FailEndSym name e :: FunKind a (Either E r) -> Type) (s :: a) Source # 
Instance details

Defined in Data.Type.Symbol.Parser.Common

type App (FailEndSym name e :: FunKind a (Either E r) -> Type) (s :: a) = 'Left ('EBase name e) :: Either E r

Defun symbols

type Parser s r = (ParserChSym s r, ParserEndSym s r, s) Source #

A parser you can pass (heh) around.

Parsers are defined by the product of a ParserCh character parser, ParserEnd end handler, and s starting state.

type ParserChSym s r = Char ~> (s ~> Result s r) Source #

A defunctionalization symbol for a ParserCh.

type ParserEndSym s r = s ~> Either E r Source #

A defunctionalization symbol for a ParserEnd.