我正在阅读以下数据类型:
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
。由标点符号组成并以 with 开头的构造函数名称:
成为中缀运算符。尝试这个:
module Main where
data List a = Nil
| a :.. (List a)
deriving Show
main = print (1 :.. (2 :.. Nil))