Scala的Cake模式可以在Haskell中实现吗? [英] Can Scala's Cake Pattern be implemented in Haskell?

查看:166
本文介绍了Scala的Cake模式可以在Haskell中实现吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Scala中使用许多更新的语言特性,可以实现一个可组合的组件系统,并使用所谓的Cake模式创建组件,Martin Odersky在文章可伸缩组件抽象 recent talk

Cake模式中使用的几个Scala特性有相应的Haskell功能。例如,Scala蕴涵对应于Haskell类型类,而Scala的抽象类型成员似乎对应于Haskell的关联类型。这让我想知道Cake Pattern是否可以在Haskell中实现以及它看起来是什么样的。

Cake可以在Haskell中实现吗?在这样的实现中,哪些Haskell功能对应于Scala功能?如果Cake模式不能在Haskell中实现,那么缺少哪些语言功能可以实现这一点?

解决方案

Oleg提供了一个非常详细的答案在这里: http://okmij.org/ftp/Haskell/ScalaCake.hs


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?

解决方案

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

这篇关于Scala的Cake模式可以在Haskell中实现吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆