rob*_*kuz 4 f# types ml higher-kinded-types
我正在尝试跟进"Lightweight high-kinded polymorphism"(https://ocamllabs.github.io/higher/lightweight-higher-kinded-polymorphism.pdf)这篇论文并且我坚持将这个ML代码转换为F#
type (_,_) arrow =
Fn_plus : ((int ? int), int) arrow
| Fn_plus_cons : int ? ((int ? int list), int list) arrow
Run Code Online (Sandbox Code Playgroud)
和
let apply : type a b. (a, b) arrow ? a ? b =
fun (appl, v) ? match appl with
| Fn_plus ? let (x, y) = v in x + y
| Fn_plus_cons n ? let (x, l’) = v in x + n :: l’
Run Code Online (Sandbox Code Playgroud)
具体来说,类型定义感觉就像一个巨大的魔力墙.
| 归档时间: |
|
| 查看次数: |
286 次 |
| 最近记录: |