What does ':..' mean in Haskell?
Asked Answered
P

2

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?

Pazia answered 3/4, 2012 at 15:42 Comment(0)
J
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).

Jugglery answered 3/4, 2012 at 15:45 Comment(0)
D
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))
Doorn answered 3/4, 2012 at 15:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.