Imagine you have a typeclass for monads in which you can call evaluate:
class Monad m => MonadEvaluate m where
evaluate :: a -> m a
Essentially only IO
(and stacks based on IO
) have a proper instance, however Identity
instance with evaluate = pure
may be useful for pure tests. However, this instance shouldn’t be used in production, as it’s not evaluating anything.
Is there a way to emit a GHC warning each time GHC uses/produces a dictionary MonadEvaluate Identity
? I’d like to have something like
instance
{-# WARNING "Instance MonadEvaluate Identity should only be used in tests" #-}
MonadEvaluate Identity where
evaluate = pure
however it’s not working. Can I achieve such a behaviour in some other way?