19

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?

Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192

2 Answers2

20

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).

sepp2k
  • 363,768
  • 54
  • 674
  • 675
12

:.. is one of the constructors for the algebraic datatype 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))
Fred Foo
  • 355,277
  • 75
  • 744
  • 836