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

Change Alternative instance #50

Closed
chshersh opened this issue May 28, 2020 · 1 comment · Fixed by #51
Closed

Change Alternative instance #50

chshersh opened this issue May 28, 2020 · 1 comment · Fixed by #51
Assignees
Labels

Comments

@chshersh
Copy link
Contributor

Current implementation:

trial/trial/src/Trial.hs

Lines 298 to 301 in 49ad9a0

(<|>) :: Trial e a -> Trial e a -> Trial e a
r@Result{} <|> _ = r
_ <|> r@Result{} = r
(Fiasco e1) <|> (Fiasco e2) = Fiasco (e1 <> e2)

Proposal:

    (<|>) :: Trial e a -> Trial e a -> Trial e a
    r@Result{}  <|> _           = r
    f@Fiasco{}  <|> r@Result{}  = f <> r
    (Fiasco e1) <|> (Fiasco e2) = Fiasco (e1 <> e2)

New semantics: return first Result, but also accumulate all previous Fiascos.

@chshersh chshersh added the core label May 28, 2020
@vrom911
Copy link
Member

vrom911 commented May 28, 2020

Let's first check is the new semantic would preserve all the laws. If not we still can add such function as I see how useful it could be sometimes 🙂

@chshersh chshersh self-assigned this May 28, 2020
@chshersh chshersh changed the title [RFC] Change Alternative instance Change Alternative instance May 28, 2020
chshersh added a commit that referenced this issue May 28, 2020
This was referenced May 28, 2020
vrom911 added a commit that referenced this issue May 28, 2020
* [#50] Change Alternative instance

Resolves #50

* Update trial/src/Trial.hs

Co-authored-by: Veronika Romashkina <[email protected]>

* Fix after review

Co-authored-by: Veronika Romashkina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants