Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFlipping arguments in foldl's step function #340
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 11, 2015
Member
The reasoning is here and matches how things work in Standard ML which I find the clearest and nicest of the ML family languages.
I get why Haskell did it that way, but in practice I find it super annoying. I also am not targeting Haskell programmers primarily. I trust that they'll be able to sort out any minor differences (like colon vs double colon) and I can do what's right for the broader Elm community which will primarily be made up of folks coming from JS and ruby and python and such.
There are probably discussions on elm-discuss going into more detail about why things are this way, so def check that out for more information!
|
The reasoning is here and matches how things work in Standard ML which I find the clearest and nicest of the ML family languages. I get why Haskell did it that way, but in practice I find it super annoying. I also am not targeting Haskell programmers primarily. I trust that they'll be able to sort out any minor differences (like colon vs double colon) and I can do what's right for the broader Elm community which will primarily be made up of folks coming from JS and ruby and python and such. There are probably discussions on elm-discuss going into more detail about why things are this way, so def check that out for more information! |
evancz
closed this
Aug 11, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sindikat
commented
Aug 11, 2015
|
Thank you Evan for the response. This topic was discussed on mailing list: |
sindikat commentedAug 10, 2015
Elm's
foldrhas the same type as Haskell'sfoldr:However Elm's
foldlhas a different type, than Haskell'sfoldl:Changing type of
foldlin Elm is API-breaking, but it makes sense. When you fold a list from left, your step function looks like(\acc e -> ...)— the accumulator is to the left of the current element, because the accumulator is to the left of the list itself. This is a good visual intuition. Also there is no reason to arbitrarily deviate from Haskell, if it doesn't benefit Elm (or there are benefits that I don't know about?).Can we consider that? If no, can we maybe add the note to documentation to avoid confusion?