fused-effects-th-0.1.0.2: Template Haskell helpers for fused-effects.
Safe HaskellNone
LanguageHaskell2010

Control.Effect.TH

Description

Defines splices that cut down on boilerplate associated with declaring new effects.

Synopsis

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.