我正在嘗試將 SML 型別轉換為 Haskell 型別。
type Identifier = string
type 'a Environment = (Identifier * 'a) list
uj5u.com熱心網友回復:
我猜 Haskell 中的相同代碼可能是
type Identifier = String
type Environment a = [(Identifier, a)]
盡管如此,我還是建議使用newtypes 來提高型別安全性,例如
newtype Identifier = Identifier String
newtype Environment a = Environment [(Identifier, a)]
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/482700.html
