Skip to content
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

Either andThenK or pipelK seems not quite right #17

Open
lrworth opened this issue Mar 23, 2021 · 0 comments
Open

Either andThenK or pipelK seems not quite right #17

lrworth opened this issue Mar 23, 2021 · 0 comments

Comments

@lrworth
Copy link

lrworth commented Mar 23, 2021

andThenK : (a -> Return x b) -> (b -> Return x c) -> (a -> Return x c)

which means it needs to be called like

andThenK doFirst doSecond

which is the opposite to andThen.

This is fine, I guess, except that

pipelK = List.foldl andThenK singleton

which means

  pipelK [doFirst, doSecond]

expand pipelK

  List.foldl andThenK singleton [doFirst, doSecond]

expand foldl per https://package.elm-lang.org/packages/elm/core/1.0.5/List#foldl

  singleton
  |> andThenK doFirst
  |> andThenK doSecond

expand |>

  andThenK doSecond (andThenK doFirst singleton)

which has the effect of doing doSecond first, then doFirst. The name pipelK (and the comment "Compose updaters from the left") implies it should be the other way around.

I'd solve this by flipping the type of andThenK, and I am happy to submit a PR, just wanted to check it's the right thing to do.

@lrworth lrworth mentioned this issue Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant