mirror of
https://github.com/haskell-effectful/effectful.git
synced 2024-11-23 06:22:28 +03:00
0c66324baf
It's really saddening since (:>>) is a great QoL feature, but if people use it in a lot of type signatures in a non-trivial codebase, it'll start taking forever to compile their code and they'll think it's the fault of the library. This was already encountered in the context of effect libraries: https://github.com/joshvera/effects/issues/49 Relevant GHC issue: https://gitlab.haskell.org/ghc/ghc/-/issues/19238
961 B
961 B
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.