[Haskell-beginners] Empty list and null

trent shipley trent.shipley at gmail.com
Sat Aug 18 09:13:25 UTC 2018


Why does Haskell so often seem to treat [] as a general null.

For example I know 0 : 1 : [] gives [0, 1].

But shouldn't it produce a type fault in a consistent world?

Int:Int:List isn't properly a list.  It mixes types.

I expect something like:

Let GSN mean general_scalar_null.

1 : 2 : GSN  -- works

1 : 2 : []  -- type fault, cannot mix int and empty list in the same list.

And why does [] == [] : []
instead of [[], []] == [] : []

What sorts of nullity are there in core Haskell?

Trent.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180818/dd3bff19/attachment.html>


More information about the Beginners mailing list