Most examples for defining algebraic types include data constructors like so:
data Tree a = Tip | Node a (Tree a) (Tree a)
I by mistake defined a type which did not specify a data constructor :
data SearchCondition = Term Bool | SearchCondition :||: (Term Bool)
data Term a = Constant a
sc ::
Hi
I by mistake defined a type which did not specify a data constructor
So the question is what are types with no constructors good for? A
simple example would be appreciated.
They are called phantom types, and can be used for ensuring properties
at the type level.
I wrote about them in a
The answer would be phantom types, but your example doesn't use them.
Each of your types has at least one constructor:
Possibly you overlooked the infix constructor :||: ?
Tree a has 2 constructors: Tip and Node
SearchCondition has 2 constructors: Term and (:||:)
Term a has
On Monday 06 August 2007 19:23, Rahul Kapoor wrote:
Most examples for defining algebraic types include data constructors like
so:
data Tree a = Tip | Node a (Tree a) (Tree a)
I by mistake defined a type which did not specify a data constructor :
In this example, you have two different uses