in-other-words-plugin: Disambiguate obvious uses of effects when using in-other-words.

[ bsd3, control-language, library ] [ Propose Tags ]
Versions [RSS]
Change log
Dependencies base (>=4.9 && <5), containers (>=0.5 && <0.7), ghc (>=8.4.4 && <9), ghc-tcplugins-extra (>=0.3 && <0.5), in-other-words (>=0.1 && <0.3), syb (>=0.7 && <0.8), transformers (>= && <0.6) [details]
License BSD-3-Clause
Copyright 2021 Love Waern
Author Love Waern
Category Control Language
Home page
Bug tracker
Source repo head: git clone
Uploaded by KingoftheHomeless at 2021-01-30T18:28:23Z
Distributions NixOS:
Downloads 140 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-01-30 [all 1 reports]

Readme for in-other-words-plugin-

[back to package description]


build GHC 8.6 build GHC 8.8 build GHC 8.10


A typechecker plugin that can disambiguate "obvious" uses of effects when using in-other-words.


Consider the following program:

foo :: Eff (State Int) m => m ()
foo = put 10

What does this program do? Any human will tell you that it changes the state of the Int to 10, which is clearly what's meant.

Unfortunately, in-other-words can't work this out on its own. Its reasoning is "maybe you wanted to change some other State effect which is also a Num, but you just forgot to add some Eff/s constraints for it."

This is obviously insane, but it's the way the cookie crumbles. in-other-words-plugin is a typechecker plugin which will disambiguate the above program (and others) so the compiler will do what you want.


Add the following line to your package configuration:

ghc-options: -fplugin=Control.Effect.Plugin


in-other-words-plugin will only disambiguate effects if there is exactly one relevant constraint in scope. For example, it will not disambiguate the following program:

bar :: Effs '[ State Int
             , State Double
             ] m
    => m ()
bar = put 10

because it is now unclear whether you're attempting to set the Int or the Double. Instead, you can manually write a type application in this case.

bar :: Effs '[ State Int
             , State Double
             ] m
    => m ()
bar = put @Int 10


This plugin and this README is copied almost verbatim from polysemy-plugin, which itself is copied almost verbatim from simple-effects.