Safe Haskell | None |
---|---|
Language | GHC2021 |
Symparsec.Parser.Common
Description
Common definitions used by parsers.
Synopsis
- type family UnconsState (s :: PState) :: (Maybe Char, PState) where ...
- type Error1 (str1 :: str) = 'Error '[str1]
- type EStrInputTooShort (nNeed :: Natural) (nGot :: Natural) = ((("needed " ++ ShowNatDec nNeed) ++ " chars, but only ") ++ ShowNatDec nGot) ++ " remain"
- type EStrWrongChar (chExpect :: Char) (chGot :: Char) = ((("expected '" ++ ShowChar chExpect) ++ "', got '") ++ ShowChar chGot) ++ "'"
- type Impossible = TypeError ('Text "impossible parser state") :: k
- module Symparsec.Parser
- data Doc s
- type (++) (l :: Symbol) (r :: Symbol) = AppendSymbol l r
- type family App (f :: a ~> b) (x :: a) :: b
- data Symbol
- type family UnconsSymbol (a :: Symbol) :: Maybe (Char, Symbol) where ...
- type family ConsSymbol (a :: Char) (b :: Symbol) :: Symbol where ...
- data Natural
- type family (a :: Natural) + (b :: Natural) :: Natural where ...
- type family (a :: Natural) - (b :: Natural) :: Natural where ...
- type family (a :: Natural) * (b :: Natural) :: Natural where ...
- type ShowNatDec (n :: Natural) = ShowNatBase 10 ShowNatDigitHexLowerSym n
- type ShowChar (ch :: Char) = ConsSymbol ch ""
- type (@@) (a1 :: a ~> k) (b :: a) = App a1 b
- type (~>) a b = Fun a b
Common definitions
type family UnconsState (s :: PState) :: (Maybe Char, PState) where ... Source #
Get the next character in the string and update the parser state.
If at end of the string, the state is returned untouched, and len
is
guaranteed to be 0.
Equations
UnconsState ('State rem 0 idx) = '('Nothing :: Maybe Char, 'State rem 0 idx) | |
UnconsState ('State rem len idx) = UnconsState' (UnconsSymbol rem) len idx |
type EStrInputTooShort (nNeed :: Natural) (nGot :: Natural) = ((("needed " ++ ShowNatDec nNeed) ++ " chars, but only ") ++ ShowNatDec nGot) ++ " remain" Source #
type EStrWrongChar (chExpect :: Char) (chGot :: Char) = ((("expected '" ++ ShowChar chExpect) ++ "', got '") ++ ShowChar chGot) ++ "'" Source #
type Impossible = TypeError ('Text "impossible parser state") :: k Source #
Impossible parser state.
Use when you can prove that an equation is impossible.
Re-exports
module Symparsec.Parser
Simple pretty document ADT.
Designed to work on both type level (as a limited ErrorMessage
) and term
level (as a boring ADT).
Note that ShowType
is magical (see
compilerGHCCore/Type.hs#L1309
), so we need to remove it for term level.
singletons-base defines a version of this, but retains the ShowType
constructor and is in the singletons ecosystem.
Constructors
Text s | plain ol' text |
(Doc s) :<>: (Doc s) | append docs next to each other |
(Doc s) :$$: (Doc s) | stack docs on top of each other (newline) |
type (++) (l :: Symbol) (r :: Symbol) = AppendSymbol l r #
type family App (f :: a ~> b) (x :: a) :: b #
Type level function application.
Instances
type App ShowNatDigitHexLowerSym (d :: Natural) # | |
Defined in TypeLevelShow.Natural.Digit | |
type App ShowNatDigitHexUpperSym (d :: Natural) # | |
Defined in TypeLevelShow.Natural.Digit | |
type App NotSym (x :: Bool) # | |
Defined in DeFun.Bool | |
type App IsAlphaSym (ch :: Char) Source # | |
Defined in Symparsec.Parser.While.Predicates | |
type App IsDecDigitSym (ch :: Char) Source # | |
Defined in Symparsec.Parser.While.Predicates | |
type App IsHexDigitSym (ch :: Char) Source # | |
Defined in Symparsec.Parser.While.Predicates | |
type App (LAndSym1 x :: FunKind Bool Bool -> Type) (y :: Bool) # | |
type App (LOrSym1 x :: FunKind Bool Bool -> Type) (y :: Bool) # | |
type App (IdSym :: FunKind a a -> Type) (x :: a) # | |
type App (Con1 f :: FunKind a b -> Type) (x :: a) # | |
Defined in DeFun.Core | |
type App (JoinSym1 f :: FunKind a b -> Type) (x :: a) # | |
type App (ConstSym1 x :: FunKind b a -> Type) (y :: b) # | |
type App (ApSym2 f g :: FunKind a c -> Type) (x :: a) # | |
type App (CompSym2 f g :: FunKind a c -> Type) (x :: a) # | |
type App (FlipSym2 f b2 :: FunKind a1 c -> Type) (a2 :: a1) # | |
type App PExpr (s :: PState) Source # | |
Defined in Symparsec.Example.Expr | |
type App Eof (s :: PState) Source # | |
Defined in Symparsec.Parser.Eof | |
type App TakeRest (s :: PState) Source # | |
Defined in Symparsec.Parser.TakeRest | |
type App TakeSym (n :: Natural) Source # | |
Defined in Symparsec.Parser.Take | |
type App ParseDigitBinSym (ch :: Char) Source # | |
Defined in Symparsec.Parser.Natural.Digits | |
type App ParseDigitDecSym (ch :: Char) Source # | |
Defined in Symparsec.Parser.Natural.Digits | |
type App ParseDigitHexSym (ch :: Char) Source # | |
Defined in Symparsec.Parser.Natural.Digits | |
type App ParseDigitOctSym (ch :: Char) Source # | |
Defined in Symparsec.Parser.Natural.Digits | |
type App (Ensure n :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # | |
type App (Literal lit :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # | |
type App (SkipUnsafe n :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # | |
Defined in Symparsec.Parser.Skip | |
type App (Take n :: FunKind PState (PReply Symbol) -> Type) (s :: PState) Source # | |
type App (TakeWhile chPred :: FunKind PState (PReply Symbol) -> Type) (s :: PState) Source # | |
type App (Empty :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |
type App (NatBase base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # | |
type App (NatBaseWhile base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # | |
Defined in Symparsec.Parser.Natural | |
type App (Try p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |
type App (Pure a2 :: FunKind PState (PReply a1) -> Type) (s :: PState) Source # | |
type App (IsolateSym p :: FunKind Natural (PParser a) -> Type) (n :: Natural) Source # | |
Defined in Symparsec.Parser.Isolate | |
type App (NatBase1 base parseDigit digit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # | |
type App (Count n p :: FunKind PState (PReply [k]) -> Type) (s :: PState) Source # | |
type App (l <|> r :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |
type App (Isolate n p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |
type App (While chPred p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |
type App (f <$> p :: FunKind PState (PReply a2) -> Type) (s :: PState) Source # | |
type App (l <*> r :: FunKind PState (PReply b) -> Type) (s :: PState) Source # | |
type App (l >>= r :: FunKind PState (PReply b) -> Type) (s :: PState) Source # | |
type App LAndSym (x :: Bool) # | |
Defined in DeFun.Bool | |
type App LOrSym (x :: Bool) # | |
Defined in DeFun.Bool | |
type App (ConstSym :: FunKind a (b ~> a) -> Type) (x :: a) # | |
type App (FoldlSym1 f :: FunKind b ([a] ~> b) -> Type) (z :: b) # | |
type App (FoldrSym1 f :: FunKind b ([a] ~> b) -> Type) (z :: b) # | |
type App (Con2 f :: FunKind a1 (a2 ~> b) -> Type) (arg :: a1) # | |
type App (FlipSym1 f :: FunKind b (a ~> c) -> Type) (x :: b) # | |
type App (Con3 f :: FunKind a1 (a2 ~> (b ~> c)) -> Type) (arg :: a1) # | |
type App (FoldlSym2 f z :: FunKind [a] b -> Type) (xs :: [a]) # | |
type App (FoldrSym2 f z :: FunKind [a] b -> Type) (xs :: [a]) # | |
type App (SequenceSym :: FunKind [[a]] [[a]] -> Type) (xss :: [[a]]) # | |
Defined in DeFun.List | |
type App (ConcatSym :: FunKind [[a]] [a] -> Type) (xss :: [[a]]) # | |
type App (ReverseSym :: FunKind [a] [a] -> Type) (xs :: [a]) # | |
Defined in DeFun.List | |
type App (AppendSym1 xs :: FunKind [a] [a] -> Type) (ys :: [a]) # | |
Defined in DeFun.List | |
type App (FilterSym1 p :: FunKind [a] [a] -> Type) (xs :: [a]) # | |
Defined in DeFun.List | |
type App (ConcatMapSym1 f :: FunKind [a] [b] -> Type) (xs :: [a]) # | |
Defined in DeFun.List | |
type App (MapSym1 f :: FunKind [a] [b] -> Type) (xs :: [a]) # | |
type App (Map2Sym2 f xs :: FunKind [b] [c] -> Type) (ys :: [b]) # | |
type App (ZipWithSym2 f xs :: FunKind [b] [c] -> Type) (ys :: [b]) # | |
Defined in DeFun.List | |
type App (AppendSym :: FunKind [a] ([a] ~> [a]) -> Type) (xs :: [a]) # | |
Defined in DeFun.List | |
type App (Map2Sym1 f :: FunKind [a] ([b] ~> [c]) -> Type) (xs :: [a]) # | |
type App (ZipWithSym1 f :: FunKind [a] ([b] ~> [c]) -> Type) (xs :: [a]) # | |
Defined in DeFun.List | |
type App (FilterSym :: FunKind (a ~> Bool) ([a] ~> [a]) -> Type) (p :: a ~> Bool) # | |
type App (JoinSym :: FunKind (a ~> (a ~> b)) (a ~> b) -> Type) (f :: a ~> (a ~> b)) # | |
type App (FoldrSym :: FunKind (a ~> (b ~> b)) (b ~> ([a] ~> b)) -> Type) (f :: a ~> (b ~> b)) # | |
type App (ConcatMapSym :: FunKind (a ~> [b]) ([a] ~> [b]) -> Type) (f :: a ~> [b]) # | |
Defined in DeFun.List type App (ConcatMapSym :: FunKind (a ~> [b]) ([a] ~> [b]) -> Type) (f :: a ~> [b]) = ConcatMapSym1 f | |
type App (MapSym :: FunKind (a ~> b) ([a] ~> [b]) -> Type) (f :: a ~> b) # | |
type App (FoldlSym :: FunKind (b ~> (a ~> b)) (b ~> ([a] ~> b)) -> Type) (f :: b ~> (a ~> b)) # | |
type App (ApSym :: FunKind (a ~> (b ~> c)) ((a ~> b) ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) # | |
type App (Map2Sym :: FunKind (a ~> (b ~> c)) ([a] ~> ([b] ~> [c])) -> Type) (f :: a ~> (b ~> c)) # | |
type App (ZipWithSym :: FunKind (a ~> (b ~> c)) ([a] ~> ([b] ~> [c])) -> Type) (f :: a ~> (b ~> c)) # | |
Defined in DeFun.List | |
type App (FlipSym :: FunKind (a ~> (b ~> c)) (b ~> (a ~> c)) -> Type) (f :: a ~> (b ~> c)) # | |
type App (CompSym :: FunKind (b ~> c) ((a ~> b) ~> (a ~> c)) -> Type) (f :: b ~> c) # | |
type App (ApSym1 f :: FunKind (a ~> b) (a ~> c) -> Type) (g :: a ~> b) # | |
type App (CompSym1 f :: FunKind (a ~> b) (a ~> c) -> Type) (g :: a ~> b) # | |
Common imports
Not used by all parsers, but common enough that we'll export them here.
(Kind) This is the kind of type-level symbols.
Instances
type family ConsSymbol (a :: Char) (b :: Symbol) :: Symbol where ... #
Extending a type-level symbol with a type-level character
Since: base-4.16.0.0
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS
constructor
Instances
PrintfArg Natural # | Since: base-4.8.0.0 | ||||
Defined in Text.Printf | |||||
Num Natural # | Note that Since: base-4.8.0.0 | ||||
Show Natural # | Since: base-4.8.0.0 | ||||
Eq Natural # | |||||
Ord Natural # | |||||
KnownNat n => HasResolution (n :: Nat) # | For example, | ||||
Defined in Data.Fixed Methods resolution :: p n -> Integer # | |||||
TestCoercion SNat # | Since: base-4.18.0.0 | ||||
Defined in GHC.Internal.TypeNats | |||||
TestEquality SNat # | Since: base-4.18.0.0 | ||||
Defined in GHC.Internal.TypeNats | |||||
Demotable SNat # | |||||
Demotable SState Source # | |||||
KnownNat n => SingI (n :: Nat) # | |||||
Defined in Singleraeh.SingI Associated Types
| |||||
Demotable sa => Demotable (SReply sa :: PReply a -> Type) Source # | |||||
Demotable sa => Demotable (SResult sa :: PResult a -> Type) Source # | |||||
type Sing # | |||||
Defined in Singleraeh.SingI | |||||
type Demote SNat # | |||||
Defined in Singleraeh.Demote | |||||
type Demote SState Source # | |||||
type Compare (a :: Natural) (b :: Natural) # | |||||
Defined in GHC.Internal.Data.Type.Ord | |||||
type App ShowNatDigitHexLowerSym (d :: Natural) # | |||||
Defined in TypeLevelShow.Natural.Digit | |||||
type App ShowNatDigitHexUpperSym (d :: Natural) # | |||||
Defined in TypeLevelShow.Natural.Digit | |||||
type App PExpr (s :: PState) Source # | |||||
Defined in Symparsec.Example.Expr | |||||
type App Eof (s :: PState) Source # | |||||
Defined in Symparsec.Parser.Eof | |||||
type App TakeRest (s :: PState) Source # | |||||
Defined in Symparsec.Parser.TakeRest | |||||
type App TakeSym (n :: Natural) Source # | |||||
Defined in Symparsec.Parser.Take | |||||
type App ParseDigitBinSym (ch :: Char) Source # | |||||
Defined in Symparsec.Parser.Natural.Digits | |||||
type App ParseDigitDecSym (ch :: Char) Source # | |||||
Defined in Symparsec.Parser.Natural.Digits | |||||
type App ParseDigitHexSym (ch :: Char) Source # | |||||
Defined in Symparsec.Parser.Natural.Digits | |||||
type App ParseDigitOctSym (ch :: Char) Source # | |||||
Defined in Symparsec.Parser.Natural.Digits | |||||
type App (Ensure n :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # | |||||
type App (Literal lit :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # | |||||
type App (SkipUnsafe n :: FunKind PState (PReply ()) -> Type) (s :: PState) Source # | |||||
Defined in Symparsec.Parser.Skip | |||||
type App (Take n :: FunKind PState (PReply Symbol) -> Type) (s :: PState) Source # | |||||
type App (TakeWhile chPred :: FunKind PState (PReply Symbol) -> Type) (s :: PState) Source # | |||||
type App (Empty :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |||||
type App (NatBase base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # | |||||
type App (NatBaseWhile base parseDigit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # | |||||
Defined in Symparsec.Parser.Natural | |||||
type App (Try p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |||||
type App (Pure a2 :: FunKind PState (PReply a1) -> Type) (s :: PState) Source # | |||||
type App (IsolateSym p :: FunKind Natural (PParser a) -> Type) (n :: Natural) Source # | |||||
Defined in Symparsec.Parser.Isolate | |||||
type App (NatBase1 base parseDigit digit :: FunKind PState (PReply Natural) -> Type) (s :: PState) Source # | |||||
type App (Count n p :: FunKind PState (PReply [k]) -> Type) (s :: PState) Source # | |||||
type App (l <|> r :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |||||
type App (Isolate n p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |||||
type App (While chPred p :: FunKind PState (PReply a) -> Type) (s :: PState) Source # | |||||
type App (f <$> p :: FunKind PState (PReply a2) -> Type) (s :: PState) Source # | |||||
type App (l <*> r :: FunKind PState (PReply b) -> Type) (s :: PState) Source # | |||||
type App (l >>= r :: FunKind PState (PReply b) -> Type) (s :: PState) Source # | |||||
type Demote (SReply sa :: PReply a -> Type) Source # | |||||
type Demote (SResult sa :: PResult a -> Type) Source # | |||||
type family (a :: Natural) + (b :: Natural) :: Natural where ... infixl 6 #
Addition of type-level naturals.
Since: base-4.7.0.0
type family (a :: Natural) - (b :: Natural) :: Natural where ... infixl 6 #
Subtraction of type-level naturals.
Since: base-4.7.0.0
type family (a :: Natural) * (b :: Natural) :: Natural where ... infixl 7 #
Multiplication of type-level naturals.
Since: base-4.7.0.0
type ShowNatDec (n :: Natural) = ShowNatBase 10 ShowNatDigitHexLowerSym n #
type ShowChar (ch :: Char) = ConsSymbol ch "" #