barlow-lens-0.1.0.0: lens via string literals
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Lens.Barlow.Parser

Documentation

type family FromChars1 (cs :: [Char]) (res :: Symbol) :: Symbol where ... Source #

Equations

FromChars1 '[] res = res 
FromChars1 (c ': cs) res = FromChars1 cs (ConsSymbol c res) 

type family FromCharsReverse (cs :: [Char]) :: Symbol where ... Source #

Equations

FromCharsReverse cs = FromChars1 cs "" 

type family FromChars (cs :: [Char]) :: Symbol where ... Source #

Equations

FromChars cs = FromChars1 (Eval (Reverse cs)) "" 

type family ToChars1 (s :: Maybe (Char, Symbol)) (r :: [Char]) :: [Char] where ... Source #

Equations

ToChars1 Nothing s = Eval (Reverse s) 
ToChars1 ('Just '(c, cs)) s = ToChars1 (UnconsSymbol cs) (c ': s) 

type family ToChars (s :: Symbol) :: [Char] where ... Source #

Equations

ToChars s = ToChars1 (UnconsSymbol s) '[] 

type family FromChar (c :: Char) :: Symbol where ... Source #

Equations

FromChar c = FromChars '[c] 

type family AppendChar (s :: Symbol) (c :: Char) :: Symbol where ... Source #

Equations

AppendChar s c = AppendSymbol s (FromChar c) 

type family CharBetween1 (c1 :: Ordering) (c2 :: Ordering) :: Bool where ... Source #

type family CharBetween (c :: Char) (lowerBound :: Char) (upperBound :: Char) :: Bool where ... Source #

Equations

CharBetween c lowerBound upperBound = CharBetween1 (CmpChar lowerBound c) (CmpChar c upperBound) 

type SpecialChars = '['.', '?', '>', '<', '+', '!', '%'] Source #

type family UnexpectedCharacterError (c :: Char) (expected :: Symbol) (prefix :: [Char]) (rest :: [Char]) :: k where ... Source #

Equations

UnexpectedCharacterError c expected prefix rest = TypeError (((((Text "Unexpected character: " :<>: Text (FromChar c)) :<>: Text "\n") :<>: (Text expected :<>: Text "\n")) :<>: ((Text "in " :<>: Text (FromCharsReverse prefix)) :<>: Text "\n")) :<>: (Text "in " :<>: Text (AppendSymbol (FromCharsReverse prefix) (FromChars rest)))) 

type family Parse1 (parsed :: [Char]) (rest :: [Char]) (tags :: [Tag]) :: [Tag] where ... Source #

Equations

Parse1 p '[] ts = ts 
Parse1 p ('.' ': xs) ts = Parse1 ('.' ': p) xs (Tag'Dot ': ts) 
Parse1 p ('?' ': xs) ts = Parse1 ('?' ': p) xs (Tag'QuestionMark ': ts) 
Parse1 p ('>' ': xs) ts = Parse1 ('>' ': p) xs (Tag'RightArrow ': ts) 
Parse1 p ('<' ': xs) ts = Parse1 ('<' ': p) xs (Tag'LeftArrow ': ts) 
Parse1 p ('+' ': xs) ts = Parse1 ('+' ': p) xs (Tag'Plus ': ts) 
Parse1 p ('!' ': xs) ts = Parse1 ('!' ': p) xs (Tag'ExclamationMark ': ts) 
Parse1 p ('%' ': (x ': xs)) ts = If (CharBetween x '1' '9') (Parse1 (x ': ('%' ': p)) xs (Tag'PercentageNumber (DigitNat x) ': ts)) (If (IsSpecial x) (UnexpectedCharacterError x "Expected a letter or a digit\nafter '%'" p (x ': xs)) (Parse1 (x ': ('%' ': p)) xs (Tag'PercentageName (ConsSymbol x "") ': ts))) 
Parse1 p (x ': xs) (Tag'PercentageName s ': ts) = Parse1 (x ': p) xs (Tag'PercentageName (AppendChar s x) ': ts) 
Parse1 p (x ': xs) (Tag'PercentageNumber n ': ts) = If (CharBetween x '0' '9') (Parse1 (x ': p) xs (Tag'PercentageNumber ((n * 10) + DigitNat x) ': ts)) (UnexpectedCharacterError x "Expected a digit or a special character\nafter a digit" p (x ': xs)) 
Parse1 p (x ': xs) (Tag'Name n ': ts) = Parse1 (x ': p) xs (Tag'Name (AppendChar n x) ': ts) 
Parse1 p (x ': xs) ts = If (Eval (Or '[CharBetween x '0' '9'])) (UnexpectedCharacterError x "Expected a letter" p (x ': xs)) (Parse1 (x ': p) xs (Tag'Name (FromChar x) ': ts)) 
Parse1 _ _ _ = TypeError (Text "cornercase!") 

data DotFilter :: Tag -> Exp Bool Source #

Instances

Instances details
type Eval (DotFilter x :: Bool -> Type) Source # 
Instance details

Defined in Data.Lens.Barlow.Parser

type Eval (DotFilter x :: Bool -> Type) = If (Eval (TyEq x 'Tag'Dot)) 'False 'True

type family Parse (a :: Symbol) :: [Tag] where ... Source #

Equations

Parse a = Eval (Filter DotFilter (Eval (Reverse (Parse1 '[] (ToChars a) '[]))))