由买买提看人间百态

topics

全部话题 - 话题: gadt
(共0页)
b***e
发帖数: 1419
1
来自主题: Programming版 - scala ts 的复杂
你这个说法有点儿意思。一般来讲duck type和strongly typed是不两立的。但是你这
个说法确实有意义。其实GADT的本质是吧runtime type identification变成了一个
first class value。在Java里可以说
o instanceOf Integer
如果用GADT的方式就变成了
o.type == rttiOfInteger
GADT的expressiveness在于等式的右侧可以是variable, like
o.type == rttiOfSomeType
而instanceof的右侧只能是一个type, which is not a first class value。
GADT还有一个好处是type constructor也可以有rtti as first class (higher order)
value。For instance:
o.type == rttiOfArray(rttiOfInteger)
这就是判断o的type是不是[Int]。我印象里Java的rtti由于历史原因无法支持higher
order va... 阅读全帖
b***e
发帖数: 1419
2
来自主题: Programming版 - functional programming?
I question the accuracy of the Haskell developer salary report, well, yes,
depending on how do you classify Haskell developers. Most of the Haskell
developers are truly academic researchers. Those people who worked with me
before are mostly tenure professors at some universities. So far I didn't
find a single case in my list of 4 big cows who's "thousand years of post-
doc". This is not biology (sorry for my candor, biologists). They might
not be making as high as 200k per year as far as ba... 阅读全帖
b***e
发帖数: 1419
3
来自主题: Programming版 - functional programming?
I question the accuracy of the Haskell developer salary report, well, yes,
depending on how do you classify Haskell developers. Most of the Haskell
developers are truly academic researchers. Those people who worked with me
before are mostly tenure professors at some universities. So far I didn't
find a single case in my list of 4 big cows who's "thousand years of post-
doc". This is not biology (sorry for my candor, biologists). They might
not be making as high as 200k per year as far as ba... 阅读全帖
A*******t
发帖数: 443
4
来自主题: Programming版 - functional programming?
求问GADT, template Haskell, type based reflection, quasiquoting 在python里面
是咋做的。
A*******t
发帖数: 443
5
来自主题: Programming版 - functional programming?
求问GADT, template Haskell, type based reflection, quasiquoting 在python里面
是咋做的。
a*****e
发帖数: 1700
6
来自主题: Programming版 - haskell怎么调试好?

我做编译器相关工作,有时会用到 Haskell。
你如果用 deriving Show,那么会自动生成 Show a => Show (Tree a) 的 instance.
如果你想直接在类型上限定,可以写成:
data Tree a where
EmptyTree :: Tree a
Node :: a -> Tree a -> Tree a
这种写法和上面写法等价,是引入 GADT 之后加入的语法。然后,要做 Show a 的限制
就很简单了:
data Tree a where
EmptyTree :: Show a => Tree a
Node :: Show a => a -> Tree a -> Tree a
之前你遇到那个类型错误,询问结果是,可以用 {-# LANGUAGE ExtendedDefaultRules
#-} 来规避。详见
https://www.haskell.org/ghc/docs/7.8.3/html/users_guide/interactive-
evaluation.html#extended-de... 阅读全帖
b***e
发帖数: 1419
7
来自主题: Programming版 - scala ts 的复杂
我个人的感觉是implicit parameters and type/constructor classes其实还是很复杂
的,不过一般人不会deep dive。还有就是GADT。Haskell里面搀的东西太多了。作为教
材是合适的。但是如果有一条实用路的话,还是scala比较接地气。
H****S
发帖数: 1359
8
来自主题: Programming版 - 王垠新文 为Java说句公道话
Haskell所有data structure都是immutable的,而且还是inherent lazy。
Haskell Machines库直接就是networked stream transducer
https://hackage.haskell.org/package/machines-0.6/docs/Data-Machine-Moore.
html
支持数据流的各种同步或者异步整合操作。
所以你这些根本就不能叫什么原创。我说几个Haskell特有的,GADT还有kind
polymorphism。这些才叫独有,即便Scala compiler暂时也不能从语言层面支持这些特
性。

Clojure
(共0页)