Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is sequence syntactic sugar ([1..6]) translated into actual list syntax ( 1:2:3...6 )?

How does Haskell translate [ and ] into the list definitions? Are they value constructors or something? Are they newtypes? Is there a way to define an outfix syntax, as opposed to an infix one?

like image 658
Athan Clark Avatar asked Jul 26 '13 03:07

Athan Clark


Video Answer


1 Answers

This syntax is defined in the Report, and in particular in section 3.10. [1..6] is defined to mean enumFromTo 1 6. You can't define syntax like that yourself.

like image 194
shachaf Avatar answered Sep 23 '22 19:09

shachaf