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

Alternative MaybeT instance might not be distributive #116

Closed
LukaJCB opened this issue Jul 10, 2019 · 5 comments
Closed

Alternative MaybeT instance might not be distributive #116

LukaJCB opened this issue Jul 10, 2019 · 5 comments

Comments

@LukaJCB
Copy link

LukaJCB commented Jul 10, 2019

Imagine this scenario:

f :: MaybeT Effect (a -> b)
f = empty 
g :: MaybeT Effect (a -> b)
x :: MaybeT Effect a

-- Will run the effects of x only once
(f <|> g) <*> x

-- Will run the effects of x twice
 (f <*> x) <|> (g <*> x)
@hdgarrood
Copy link
Contributor

Thanks for the report. This does indeed seem problematic. Perhaps we should just remove the Alternative instance in the next breaking release.

@triallax
Copy link

After this library is updated to 0.14, can I make a PR for this? Or do we not breaking release for now?

@JordanMartinez
Copy link
Contributor

JordanMartinez commented Oct 14, 2020 via email

@hdgarrood
Copy link
Contributor

Actually, I think we should leave this as-is. Many Alternative instances in the wild obey a "left catch" law:

pure a <|> b = pure a

instead of the documented distributivity law, and MaybeT is one example. Other examples include parsers and Aff. See also purescript/purescript-control#63 - I think we should wait until we've made progress there before removing any instances here.

@hdgarrood
Copy link
Contributor

I think this is just one example of the issue described in purescript/purescript-control#63, so I think we should close this for now and continue tracking the issue there.

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

No branches or pull requests

4 participants