symparsec
Safe HaskellNone
LanguageGHC2021

Symparsec.Parser

Synopsis

Documentation

data State str n Source #

Parser state.

Constructors

State 

Fields

  • remaining :: str

    Remaining input.

  • length :: n

    Remaining permitted length.

    Must be less than or equal to the actual length of the remaining input. Parsers must use this field when reading from input:

    • if ==0, treat as end of input.
    • if >0 but remaining input is empty, unrecoverable parser error

    This extra bookkeeping permits much simpler parser design, specifically for parsers that act on a substring of the input.

  • index :: n

    Index in the input string.

    Overall index. Used for nicer error reporting after parse completion.

Instances

Instances details
Demotable SState Source # 
Instance details

Defined in Symparsec.Parser

Associated Types

type Demote SState 
Instance details

Defined in Symparsec.Parser

Methods

demote :: forall (k1 :: PState). SState k1 -> Demote SState #

(Show str, Show n) => Show (State str n) Source # 
Instance details

Defined in Symparsec.Parser

Methods

showsPrec :: Int -> State str n -> ShowS #

show :: State str n -> String #

showList :: [State str n] -> ShowS #

type Demote SState Source # 
Instance details

Defined in Symparsec.Parser

type App PExpr (s :: PState) Source # 
Instance details

Defined in Symparsec.Example.Expr

type App PExpr (s :: PState) = PExprNext s ('[] :: [ExprTok]) ('[] :: [Expr Natural]) (UnconsState s)
type App Eof (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Eof

type App Eof (s :: PState)
type App TakeRest (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.TakeRest

type App TakeRest (s :: PState)
type App TakeSym (n :: Natural) Source # 
Instance details

Defined in Symparsec.Parser.Take

type App TakeSym (n :: Natural) = Take n
type App (Ensure n :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Ensure

type App (Ensure n :: FunKind PState (PReply ()) -> Type) (s :: PState)
type App (Literal lit :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Literal

type App (Literal lit :: FunKind PState (PReply ()) -> Type) (s :: PState)
type App (SkipUnsafe n :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Skip

type App (SkipUnsafe n :: FunKind PState (PReply ()) -> Type) (s :: PState)
type App (Take n :: FunKind PState (PReply Symbol) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Take

type App (Take n :: FunKind PState (PReply Symbol) -> Type) (s :: PState)
type App (TakeWhile chPred :: FunKind PState (PReply Symbol) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.TakeWhile

type App (TakeWhile chPred :: FunKind PState (PReply Symbol) -> Type) (s :: PState)
type App (Empty :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Alternative

type App (Empty :: FunKind PState (PReply a) -> Type) (s :: PState) = 'Reply ('Err (Error1 "called empty parser") :: Result Symbol Natural a) s
type App (NatBase base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type App (NatBase base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState)
type App (NatBaseWhile base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type App (NatBaseWhile base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState)
type App (Try p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Try

type App (Try p :: FunKind PState (PReply a) -> Type) (s :: PState)
type App (Pure a2 :: FunKind PState (PReply a1) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Applicative

type App (Pure a2 :: FunKind PState (PReply a1) -> Type) (s :: PState) = 'Reply ('OK a2 :: Result Symbol Natural a1) s
type App (IsolateSym p :: FunKind Natural (PParser a) -> Type) (n :: Natural) Source # 
Instance details

Defined in Symparsec.Parser.Isolate

type App (IsolateSym p :: FunKind Natural (PParser a) -> Type) (n :: Natural) = Isolate n p
type App (NatBase1 base parseDigit digit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type App (NatBase1 base parseDigit digit :: FunKind PState (PReply Natural) -> Type) (s :: PState)
type App (Count n p :: FunKind PState (PReply [k]) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Count

type App (Count n p :: FunKind PState (PReply [k]) -> Type) (s :: PState)
type App (l <|> r :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Alternative

type App (l <|> r :: FunKind PState (PReply a) -> Type) (s :: PState)
type App (Isolate n p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Isolate

type App (Isolate n p :: FunKind PState (PReply a) -> Type) (s :: PState)
type App (While chPred p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.While

type App (While chPred p :: FunKind PState (PReply a) -> Type) (s :: PState)
type App (f <$> p :: FunKind PState (PReply a2) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Functor

type App (f <$> p :: FunKind PState (PReply a2) -> Type) (s :: PState)
type App (l <*> r :: FunKind PState (PReply b) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Applicative

type App (l <*> r :: FunKind PState (PReply b) -> Type) (s :: PState)
type App (l >>= r :: FunKind PState (PReply b) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Monad

type App (l >>= r :: FunKind PState (PReply b) -> Type) (s :: PState)

data SState (s :: PState) where Source #

Singled State.

Constructors

SState :: forall (rem :: Symbol) (len :: Natural) (idx :: Natural). SSymbol rem -> SNat len -> SNat idx -> SState ('State rem len idx) 

Instances

Instances details
Demotable SState Source # 
Instance details

Defined in Symparsec.Parser

Associated Types

type Demote SState 
Instance details

Defined in Symparsec.Parser

Methods

demote :: forall (k1 :: PState). SState k1 -> Demote SState #

type Demote SState Source # 
Instance details

Defined in Symparsec.Parser

demoteSState :: forall (s :: PState). SState s -> State String Natural Source #

Demote an SState.

data Error str Source #

Constructors

Error 

Fields

Instances

Instances details
Demotable SError Source # 
Instance details

Defined in Symparsec.Parser

Associated Types

type Demote SError 
Instance details

Defined in Symparsec.Parser

Methods

demote :: forall (k1 :: PError). SError k1 -> Demote SError #

Show str => Show (Error str) Source # 
Instance details

Defined in Symparsec.Parser

Methods

showsPrec :: Int -> Error str -> ShowS #

show :: Error str -> String #

showList :: [Error str] -> ShowS #

type Demote SError Source # 
Instance details

Defined in Symparsec.Parser

type PError = Error Symbol Source #

Promoted Error.

data SError (e :: PError) where Source #

Singled Error.

Constructors

SError :: forall (detail :: [Symbol]). SList SSymbol detail -> SError ('Error detail) 

Instances

Instances details
Demotable SError Source # 
Instance details

Defined in Symparsec.Parser

Associated Types

type Demote SError 
Instance details

Defined in Symparsec.Parser

Methods

demote :: forall (k1 :: PError). SError k1 -> Demote SError #

type Demote SError Source # 
Instance details

Defined in Symparsec.Parser

demoteSError :: forall (e :: PError). SError e -> Error String Source #

Demote an SError.

data Reply str n a Source #

Parser completion: result, and final state.

TODO: megaparsec also returns a bool indicating if any input was consumed. Unsure what it's used for.

Constructors

Reply 

Fields

Instances

Instances details
Demotable sa => Demotable (SReply sa :: PReply a -> Type) Source # 
Instance details

Defined in Symparsec.Parser

Associated Types

type Demote (SReply sa :: PReply a -> Type) 
Instance details

Defined in Symparsec.Parser

type Demote (SReply sa :: PReply a -> Type) = Reply String Natural (Demote sa)

Methods

demote :: forall (k1 :: PReply a). SReply sa k1 -> Demote (SReply sa) #

(Show a, Show str, Show n) => Show (Reply str n a) Source # 
Instance details

Defined in Symparsec.Parser

Methods

showsPrec :: Int -> Reply str n a -> ShowS #

show :: Reply str n a -> String #

showList :: [Reply str n a] -> ShowS #

type App PExpr (s :: PState) Source # 
Instance details

Defined in Symparsec.Example.Expr

type App PExpr (s :: PState) = PExprNext s ('[] :: [ExprTok]) ('[] :: [Expr Natural]) (UnconsState s)
type App Eof (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Eof

type App Eof (s :: PState)
type App TakeRest (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.TakeRest

type App TakeRest (s :: PState)
type App TakeSym (n :: Natural) Source # 
Instance details

Defined in Symparsec.Parser.Take

type App TakeSym (n :: Natural) = Take n
type App (Ensure n :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Ensure

type App (Ensure n :: FunKind PState (PReply ()) -> Type) (s :: PState)
type App (Literal lit :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Literal

type App (Literal lit :: FunKind PState (PReply ()) -> Type) (s :: PState)
type App (SkipUnsafe n :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Skip

type App (SkipUnsafe n :: FunKind PState (PReply ()) -> Type) (s :: PState)
type App (Take n :: FunKind PState (PReply Symbol) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Take

type App (Take n :: FunKind PState (PReply Symbol) -> Type) (s :: PState)
type App (TakeWhile chPred :: FunKind PState (PReply Symbol) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.TakeWhile

type App (TakeWhile chPred :: FunKind PState (PReply Symbol) -> Type) (s :: PState)
type App (Empty :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Alternative

type App (Empty :: FunKind PState (PReply a) -> Type) (s :: PState) = 'Reply ('Err (Error1 "called empty parser") :: Result Symbol Natural a) s
type App (NatBase base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type App (NatBase base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState)
type App (NatBaseWhile base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type App (NatBaseWhile base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState)
type App (Try p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Try

type App (Try p :: FunKind PState (PReply a) -> Type) (s :: PState)
type App (Pure a2 :: FunKind PState (PReply a1) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Applicative

type App (Pure a2 :: FunKind PState (PReply a1) -> Type) (s :: PState) = 'Reply ('OK a2 :: Result Symbol Natural a1) s
type App (IsolateSym p :: FunKind Natural (PParser a) -> Type) (n :: Natural) Source # 
Instance details

Defined in Symparsec.Parser.Isolate

type App (IsolateSym p :: FunKind Natural (PParser a) -> Type) (n :: Natural) = Isolate n p
type App (NatBase1 base parseDigit digit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type App (NatBase1 base parseDigit digit :: FunKind PState (PReply Natural) -> Type) (s :: PState)
type App (Count n p :: FunKind PState (PReply [k]) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Count

type App (Count n p :: FunKind PState (PReply [k]) -> Type) (s :: PState)
type App (l <|> r :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Alternative

type App (l <|> r :: FunKind PState (PReply a) -> Type) (s :: PState)
type App (Isolate n p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Isolate

type App (Isolate n p :: FunKind PState (PReply a) -> Type) (s :: PState)
type App (While chPred p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.While

type App (While chPred p :: FunKind PState (PReply a) -> Type) (s :: PState)
type App (f <$> p :: FunKind PState (PReply a2) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Functor

type App (f <$> p :: FunKind PState (PReply a2) -> Type) (s :: PState)
type App (l <*> r :: FunKind PState (PReply b) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Applicative

type App (l <*> r :: FunKind PState (PReply b) -> Type) (s :: PState)
type App (l >>= r :: FunKind PState (PReply b) -> Type) (s :: PState) Source # 
Instance details

Defined in Symparsec.Parser.Monad

type App (l >>= r :: FunKind PState (PReply b) -> Type) (s :: PState)
type Demote (SReply sa :: PReply a -> Type) Source # 
Instance details

Defined in Symparsec.Parser

type Demote (SReply sa :: PReply a -> Type) = Reply String Natural (Demote sa)

data SReply (sa :: a -> Type) (rep :: PReply a) where Source #

Singled Reply.

Constructors

SReply :: forall {a} (sa :: a -> Type) (result :: Result Symbol Natural a) (state :: State Symbol Natural). SResult sa result -> SState state -> SReply sa ('Reply result state) 

Instances

Instances details
Demotable sa => Demotable (SReply sa :: PReply a -> Type) Source # 
Instance details

Defined in Symparsec.Parser

Associated Types

type Demote (SReply sa :: PReply a -> Type) 
Instance details

Defined in Symparsec.Parser

type Demote (SReply sa :: PReply a -> Type) = Reply String Natural (Demote sa)

Methods

demote :: forall (k1 :: PReply a). SReply sa k1 -> Demote (SReply sa) #

type Demote (SReply sa :: PReply a -> Type) Source # 
Instance details

Defined in Symparsec.Parser

type Demote (SReply sa :: PReply a -> Type) = Reply String Natural (Demote sa)

demoteSReply :: forall {a} sa da (rep :: PReply a). (forall (a1 :: a). sa a1 -> da) -> SReply sa rep -> Reply String Natural da Source #

Demote an 'SReply.

data Result str (n :: k) a Source #

Parse result: a value, or an error.

Constructors

OK a

Parser succeeded.

Err (Error str)

Parser failed.

Instances

Instances details
Demotable sa => Demotable (SResult sa :: PResult a -> Type) Source # 
Instance details

Defined in Symparsec.Parser

Associated Types

type Demote (SResult sa :: PResult a -> Type) 
Instance details

Defined in Symparsec.Parser

Methods

demote :: forall (k1 :: PResult a). SResult sa k1 -> Demote (SResult sa) #

(Show a, Show str) => Show (Result str n a) Source # 
Instance details

Defined in Symparsec.Parser

Methods

showsPrec :: Int -> Result str n a -> ShowS #

show :: Result str n a -> String #

showList :: [Result str n a] -> ShowS #

type Demote (SResult sa :: PResult a -> Type) Source # 
Instance details

Defined in Symparsec.Parser

data SResult (sa :: a -> Type) (res :: PResult a) where Source #

Singled Result.

Constructors

SOK :: forall {a} (sa :: a -> Type) (a1 :: a). sa a1 -> SResult sa ('OK a1 :: Result Symbol Natural a) 
SErr :: forall {a} (e :: Error Symbol) (sa :: a -> Type). SError e -> SResult sa ('Err e :: Result Symbol Natural a) 

Instances

Instances details
Demotable sa => Demotable (SResult sa :: PResult a -> Type) Source # 
Instance details

Defined in Symparsec.Parser

Associated Types

type Demote (SResult sa :: PResult a -> Type) 
Instance details

Defined in Symparsec.Parser

Methods

demote :: forall (k1 :: PResult a). SResult sa k1 -> Demote (SResult sa) #

type Demote (SResult sa :: PResult a -> Type) Source # 
Instance details

Defined in Symparsec.Parser

demoteSResult :: forall {a} sa da (res :: PResult a). (forall (a1 :: a). sa a1 -> da) -> SResult sa res -> Result String Natural da Source #

Demote an SResult.

type Parser str n a = State str n -> Reply str n a Source #

A parser is a function on parser state.

type PParser a = PState ~> PReply a Source #

Promoted Parser: a defunctionalization symbol to a function on promoted parser state.

type SParser (sa :: a -> Type) (p :: PState ~> PReply a) = Lam SState (SReply sa) p Source #

Singled Parser.