Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In haskell, What does :+: mean in data type definition?

Tags:

haskell

This is the definition for a new data type:

data Total a = Total a :+: Total a 
              |...

What does :+: mean in this type definition?

like image 476
Hamid Avatar asked Oct 04 '12 18:10

Hamid


People also ask

How do you define data types in Haskell?

The Data Keyword and Constructors In general, we define a new data type by using the data keyword, followed by the name of the type we're defining. The type has to begin with a capital letter to distinguish it from normal expression names. To start defining our type, we must provide a constructor.

How is defined in Haskell?

The most basic way of defining a function in Haskell is to ``declare'' what it does. For example, we can write: double :: Int -> Int double n = 2*n. Here, the first line specifies the type of the function and the second line tells us how the output of double depends on its input.

What do you mean by type class in Haskell?

Type Classes are a language mechanism in Haskell designed to support general overloading in a principled way. They address each of the concerns raised above. They provide concise types to describe overloaded functions, so there is no expo- nential blow-up in the number of versions of an overloaded function.

What does nothing mean in Haskell?

Nothing is a value, and its concrete type may be any possible instantiation of Maybe a . Otherwise said, values of type Maybe a continue to have concrete types Maybe Int , Maybe String , Maybe Whatever , and in particular, Nothing is able to be typed by each of them, depending on the context.


1 Answers

It is a data constructor written in infix form. You can have an operator as constructor if it begins with : .

like image 139
Satvik Avatar answered Oct 19 '22 04:10

Satvik