标签: 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