
6 Aug
2007
6 Aug
'07
7:52 p.m.
On 2007-08-06, Rahul Kapoor
I by mistake defined a type which did not specify a data constructor :
No, you didn't. Both types have data constructors.
data SearchCondition = Term Bool | SearchCondition :||: (Term Bool) data Term a = Constant a
sc :: SearchCondition sc = Term True
is ok, but
sc :: SearchCondition sc = Constant True
is not (though this is what I intended to capture!).
The problem is that Constant True is of type Term Bool, rather than SearchCondition. Constructors and names of data types live in separate namespaces.
So the question is what are types with no constructors good for? A simple example would be appreciated.
See the phantom types answer that someone else gave. -- Aaron Denney -><-