| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Haskell.TH.Natural.Syntax.Signature
Description
Synopsis
- newSignature :: forall (step :: BuilderStep). SignatureBuilder step 'Ready () -> Q ForallT
- type SignatureBuilder (prev :: k) (next :: k) a = Builder SignatureState prev next a
- data SignatureState = MkSBS {
- _tyVarBndr :: [TyVarBndr Specificity]
- _constraints :: [Type]
- _params :: [Type]
- _result :: Maybe Type
- addToForall :: forall {k} (step :: k). TypeVarName -> SignatureBuilder step step ()
- addConstraint :: forall {k} a (step :: k). GenType a => a -> SignatureBuilder step step ()
- addParam :: forall {k} a (step :: k). GenType a => a -> SignatureBuilder step step ()
- setResultType :: forall a (step :: BuilderStep). GenType a => a -> SignatureBuilder step 'Ready ()
- tyVarBndr :: Lens' SignatureState [TyVarBndr Specificity]
- constraints :: Lens' SignatureState [Type]
- params :: Lens' SignatureState [Type]
- result :: Lens' SignatureState (Maybe Type)
- newTypeVar :: forall {k} st (step :: k). String -> Builder st step step TypeVarName
- module Language.Haskell.TH.Natural.Syntax.Builder.Monad
Builder
newSignature :: forall (step :: BuilderStep). SignatureBuilder step 'Ready () -> Q ForallT Source #
Builds a type signature
type SignatureBuilder (prev :: k) (next :: k) a = Builder SignatureState prev next a Source #
State
data SignatureState Source #
Constructors
| MkSBS | |
Fields
| |
Instances
| GenType (SignatureBuilder step 'Ready ()) Source # | |
Defined in Language.Haskell.TH.Natural.Syntax.Signature | |
Functions
addToForall :: forall {k} (step :: k). TypeVarName -> SignatureBuilder step step () Source #
Adds the given type variable to the _forall_ list.
Using this function should comply with the 'forall-or-nothing' rule (https:/ghc.gitlab.haskell.orgghcdocusers_guideextsexplicit_forall.html#the-forall-or-nothing-rule)
addConstraint :: forall {k} a (step :: k). GenType a => a -> SignatureBuilder step step () Source #
Add the given type to the set of constraints
addParam :: forall {k} a (step :: k). GenType a => a -> SignatureBuilder step step () Source #
Set the type as the nth parameter of the function's signature
(n being the number of time addParam was called)
setResultType :: forall a (step :: BuilderStep). GenType a => a -> SignatureBuilder step 'Ready () Source #
Set the result type in the function's signature
Lenses
Re-export
newTypeVar :: forall {k} st (step :: k). String -> Builder st step step TypeVarName Source #
Builds a new type variable