Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type T ctx = GrammarM ctx
- class HasField (x :: k) r a | x r -> a where
- getField :: r -> a
- class (KnownSymbol v, HasField v rules (RuleExprType rules (RuleExprReturnType rules v))) => HasRuleExprField rules (v :: Symbol) where
- type RuleExprReturnType rules (v :: Symbol)
- nonTerminalName :: rules -> proxy v -> String
- type family TokensTag tokens :: [Symbol]
- type family RulesTag rules :: [Symbol]
- type family RuleExprType rules :: Type -> Type
- type GrammarM ctx = Grammar (SemActM ctx)
- class MemberInitials rules (initials :: [Symbol]) where
- memberInitials :: T (DictF (HasRuleExprField rules)) initials
- class Rules rules where
- generateRules :: T (DictF (HasRuleExprField rules)) (RulesTag rules)
- class GrammarToken tokens elem where
- tokenToTerminal :: Proxy tokens -> elem -> T (TokensTag tokens)
- type RuleExprM ctx = RuleExpr (SemActM ctx)
- type AltM ctx = Alt (SemActM ctx)
- data Expr rules tokens elem (us :: [Type])
- newtype SemActM ctx us a = UnsafeSemActM {}
- semActM :: (HTExpList us -> Q (TExp (ActionTask ctx a))) -> T f us -> SemActM ctx us a
- data HFList (a :: k -> Type) (b :: [k]) where
- data DictF (a :: k -> Constraint) (b :: k) where
- DictF :: forall k (a :: k -> Constraint) (b :: k). a b => DictF a b
- type HTExpList = T TExpQ
- pattern HNil :: HTExpList '[]
- pattern (:*) :: Q (TExp u) -> HTExpList us -> HTExpList (u ': us)
- newtype TExpQ a = TExpQ {}
- newtype ActionTask ctx a = ActionTask {
- runActionTask :: ctx -> ActionTaskResult ctx a
- data ActionTaskResult ctx a
- = ActionTaskFail
- | ActionTaskResult a
- | ActionTaskModifyResult ctx a
- getAction :: ActionTask ctx ctx
- modifyAction :: (ctx -> ctx) -> ActionTask ctx ()
- failAction :: ActionTask ctx a
- type Grammar = GrammarM ()
- type RuleExpr = RuleExprM ()
- type Alt = AltM ()
- type SemAct = SemActM ()
- semAct :: (HTExpList us -> Q (TExp a)) -> T f us -> SemActM ctx us a
- fixGrammar :: forall (initials :: [Symbol]) (action :: [Type] -> Type -> Type) rules tokens elem. (MemberInitials rules initials, Rules rules, RuleExprType rules ~ RuleExpr action rules tokens elem) => rules -> Grammar action rules tokens elem initials
- ruleExpr :: forall (action :: [Type] -> Type -> Type) rules tokens elem a. [Alt action rules tokens elem a] -> RuleExpr action rules tokens elem a
- (<^>) :: forall rules tokens elem (us1 :: [Type]) (us2 :: [Type]). Expr rules tokens elem us1 -> Expr rules tokens elem us2 -> Expr rules tokens elem (Concat us1 us2)
- (<:>) :: Expr rules tokens elem us -> (HTExpList us -> Q (TExp a)) -> AltM ctx rules tokens elem a
- eps :: (HTExpList '[] -> Q (TExp a)) -> AltM ctx rules tokens elem a
- (<::>) :: Expr rules tokens elem us -> (HTExpList us -> Q (TExp (ActionTask ctx a))) -> AltM ctx rules tokens elem a
- epsM :: (HTExpList '[] -> Q (TExp (ActionTask ctx a))) -> AltM ctx rules tokens elem a
- var :: forall (v :: Symbol) proxy rules tokens elem. KnownSymbol v => proxy v -> Expr rules tokens elem '[RuleExprReturnType rules v]
- varA :: forall (v :: Symbol) rules tokens elem. KnownSymbol v => Expr rules tokens elem '[RuleExprReturnType rules v]
- tok :: forall tokens (t :: Symbol) rules elem. Membership (TokensTag tokens) t -> Expr rules tokens elem '[elem]
- class TokensMember tokens (t :: Symbol) where
- tokensMembership :: Proxy# '(tokens, t) -> Membership (TokensTag tokens) t
- tokA :: forall (t :: Symbol) rules tokens elem. TokensMember tokens t => Expr rules tokens elem '[elem]
Documentation
class HasField (x :: k) r a | x r -> a where #
Constraint representing the fact that the field x
belongs to
the record type r
and has field type a
. This will be solved
automatically, but manual instances may be provided as well.
class (KnownSymbol v, HasField v rules (RuleExprType rules (RuleExprReturnType rules v))) => HasRuleExprField rules (v :: Symbol) where #
Nothing
type RuleExprReturnType rules (v :: Symbol) #
nonTerminalName :: rules -> proxy v -> String #
type family RuleExprType rules :: Type -> Type #
class MemberInitials rules (initials :: [Symbol]) where #
memberInitials :: T (DictF (HasRuleExprField rules)) initials #
generateRules :: T (DictF (HasRuleExprField rules)) (RulesTag rules) #
class GrammarToken tokens elem where #
tokenToTerminal :: Proxy tokens -> elem -> T (TokensTag tokens) #
data DictF (a :: k -> Constraint) (b :: k) where #
DictF :: forall k (a :: k -> Constraint) (b :: k). a b => DictF a b |
newtype ActionTask ctx a #
ActionTask | |
|
Instances
Monad (ActionTask ctx) | |
Defined in Language.Parser.Ptera.Syntax (>>=) :: ActionTask ctx a -> (a -> ActionTask ctx b) -> ActionTask ctx b # (>>) :: ActionTask ctx a -> ActionTask ctx b -> ActionTask ctx b # return :: a -> ActionTask ctx a # | |
Functor (ActionTask ctx) | |
Defined in Language.Parser.Ptera.Syntax fmap :: (a -> b) -> ActionTask ctx a -> ActionTask ctx b # (<$) :: a -> ActionTask ctx b -> ActionTask ctx a # | |
Applicative (ActionTask ctx) | |
Defined in Language.Parser.Ptera.Syntax pure :: a -> ActionTask ctx a # (<*>) :: ActionTask ctx (a -> b) -> ActionTask ctx a -> ActionTask ctx b # liftA2 :: (a -> b -> c) -> ActionTask ctx a -> ActionTask ctx b -> ActionTask ctx c # (*>) :: ActionTask ctx a -> ActionTask ctx b -> ActionTask ctx b # (<*) :: ActionTask ctx a -> ActionTask ctx b -> ActionTask ctx a # |
data ActionTaskResult ctx a #
Instances
Functor (ActionTaskResult ctx) | |
Defined in Language.Parser.Ptera.Syntax fmap :: (a -> b) -> ActionTaskResult ctx a -> ActionTaskResult ctx b # (<$) :: a -> ActionTaskResult ctx b -> ActionTaskResult ctx a # | |
(Eq a, Eq ctx) => Eq (ActionTaskResult ctx a) | |
Defined in Language.Parser.Ptera.Syntax (==) :: ActionTaskResult ctx a -> ActionTaskResult ctx a -> Bool # (/=) :: ActionTaskResult ctx a -> ActionTaskResult ctx a -> Bool # | |
(Show a, Show ctx) => Show (ActionTaskResult ctx a) | |
Defined in Language.Parser.Ptera.Syntax showsPrec :: Int -> ActionTaskResult ctx a -> ShowS # show :: ActionTaskResult ctx a -> String # showList :: [ActionTaskResult ctx a] -> ShowS # |
getAction :: ActionTask ctx ctx #
modifyAction :: (ctx -> ctx) -> ActionTask ctx () #
failAction :: ActionTask ctx a #
fixGrammar :: forall (initials :: [Symbol]) (action :: [Type] -> Type -> Type) rules tokens elem. (MemberInitials rules initials, Rules rules, RuleExprType rules ~ RuleExpr action rules tokens elem) => rules -> Grammar action rules tokens elem initials #
ruleExpr :: forall (action :: [Type] -> Type -> Type) rules tokens elem a. [Alt action rules tokens elem a] -> RuleExpr action rules tokens elem a #
(<^>) :: forall rules tokens elem (us1 :: [Type]) (us2 :: [Type]). Expr rules tokens elem us1 -> Expr rules tokens elem us2 -> Expr rules tokens elem (Concat us1 us2) infixr 5 #
(<:>) :: Expr rules tokens elem us -> (HTExpList us -> Q (TExp a)) -> AltM ctx rules tokens elem a infixl 4 Source #
(<::>) :: Expr rules tokens elem us -> (HTExpList us -> Q (TExp (ActionTask ctx a))) -> AltM ctx rules tokens elem a infixl 4 Source #
var :: forall (v :: Symbol) proxy rules tokens elem. KnownSymbol v => proxy v -> Expr rules tokens elem '[RuleExprReturnType rules v] #
varA :: forall (v :: Symbol) rules tokens elem. KnownSymbol v => Expr rules tokens elem '[RuleExprReturnType rules v] #
tok :: forall tokens (t :: Symbol) rules elem. Membership (TokensTag tokens) t -> Expr rules tokens elem '[elem] #
class TokensMember tokens (t :: Symbol) where #
tokensMembership :: Proxy# '(tokens, t) -> Membership (TokensTag tokens) t #
tokA :: forall (t :: Symbol) rules tokens elem. TokensMember tokens t => Expr rules tokens elem '[elem] #