Search code examples
haskellmodulecake-pattern

Can Scala's Cake Pattern be implemented in Haskell?


Using a number of newer language features in Scala it's possible to implement a composable component system and create components using the so called Cake Pattern, described by Martin Odersky in the paper Scalable Component Abstractions and also in a recent talk.

Several of the Scala features used in the Cake Pattern have corresponding Haskell features. For example, Scala implicits correspond to Haskell type classes and Scala's abstract type members seem to correspond to Haskell's associated types. This makes me wonder if the Cake Pattern could be implemented in Haskell and what it would look like.

Can the Cake Pattern be implemented in Haskell? Which Haskell features do the Scala features correspond to in such an implementation? If the Cake Pattern can't be implemented in Haskell, which language features are missing to make that possible?


Solution

  • Oleg provided a very detailed answer here: http://okmij.org/ftp/Haskell/ScalaCake.hs