symparsec-1.1.0: Type level string parser combinators
Safe HaskellSafe-Inferred
LanguageGHC2021

Symparsec.Parser.Natural

Synopsis

Documentation

type NatBin = NatBase 2 ParseDigitBinSym Source #

Parse a binary (base 2) natural.

type NatOct = NatBase 8 ParseDigitOctSym Source #

Parse an octal (base 8) natural.

type NatDec = NatBase 10 ParseDigitDecSym Source #

Parse a decimal (base 10) natural.

type NatHex = NatBase 16 ParseDigitHexSym Source #

Parse a hexadecimal (base 16) natural. Permits mixed-case (0-9A-Fa-f).

type NatBase base parseDigit = 'PParser (NatBaseChSym base parseDigit) NatBaseEndSym Nothing Source #

Parse a natural in the given base, using the given digit parser.

sNatBase :: SNat base -> SParseDigit parseDigit -> SParser (SMaybe SNat) SNat (NatBase base parseDigit) Source #

type NatBaseCh base parseDigit ch mn = NatBaseCh' base mn (parseDigit @@ ch) Source #

type family NatBaseCh' base mn mDigit where ... Source #

Equations

NatBaseCh' base (Just n) (Just digit) = Cont (Just ((n * base) + digit)) 
NatBaseCh' base Nothing (Just digit) = Cont (Just digit) 
NatBaseCh' base mn Nothing = Err (EInvalidDigit base) 

type EInvalidDigit base = EBase "NatBase" ((Text "not a base " :<>: Text (ShowNatDec base)) :<>: Text " digit") Source #

data NatBaseChSym base parseDigit f Source #

Instances

Instances details
(KnownNat base, SingParseDigit parseDigit) => SingParser (NatBase base parseDigit :: PParser (Maybe Natural) Natural) Source # 
Instance details

Defined in Symparsec.Parser.Natural

Associated Types

type PS (NatBase base parseDigit) :: s -> Type Source #

type PR (NatBase base parseDigit) :: r -> Type Source #

Methods

singParser' :: SParser (PS (NatBase base parseDigit)) (PR (NatBase base parseDigit)) (NatBase base parseDigit) Source #

type PS (NatBase base parseDigit :: PParser (Maybe Natural) Natural) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type PS (NatBase base parseDigit :: PParser (Maybe Natural) Natural) = SMaybe SNat
type App (NatBaseChSym base parseDigit :: FunKind Char (Maybe Natural ~> PResult (Maybe Natural) Natural) -> Type) (f :: Char) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type App (NatBaseChSym base parseDigit :: FunKind Char (Maybe Natural ~> PResult (Maybe Natural) Natural) -> Type) (f :: Char) = NatBaseChSym1 base parseDigit f
type PR (NatBase base parseDigit :: PParser (Maybe Natural) Natural) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type PR (NatBase base parseDigit :: PParser (Maybe Natural) Natural) = SNat

data NatBaseChSym1 base parseDigit ch mn Source #

Instances

Instances details
type App (NatBaseChSym1 base parseDigit ch :: FunKind (Maybe Natural) (PResult (Maybe Natural) Natural) -> Type) (mn :: Maybe Natural) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type App (NatBaseChSym1 base parseDigit ch :: FunKind (Maybe Natural) (PResult (Maybe Natural) Natural) -> Type) (mn :: Maybe Natural) = NatBaseCh base parseDigit ch mn

sNatBaseChSym :: SNat base -> SParseDigit parseDigit -> SParserChSym (SMaybe SNat) SNat (NatBaseChSym base parseDigit) Source #

type family NatBaseEnd mn where ... Source #

type EEmpty = EBase "NatBase" (Text "no digits parsed") Source #

data NatBaseEndSym mn Source #

Instances

Instances details
(KnownNat base, SingParseDigit parseDigit) => SingParser (NatBase base parseDigit :: PParser (Maybe Natural) Natural) Source # 
Instance details

Defined in Symparsec.Parser.Natural

Associated Types

type PS (NatBase base parseDigit) :: s -> Type Source #

type PR (NatBase base parseDigit) :: r -> Type Source #

Methods

singParser' :: SParser (PS (NatBase base parseDigit)) (PR (NatBase base parseDigit)) (NatBase base parseDigit) Source #

type PS (NatBase base parseDigit :: PParser (Maybe Natural) Natural) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type PS (NatBase base parseDigit :: PParser (Maybe Natural) Natural) = SMaybe SNat
type PR (NatBase base parseDigit :: PParser (Maybe Natural) Natural) Source # 
Instance details

Defined in Symparsec.Parser.Natural

type PR (NatBase base parseDigit :: PParser (Maybe Natural) Natural) = SNat
type App NatBaseEndSym (mn :: Maybe Natural) Source # 
Instance details

Defined in Symparsec.Parser.Natural