5

We've seen the Free Monad, The Reader Monad and the IO Monad in Clojure.

We've seen the Eff Monad - which is a better Monad transformer in Haskell.

We've also seen Monad Transformers, and the free Monad transformer in Clojure.

Daniel Spiewak has sought to improve on the Eff Monad, with the Emm Monad in Scala. It looks like this:

def readName: Task[String] = ???
def log(msg: String): Task[Unit] = ???

type E = Task |: Option |: Base

val effect: Emm[E, String] = for {
  first <- readName.liftM[E]
  last <- readName.liftM[E]

  name <- (if ((first.length * last.length) < 20) Some(s"$first $last") else None).liftM[E]

  _ <- log(s"successfully read in $name").liftM[E]
} yield name

My question is: Is it possible to do the Eff Monad in Clojure?

Community
  • 1
  • 1
hawkeye
  • 34,745
  • 30
  • 150
  • 304
  • < joke > does the EFF monad protect your other monads online rights? < /joke > I'm assuming you want an answer beyond them both being touring complete languages and therefore the same actions are possible on both languages? Mind if I change the title to "How to write the Emm monad in Clojure?" – Arthur Ulfeldt Dec 23 '15 at 23:12
  • Thanks Arthur - if you think that would be helpful. I would argue that it is unnecessary because the other times monad in clojure questions have been asked it was in this format - so changing the title should be unnecessary and would make it inconsistent, but I'll defer to your judgement. The question about whether it is possible has to do with the nature of types in different languages. Please change away if you think it best. – hawkeye Dec 24 '15 at 00:42

0 Answers0