Haskell 数据构造函数是否支持currying?

Haskell 数据构造函数是否支持currying?,haskell,Haskell,Haskell中的所有功能都类似于: 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

Haskell中的所有功能都类似于:

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"  
数据类型也支持咖喱吗

     v this is name of a new type
data Sentence = Sentence Subject Verb Object
                ^ and this is a function called "value constructor"
                  (it may or may not have same name with the new type)

所以答案是肯定的,Curry也适用于“值构造函数”函数。

正如Jokester所指出的,令人困惑的是,这里有两个东西都被命名为“
句子”
”:

  • 句子
    类型,以及
  • 语句
    数据构造函数
许多数据构造函数都是函数,因为许多数据类型在其中存储了一些内容,而它们唯一能做到这一点的方法就是在构造过程中请求这些内容

但是,具有
语句
类型的对象不是函数。它们只是普通值:

:t (Sentence "he" "likes" "cake")
:: Sentence

如果您尝试过
:ts1
,您会看到它的类型是
对象->句子。