| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Haskell.TH.Natural.Syntax.Builder.Internal
Synopsis
- newtype BaseBuilder (m :: Type -> Type) s (prev :: k) (next :: k) a = MkB {}
- data BuilderStep
- type Builder = BaseBuilder Q :: Type -> k -> k -> Type -> Type
- type ConstBuilder s = BaseBuilder Q s 'Ready 'Ready
- runBaseBuilder :: forall {k} m s (step :: k) (end :: k). Monad m => BaseBuilder m s step end () -> s -> m s
- runBaseBuilder' :: forall {k} m s (step :: k) (end :: k) a. BaseBuilder m s step end a -> s -> m (a, s)
- liftB :: forall {k} m a s (step :: k). Monad m => m a -> BaseBuilder m s step step a
- impure :: forall {k} (m :: Type -> Type) s (step :: k) a (next :: k). BaseBuilder m s step step a -> BaseBuilder m s step next a
- unsafeWithState :: forall {k} s (m :: Type -> Type) a (prev :: k) (curr :: k). StateT s m a -> BaseBuilder m s prev curr a
- unsafeCastStep :: forall {k1} {k2} (prev' :: k1) (curr' :: k1) (prev :: k2) (curr :: k2) (m :: Type -> Type) s a. BaseBuilder m s prev curr a -> BaseBuilder m s prev' curr' a
Documentation
newtype BaseBuilder (m :: Type -> Type) s (prev :: k) (next :: k) a Source #
A computation that builds an object, the state
A graded state monad
Instances
data BuilderStep Source #
Typically used a kinds to represent the progress of a Builder computation
Constructors
| Empty | When the builder is not _ready_ to produce a valid AST (i.e. one of the fields is "empty") |
| Ready | The builder is ready to produce the AST |
Instances
| Show BuilderStep Source # | |
Defined in Language.Haskell.TH.Natural.Syntax.Builder.Internal Methods showsPrec :: Int -> BuilderStep -> ShowS # show :: BuilderStep -> String # showList :: [BuilderStep] -> ShowS # | |
| Eq BuilderStep Source # | |
| ConPatternBuilder PatternBuilder Source # | |
Defined in Language.Haskell.TH.Natural.Syntax.Case Methods setFieldPattern :: Int -> Pat -> PatternBuilder () Source # | |
| GenType (SignatureBuilder step 'Ready ()) Source # | |
Defined in Language.Haskell.TH.Natural.Syntax.Signature | |
| (IsExprBuilder st, GenExpr (Definition st)) => GenExpr (Builder st step 'Ready ()) Source # | |
type Builder = BaseBuilder Q :: Type -> k -> k -> Type -> Type Source #
Common type for anything that builds a TH AST.
type ConstBuilder s = BaseBuilder Q s 'Ready 'Ready Source #
runBaseBuilder :: forall {k} m s (step :: k) (end :: k). Monad m => BaseBuilder m s step end () -> s -> m s Source #
Runs the BaseBuilder and returns the state
runBaseBuilder' :: forall {k} m s (step :: k) (end :: k) a. BaseBuilder m s step end a -> s -> m (a, s) Source #
Similar to runBaseBuilder, but also returns the value output by the computation
liftB :: forall {k} m a s (step :: k). Monad m => m a -> BaseBuilder m s step step a Source #
Lift a monadic computation in a builder
impure :: forall {k} (m :: Type -> Type) s (step :: k) a (next :: k). BaseBuilder m s step step a -> BaseBuilder m s step next a Source #
A safe way to cast the current step of the BaseBuilder when a computation is pure and does not explicitly changes the state of the BaseBuilder
unsafeWithState :: forall {k} s (m :: Type -> Type) a (prev :: k) (curr :: k). StateT s m a -> BaseBuilder m s prev curr a Source #
Allows accessing and modifying the state.
Using this to modify the state breaks the security provided by the type-level tracking of state.
unsafeCastStep :: forall {k1} {k2} (prev' :: k1) (curr' :: k1) (prev :: k2) (curr :: k2) (m :: Type -> Type) s a. BaseBuilder m s prev curr a -> BaseBuilder m s prev' curr' a Source #
Unsafely changes the state of the computation. Breaks the security provided by the type-level tracking of state.