effectful/effectful-plugin
Andrzej Rybczak 5979e8f2da
Add HasCallStack constraints for easier debugging (#244)
* Add HasCallStack constraints for easier debugging

Bechmarks are pretty much unaffected because most of these functions are small
and GHC inlines them.

* Fix plugin
2024-09-11 00:19:29 +02:00
..
src/Effectful Add HasCallStack constraints for easier debugging (#244) 2024-09-11 00:19:29 +02:00
src-legacy/Effectful Add HasCallStack constraints for easier debugging (#244) 2024-09-11 00:19:29 +02:00
tests Improve Show instance of Effectful.Error.Static.ErrorWrapper (#232) 2024-08-26 19:48:00 +02:00
CHANGELOG.md Release 2.3.1.0, effectful-plugin-1.1.0.3 and effectful-th-1.0.0.2 (#222) 2024-06-06 23:33:07 +02:00
effectful-plugin.cabal Improve Labeled and add labeled versions of base effects (#228) 2024-08-22 20:59:21 +02:00
LICENSE Port the plugin from cleff (#66) 2022-06-29 06:41:06 +02:00
README.md Deprecate (:>>) because GHC can't efficiently handle recursive type families (#101) 2022-10-06 16:12:29 +02:00

effectful-plugin

A GHC plugin for improving disambiguation of effects.

Usage

To enable the plugin, add the following GHC option to your project file:

ghc-options: -fplugin=Effectful.Plugin

What it does

The following code:

action :: (State Int :> es, State String :> es) => Eff es ()
action = do
  x <- get
  put (x + 1)

will not compile out of the box because GHC doesn't know that you meant to get an Int since the function + as well as the literal 1 are polymorphic. You have to write:

action :: (State Int :> es, State String :> es) => Eff es ()
action = do
  x <- get @Int
  put (x + 1)

Which is slightly annoying. This plugin tells GHC extra information so code like this can type-check without having to spell types to the compiler.

Acknowledgements

Thanks to Xy Ren for her work on cleff-plugin effectful-plugin is based on.