Ocaml中的参数多态性

时间:2018-11-08 20:22:52

标签: functional-programming polymorphism ocaml parametric-polymorphism

假设我有一个代数数据类型:

type ('a,'b) addition = 
  | first of 'a 
  | second of 'b

如何在OCaml中编写下面两个满足上面多态类型签名的函数?

1: ('a, 'b) addition * ('a -> 'c) * ('b -> 'c) -> 'c

2: ('a, 'b * 'c) addition -> ('a, 'b) addition * ('a, 'c) addition

0 个答案:

没有答案