Safe Haskell | None |
---|---|
Language | GHC2021 |
Effectful.Dynamic.Utils
Description
Since: 0.1
Synopsis
- class ShowEffect (p :: (Type -> Type) -> Type -> Type) where
- showEffectCons :: forall (m :: Type -> Type) a. p m a -> String
Documentation
class ShowEffect (p :: (Type -> Type) -> Type -> Type) where Source #
Class for "showing" a dynamic effect. This class is intended for debugging or error handling.
Methods
showEffectCons :: forall (m :: Type -> Type) a. p m a -> String Source #
Shows an effect constructor. Useful for stubbing mock effects e.g.
runEffect = interpret_ $ case Cons1 x -> ... Cons2 x y -> ... other -> error $ (showEffectCons other) ++ ": unimplemented"
We may not want to provide an implementation for all members of a mock effect e.g. because we want to verify a specific member is _not_ used, or implementing everything is unnecessarily cumbersome.
Erroring out is a reasonable choice, though it can lead to cryptic errors if such a member _is_ (unexpectedly) used and subsequently fails. Thus this show instance can be used to provide a better error message.