一切都在Haskell是一樣的功能:數據構造函數是否支持currying?
Prelude> type Subject = String
Prelude> type Verb = String
Prelude> type Object = String
Prelude> data Sentence = Sentence Subject Verb Object deriving (Eq, Show)
Prelude> :t Sentence
Sentence :: Subject -> Verb -> Object -> Sentence
的句子是一個數據類型,但爲什麼它顯示的功能? 即使我用一個值替代,那麼它就像一個函數。
s1 = Sentence "dogs" "drool"
數據類型是否也支持currying呢?
如果你已經嘗試了':t s1',你會發現它的類型是'Object - > Sentence'。 – chepner