@hackage / fused-effects-th

Template Haskell helpers for fused-effects.

Latest0.1.0.3

About

Metadata

  • Last updated , by patrick_thomson
  • License BSD-3-Clause
  • Maintained by: Patrick Thomson <patrickt@github.com>

  • Lottery factor: 0

Links

Installation

Tested Compilers

  1. 9.2.2
  2. 9.0.1
  3. 8.10.2
  4. 8.8.3
  5. 8.6.5

Readme

fused-effects-th

GitHub CI Hackage BSD-3-Clause license

This package provides Template Haskell helpers for fused-effects. The makeSmartConstructors splice, given the name of a GADT defining an effect, iterates through the possible constructors and generates functions that construct effects using send. 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 ()

calling makeSmartConstructors ''State generates the following code (cleaned up a little from the native Template Haskell output):

get ::
  forall s sig m
  Has (State s) sig m =>
  m s
get = send Get
{-# INLINEABLE get #-}
 put ::
  forall s sig m.
  Has (State s) sig m =>
  s ->
  m ()
put a = send (Put a)
{-# INLINEABLE put #-}

Bug reports are welcome on the issue tracker.