Safe Haskell | None |
---|---|
Language | Haskell2010 |
Defines splices that cut down on boilerplate associated with declaring new effects.
Synopsis
- makeSmartConstructors :: Name -> DecsQ
Documentation
makeSmartConstructors :: Name -> DecsQ Source #
Given an effect type, this splice generates functions that create per-constructor request functions.
That is to say, given the standard State
type
data State s m k where Get :: State s m s Put :: s -> State s m ()
an invocation of makeSmartConstructors ''State
will generate code that looks like
get :: forall (s :: Type) sig (m :: Type -> Type). Has (State s) sig m => m s get = send Get {-# INLINEABLE get #-} put :: forall (s :: Type) sig (m :: Type -> Type). Has (State s) sig m => s -> m () put a = send (Put a) {-# INLINEABLE put #-}
The type variables in each declared function signature will appear in the order they were defined in the effect type.