相关疑难解决方法(0)

Ocaml中的高阶类型构造函数和函子

可以具有以下多态函数

let id x = x;;
let compose f g x = f (g x);;
let rec fix f = f (fix f);;     (*laziness aside*)
Run Code Online (Sandbox Code Playgroud)

是为类型/类型构造函数或模块/仿函数编写的?我试过了

type 'x id = Id of 'x;;
type 'f 'g 'x compose = Compose of ('f ('g 'x));;
type 'f fix = Fix of ('f (Fix 'f));;
Run Code Online (Sandbox Code Playgroud)

对于类型但它不起作用.

这是类型的Haskell版本:

data Id x = Id x
data Compose f g x = Compose (f (g x))
data Fix f = Fix (f (Fix f))

-- …
Run Code Online (Sandbox Code Playgroud)

ocaml functional-programming

28
推荐指数
2
解决办法
4976
查看次数

标签 统计

functional-programming ×1

ocaml ×1