[1,2,3] is [Int] or [] Int (if we take the numbers to be Ints for simplicity). It is the [] type constructor applied to the Int type.

On Tue, Jan 5, 2016 at 5:59 AM Olumide <50295@web.de> wrote:
On 01/01/2016 19:41, Alexander Berntsen wrote:
>> Can you please give an example of [] used as a type constructor?
> Whenever you write a list type, e.g. [Int], you are using [] as a type
> constructor. The fact that you can write [Int] instead of '[] Int' is
> simply syntax sugar.
>
> We can imagine the simple function that returns the first element of a
> list, if there is one.
>
> head :: [a] -> Maybe a
> head []     = Nothing
> head (x:xs) = Just x
>
> Here we use [] both on type and term level. On type level we use it to
> mean a list of 'a's, and on term level we use it to mean the empty list.

Out of curiosity, is [] defined as type constructor _and_ term level at
the library level or in the language/compiler? (BTW, google tells me
"term-level" has a special meaning that I do not yet know.)

Note: I've deferred reading your explanation of kinds because (1) I am
still trying to get to grips with Functors and (2) the section on kinds
is just two pages away from where I am in the book. So if these
questions are answered by kinds please let me know.

Thanks for your patience,

- Olumide

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