As someone who is still learning Ruby and would like to learn Haskell I have no idea what is going on here. Would someone be kind enough to explain? Thanks.
Specifically, it is monkey patching the unary - and + operators on array, and has a clever global method missing.
The unary operators `def -@` gets called when you do something like: `-[1,2,3]`.
So in the example code at the bottom, it's doing `bar =+ [x | x <- [1..3]]` that's better parsed as `bar = +[x | x <- [1..3]]` (note the spacing difference).
Comments
As someone who is still learning Ruby and would like to learn Haskell I have no idea what is going on here. Would someone be kind enough to explain? Thanks.
Specifically, it is monkey patching the unary - and + operators on array, and has a clever global method missing.
The unary operators `def -@` gets called when you do something like: `-[1,2,3]`.
So in the example code at the bottom, it's doing `bar =+ [x | x <- [1..3]]` that's better parsed as `bar = +[x | x <- [1..3]]` (note the spacing difference).
Hacking unary operators has a long history in silliness in ruby. See also: https://github.com/jicksta/superators
It's just adding a syntactic construct to ruby which looks similar to haskells list comprehensions. Explanation for haskell: http://learnyouahaskell.com/starting-out#im-a-list-comprehen...
Ah, I get it. Thanks dude.