2017-01-28 60 views
-3

試圖類型定義從ocaml的/ F#轉換爲Haskell中,得到一個錯誤:Ocaml程序編寫/哈斯克爾類型定義轉換爲哈斯克爾:*在定義

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> 

回答

8
data Func a b 
    = Empty 
    | Leaf Int [(a, b)] 
    | Branch Int Int (Func a b) (Func a b)