I've begun learning Haskell, and I thought I would implement the ordinal numbers, using the common ("von Neumann") definition. So I wrote:
ordinal 0 = []
ordinal x = [ ordinal n | n<-[1..(x-1)] ]
But the interpreter was not satisfied, and it told me instead that supposedly
* Couldn't match type `a' with `[a]'
Expected: t -> a
Actual: t -> [a]
* Relevant bindings include
ordinal :: t -> a (bound at fist.hs:7:1)
|
1 | ordinal 0 = []
| ^^^^^^^^^^^^^^^...
Now what I imagine might have gone wrong here is that the list is not of homogeneous type. But how would I switch to tuples then? Is there such a thing as "tuple comprehension"?