Haskell 什么是';:';你是说哈斯克尔?
我正在读取以下数据类型:Haskell 什么是';:';你是说哈斯克尔?,haskell,constructor,infix-notation,Haskell,Constructor,Infix Notation,我正在读取以下数据类型: data Ne = NVar Id | Ne :.. (Clos Term) | NSplit Ne (Bind (Bind (Clos Term))) | NCase Ne (Clos [(Label, Term)]) | NForce Ne | NUnfold Ne (Bind (Clos Term)) deriving (Show, Eq) 第二个成员声明中是什么?构造函数的名称可以是以大写字母开头的字母数字,也可以是以冒号开头的符号
data Ne
= NVar Id
| Ne :.. (Clos Term)
| NSplit Ne (Bind (Bind (Clos Term)))
| NCase Ne (Clos [(Label, Term)])
| NForce Ne
| NUnfold Ne (Bind (Clos Term))
deriving (Show, Eq)
第二个成员声明中是什么?构造函数的名称可以是以大写字母开头的字母数字,也可以是以冒号开头的符号。在后一种情况下,运算符将与中缀函数一样使用中缀
因此,
:..
是Ne
类型的中缀构造函数,它接受类型为Ne
(左操作数)的参数和类型为Clos Term
(右操作数)的参数。:..
是代数数据类型Ne
的构造函数之一。由标点符号组成并以:
开头的构造函数名将成为中缀运算符。试试这个:
module Main where
data List a = Nil
| a :.. (List a)
deriving Show
main = print (1 :.. (2 :.. Nil))