4

Reading this question and this thread on Reddit inspired me to ask:

Why don't people in the Haskell community seem to be missing Scala's Cake Pattern? Why is the lack (or cumbersomeness) of a Cake Pattern in Haskell not a such a big issue?

The Cake Pattern is meant to help with large (scalable) systems/programs. Is it possible that systems created with Scala tend to be much larger than systems created with Haskell? This in turn might explain why the Cake Pattern is so important in the Scala world and its lack is not such a big issue in the Haskell world?

Community
  • 1
  • 1
jhegedus
  • 20,244
  • 16
  • 99
  • 167
  • 4
    Just a few guesses: it models Objects (i.e. OO objects) and Haskell does not have Objects. Probably most Haskellers would balk at the thought of trying to hack Objects into their Haskell code... Haskell and Scala have vastly different type systems, I wouldn't expect design patterns applicable to Scala to be applicable to Haskell in general. Furthermore, Scala has much better support for runtime reflection, so combining the Cake pattern and reflection gets you the power of the model for no syntactic inconvenience. In Haskell you won't even get a first class object out of it. – user2407038 Mar 22 '16 at 18:57
  • 4
    Perhaps the Cake Pattern isn't as valuable to those with access to a good [reader monad](http://blog.originate.com/blog/2013/10/21/reader-monad-for-dependency-injection/). – jwvh Mar 22 '16 at 18:58
  • 12
    maybe you should first add what a *cake pattern* is - tbh: this is the first time I heard of it and I am to lazy to search for it myself ^^ – Random Dev Mar 22 '16 at 19:05
  • 5
    Is it an exaggeration to say that Haskell programmers in general don't care very much about so-called "patterns"? – Ingo Mar 22 '16 at 19:45
  • 2
    The Cake Pattern is _but one way_ in Scala to compose big modules out of smaller modules. There are lots of others; the Cake Pattern is not the most popular or even necessarily the best (it's not simple, for sure). In Haskell we compose big things out of smaller things _all the time_, and the language also gives us lots of tools with which to do it. To solve the particular problem that the Cake Pattern is used for, the most commonly-used tool is probably monad transformers. – Benjamin Hodgson Mar 22 '16 at 19:55
  • @Carsten the first link explains it http://stackoverflow.com/questions/12947176/can-scalas-cake-pattern-be-implemented-in-haskell – jhegedus Mar 22 '16 at 20:21
  • 1
    @jhegedus: Maybe it would help if you could describe the kind of problems that the cake pattern solves, instead of explaining the pattern itself. Then we could show how these problems are a) solved or b) not existent in Haskell. – Bergi Mar 22 '16 at 20:41
  • I added a link to a talk that explains the Cake Pattern and why it is a good idea. @Carsten – jhegedus Mar 22 '16 at 20:41
  • @Bergi the link I added explains the purpose of Cake Pattern very well. – jhegedus Mar 22 '16 at 20:42
  • 8
    the cake pattern is a lie – sclv Mar 22 '16 at 20:43
  • @sclv what do u mean ? – jhegedus Mar 22 '16 at 20:52
  • this https://twitter.com/miguelinlas3/status/547660890821361664 – jhegedus Mar 22 '16 at 20:57
  • @jhegedus I doubt very many people are going to watch a 40 minute video to understand some of the context of this question to decide if they want to answer it. I don't necessarily agree that this question ought to be closed as too broad, but if the cake pattern is so complicated that the core ideas can't be summarised in the question then it probably can't be well answered in this format either. – Ben Mar 23 '16 at 22:53
  • @Ben this question targets people who know already _both_ Scala and Haskell. The purpose of the question is not to teach Scala. The cake pattern is explained in detail in Odersky's Scala (intro) book, as well, but I think this video really well summarises why the cake pattern was invented/discovered and what problems ( i.e. Dependency injection) it tries to solve and how (the how part needs understanding of Scala). – jhegedus Mar 24 '16 at 06:22

0 Answers0