16

The extensible effects library and the layers library appear to have the same goals (making it easy to compose different effects together). Both talk about the advantages they offer over mtl, but neither makes reference to the other. Can both accomplish the same thing? Does one subsume the other? Does each have some feature that the other lacks?

0

2 Answers 2

10

While I'm in no way experienced with any of those, it's quite straighforward from the articles.

While layers are rather building upon MTL, exteff is a wholly different approach. exteff defines one monad that contains information about its effects in its type. exteff claims to solve the problem of monad ordering, i.e. if monads A and B are interchangable, the classic approach would make A (B a) and B (A a) different types. In exteff they're the same.

From the interface of layers it seems that it didn't solve that problem.

1
  • The github page of extensible-effects provides describes some problems with the package, from which only one applies to GHC > 7.8, namely: Common functions can't be grouped using typeclasses, e.g. the ask and getState functions can't be grouped with some [...] (github.com/suhailshergill/extensible-effects). Could you tell more about how it applies to layers package? I think we all would be interested in seeing the problem from different "angles". cc: @ibotty Feb 22, 2015 at 16:33
3

adding to polkovnikov's answer, extensible-effects are initially encoded effects and the effects in layers (and mtl) are final encoded. both approaches have advantages and disadvantages, and perform better or worse in some scenarios.

3
  • 4
    Can you be more concrete? In what specific scenarios does one or other approach perform better or worse?
    – lmm
    Sep 23, 2014 at 13:29
  • i will come back to that answer when i update the benchmark to also test the cases where free monads work better.
    – ibotty
    Oct 7, 2014 at 6:50
  • 2
    i guess i won't have time for a long while. the gist is, that with mtl/layers (or more accurately: transformers) you pay whenever you add a new transformer. lifting through t (t1 (t2 (t3 m))) is pretty expensive and not neccessary with a free monad-like approach as extensible-effects is using. but: with just one transformer it is way faster than extensible effects. that's what you can see in the benchmark i linked.
    – ibotty
    Oct 7, 2014 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.