Why is it possible to make such a list in Haskell:
slist = [ [], [[]], [[],[[]]] ]
As far I understand, every element has various types here (like in mathematics: Ø, {Ø} and so on). And ghci says:
> :t []
[] :: [t]
> :t [[]]
[[]] :: [[t]]
formally, I see different notes.
In other words, the first element is a simple empty list and the second one is a list of list (!) and so on.
What is wrong? Why does Haskell consider them to be the same type?
data NestList a = Elem a | Nest [a], then you can writeNest [ Nest [], Nest [ Nest [] ] ]to any depth.data NestedList a = Elem a | Nest [NestedList a].