emilaxelsson / syntactic

Generic representation and manipulation of abstract syntax
BSD 3-Clause "New" or "Revised" License
25 stars 13 forks source link

Codensity monad #29

Closed Icelandjack closed 8 years ago

Icelandjack commented 8 years ago

The paper Combining Deep and Shallow Embedding of Domain-Specific Languages says about this “Readers with prior knowledge about monads will recognize that Mon is similar to the continuation passing monad. The difference is that the answer type has been specialized to generate syntax trees.”

data Mon m a = M { unM :: forall b. ((a → FunC (m b)) → FunC (m b)) }

This is actually the Codensity monad.

type Codensity m a = forall b. (a -> m b) -> m b
emilaxelsson commented 8 years ago

Yes, thanks, we're aware of this. Should probably have commented on that in the journal version of the paper.

I'll add a comment in the source code.