<div dir="ltr">[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.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 5, 2016 at 5:59 AM Olumide <<a href="mailto:50295@web.de">50295@web.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 01/01/2016 19:41, Alexander Berntsen wrote:<br>
>> Can you please give an example of [] used as a type constructor?<br>
> Whenever you write a list type, e.g. [Int], you are using [] as a type<br>
> constructor. The fact that you can write [Int] instead of '[] Int' is<br>
> simply syntax sugar.<br>
><br>
> We can imagine the simple function that returns the first element of a<br>
> list, if there is one.<br>
><br>
> head :: [a] -> Maybe a<br>
> head [] = Nothing<br>
> head (x:xs) = Just x<br>
><br>
> Here we use [] both on type and term level. On type level we use it to<br>
> mean a list of 'a's, and on term level we use it to mean the empty list.<br>
<br>
Out of curiosity, is [] defined as type constructor _and_ term level at<br>
the library level or in the language/compiler? (BTW, google tells me<br>
"term-level" has a special meaning that I do not yet know.)<br>
<br>
Note: I've deferred reading your explanation of kinds because (1) I am<br>
still trying to get to grips with Functors and (2) the section on kinds<br>
is just two pages away from where I am in the book. So if these<br>
questions are answered by kinds please let me know.<br>
<br>
Thanks for your patience,<br>
<br>
- Olumide<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>