Sam Danielson wrote:
The [] constructor takes no arguments and is like Nothing in the Maybe
type. The list ":" (cons) infix constructor takes two arguments, an
element of type a and a list of type a, to construct a new list. Compare
to Maybe.

        data []    a = []      | a : [a]
        data Maybe a = Nothing | Just a

Another way of saying [()] is

        ():[]

which, comparing with the Maybe type, is similar to saying

        Just ()

but Just only takes one argument where (:) takes two.

Both List and Maybe are containers that have a null constructor, namely
[] and Nothing. "():[]" contains () similar to how "Just ()" contains
(). You can make your own list type and put () in it as follows.

Or, in Monad terms:

"[()]" and "Just ()" are both "return ()" in their respective Monads.
"[]" and "Nothing" are both "mzero" in their respective MonadsPluses. (Both are also "fail" in their respective Monads, but I find "fail"'s presence in Monad a bit inelegant, though handy.)

--
src/
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to