所以我有這樣的代碼: type Zero = One = 1 | Two = 2 | Three = 3
type Four = Five = 5 | Six = 6 | Seven = 7
let test_1 (x : bool) : Type =
if x
then typeof<Zero>
else typeof<Four>
let test_2()
由於類型是伊德里斯一流的,好像我應該能夠編寫一個typeOf函數返回其參數的類型: typeOf : a => a -> Type
typeOf x = a
然而,當我試圖調用這個函數,我得到看起來像一個錯誤: *example> typeOf 42
Can't find implementation for Integer
我怎樣才能正確地實現這個功能typeOf?或者是否存在一些我
1)假設有一個模塊 module Int_Sig_1 =
struct
let x = 1
end
;;
2)和該模塊 module type INT_SIG =
sig
val x:int
end
;;
3)的顯式簽名和我創建基於第一級模塊在上面的模塊和模塊類型 let int_sig_1 = (module Int_Sig_1:INT_SIG)
4)現在我創建另一個