简体   繁体   English

':..'在Haskell中意味着什么?

[英]What does ':..' mean in Haskell?

I'm reading a following datatype: 我正在阅读以下数据类型:

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)

What is :.. in the second member declaration? 什么是:..在第二个成员声明中?

The name of a constructor can either be alpha-numeric starting with a capital letter or symbolic starting with a colon. 构造函数的名称可以是以大写字母开头的字母数字,也可以是以冒号开头的符号。 In the latter case the operator will be used infix just like infix functions. 在后一种情况下,操作符将像中缀函数一样使用中缀。

So :.. is an infix constructor for the Ne type, which takes an argument of type Ne (left operand) and one of type Clos Term (right operand). 所以:..Ne类型的中缀构造函数,它接受类型为Ne (左操作数)的参数和类型为Clos Term (右操作数)的参数。

:.. is one of the constructors for the algebraic datatype Ne . :..是代数数据类型Ne的构造函数之一。 A constructor name consisting of punctuation and starting with : becomes an infix operator. 构造函数的名称,包括标点符号,并开始:成为中缀运算符。 Try this: 试试这个:

module Main where

data List a = Nil
            | a :.. (List a)
            deriving Show

main = print (1 :.. (2 :.. Nil))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM