20

What is the difference between these three monad transformers?

3
  • You should probably link to the docs for the types you're referring to and make your question more specific. Commented Jan 2, 2013 at 16:24
  • Please be more specific -- do you mean just the MonadTrans instance for these types, or their behavior in general? Commented Jan 2, 2013 at 16:25
  • @Don Stewart: in general. Commented Jan 2, 2013 at 16:56

1 Answer 1

26

Well, first of all ListT is not a true monad transformer. It disobeys the associativity law for certain underlying monads. It is also pretty slow, as is the monadic interface to lists in general. It is built on actual lists internally.

LogicT is probably the best choice for list-like monad transformers. It not only implements a proper monad transformer, but also some very useful combinators for fair list products.

ChoiceT is my own work. It is basically just a CPSed version of LogicT and is inspired by both LogicT and the ChoiceT from monadLib. It's very fast, often outperforming (non-transformed) lists, but the types may be scary and you are bound to the result type, which may be in your way sometimes.

Conclusion: If you're serious, use LogicT.

Sign up to request clarification or add additional context in comments.

3 Comments

Am I right in assuming that runLogicT and runChoiceT are folds?
@Tinctorius: Both LogicT and ChoiceT encode lists as folds of some sort anyway, and as usual the "run" functions just unwrap that. Folds are already similar to a CPS'd list, and ChoiceT adds an extra layer of proper CPS on top of that, which is why it has a type signature only a mother could love. ;]
Would you mind describing this "proper CPS" in a little more detail or giving a reference? I originally thought that logictt was already basically a cpd's version of ListT done right

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.