The nullary constructor, as far as the term has meaning in most languages, is () a.k.a. unit. It takes no arguments, and returns a valid data type.

There is, however, an even less populated type: Void has no legal values at all! If nullary is arity 0, this is roughly arity i. It is still useful as a type-level encoding of "impossible outcome" in parametric code.

On Sat, Aug 18, 2018, 3:09 AM trent shipley <trent.shipley@gmail.com> wrote:
OK. That makes total sense.  And a little experimentation with GHCi or reading the prelude would have prevented my spamming the list.

What about the tacked on question about nullity in "core" Haskell?

On Sat, Aug 18, 2018 at 2:37 AM Francesco Ariis <fa-ml@ariis.it> wrote:
Hello Trent,

On Sat, Aug 18, 2018 at 02:13:25AM -0700, trent shipley wrote:
> 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.

`:` is not syntactic sugar, but a data constructor and behaves like one!

    λ> :type (:)
    (:) :: a -> [a] -> [a]

"Give me an `a` and a list of `a`, I will return a list."

The `empty list` ([]) is polymorphic:

    λ> :t []
    [] :: [a]

(it could be an empty list of strings, of ints, of dromedaries),
so `3:[]` is well typed.

Note that `3:[]:4` will not type-check and that to build a list, you
*have* to start with a `[]`.

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners