尝试将类型定义从Ocaml / F#转换为Haskell,收到错误:
error: parse error on input `*'
我怎样才能更正代码?
当前 Haskell 代码:
data Func sa sb =
Empty
| Leaf Int * (sa * sb) List
| Branch Int * Int * (Func sa sb) * (Func sa sb)
ocaml的:
type ('a,'b)func =
Empty
| Leaf of int * ('a*'b)list
| Branch of int * int * ('a,'b)func * ('a,'b)func;;
F#
type func<'a,'b> =
| Empty
| Leaf of int * ('a * 'b) list
| Branch of int * int * func<'a,'b> * func<'a,'b>
答案 0 :(得分:8)
data Func a b
= Empty
| Leaf Int [(a, b)]
| Branch Int Int (Func a b) (Func a b)