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 up`foldl` and `foldr` different from Haskell's? #956
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Apr 21, 2018
Member
Elm does it like Standard ML, and I always thought that was nicer. So the real question is why did Haskell do something different than Standard ML? ;)
The short version is that (1) I find it so much easier to remember just one thing, (2) we say "the data structure is always the last argument" is a good guide to writing functions and that means our type fits better with other functions in the language, and (3) I think the "oh, but math" argument ignores these practical considerations.
I recommend asking for more info on the Elm slack if you are still curious! We try to keep issues for bug tracking and community forums for learning, and they can give nice answers more efficiently!
|
Elm does it like Standard ML, and I always thought that was nicer. So the real question is why did Haskell do something different than Standard ML? ;) The short version is that (1) I find it so much easier to remember just one thing, (2) we say "the data structure is always the last argument" is a good guide to writing functions and that means our type fits better with other functions in the language, and (3) I think the "oh, but math" argument ignores these practical considerations. I recommend asking for more info on the Elm slack if you are still curious! We try to keep issues for bug tracking and community forums for learning, and they can give nice answers more efficiently! |
Spaxe commentedApr 21, 2018
I'm curious why Elm's implementation of
foldlandfoldrhas identical signatures, where as Haskell's doesn't.For example:
Elm:
foldl : (a -> b -> b) -> b -> List a -> bHaskell:
foldl :: (b -> a -> b) -> b -> [a] -> bSource code: https://github.com/elm-lang/core/blob/master/src/List.elm#L148-L184