New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curious why foldl in haskell has a different type than elm. #764

Closed
MrRacoon opened this Issue Nov 29, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@MrRacoon

MrRacoon commented Nov 29, 2016

In elm (5.0.0):

foldl : (a -> b -> b) -> b -> List a -> b
foldr : (a -> b -> b) -> b -> List a -> b

In haskell:

foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

notice the arguments of the function given to foldl seem to be backwards. Is that intended?

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Nov 29, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Nov 29, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@MrRacoon

This comment has been minimized.

Show comment
Hide comment
@MrRacoon

MrRacoon Nov 29, 2016

oh interesting, just saw this: elm/compiler#346

MrRacoon commented Nov 29, 2016

oh interesting, just saw this: elm/compiler#346

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Nov 30, 2016

Member

Yep, that's the reasoning! This way you can write functions such that "The data structure is always last" and it works nice with folds. The direction of your fold shouldn't require a refactor IMO.

Member

evancz commented Nov 30, 2016

Yep, that's the reasoning! This way you can write functions such that "The data structure is always last" and it works nice with folds. The direction of your fold shouldn't require a refactor IMO.

@evancz evancz closed this Nov 30, 2016

@MrRacoon

This comment has been minimized.

Show comment
Hide comment
@MrRacoon

MrRacoon Nov 30, 2016

Does this image still apply to elm? (its from a haskell deck. I use this image to teach people the difference between the folds)

MrRacoon commented Nov 30, 2016

Does this image still apply to elm? (its from a haskell deck. I use this image to teach people the difference between the folds)

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Nov 30, 2016

Member

I think it'd be better to talk about this more on the Slack or on elm-discuss.

Member

evancz commented Nov 30, 2016

I think it'd be better to talk about this more on the Slack or on elm-discuss.

@MrRacoon

This comment has been minimized.

Show comment
Hide comment
@MrRacoon

MrRacoon commented Nov 30, 2016

Aye!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment