b***e 发帖数: 1419 | 1 你这个说法有点儿意思。一般来讲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 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 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 求问GADT, template Haskell, type based reflection, quasiquoting 在python里面
是咋做的。 |
|
A*******t 发帖数: 443 | 5 求问GADT, template Haskell, type based reflection, quasiquoting 在python里面
是咋做的。 |
|
a*****e 发帖数: 1700 | 6
我做编译器相关工作,有时会用到 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 我个人的感觉是implicit parameters and type/constructor classes其实还是很复杂
的,不过一般人不会deep dive。还有就是GADT。Haskell里面搀的东西太多了。作为教
材是合适的。但是如果有一条实用路的话,还是scala比较接地气。 |
|
|