An operator character starting with a colon is a constructor

I study Haskell. From the Haskell 2010 documentation:

  • An operator character starting with a colon is a constructor.
  • An operator character starting with any other character is a regular identifier.

I do not understand the first phrase. I know there are data constructors and class constructors. What is the constructor in this case? Maybe I need some sample code.

+4
source share
2 answers

You can define things like

data Symbolic n
   = Constant n
   | Variable String
   | Symbolic n :+ Symbolic n
   | Symbolic n :* Symbolic n
  deriving (Show)

GHCi> let v = Variable; c = Constant
GHCi> c 2: * v "a": + c 3
(Constant 2: * Variable "a"): + Constant 3

What the first phrase refers to.

+5

, . ?

Haskell , -. GGC TypeOperators, , , :.

+3

All Articles