[Haskell-beginners] a bunch o' questions

Daniel Fischer daniel.is.fischer at web.de
Thu Jul 1 15:31:52 EDT 2010


On Thursday 01 July 2010 21:00:08, Brandon S Allbery KF8NH wrote:
> On 7/1/10 14:48 , matthew coolbeth wrote:
> > So, is it possible for me to define a parametric type with an infix
> > binary data constructor?
>
> With the appropriate extension, you can declare an infix type or data

To clarify: for infix data constructors, no extension is needed, they're in 
Haskell98. To define and infix type constructor, you need the TypeOperators 
language extension.

>
> constructor using a symbol starting with `:':
> > data Listy a = Nil | a :*: Listy a

^ Haskell98

{-# LANGUAGE TypeOperators #-}

data a :+: b = a :+: b deriving (Eq, Ord, Show)

^ not H98

>
> http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/data-type-extens
>ions.html#infix-tycons



More information about the Beginners mailing list