Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Add swap for Either and Tuple and Weighted implementations #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

puffnfresh
Copy link

How do we collaborate on this stuff? Should I even be submitting a pull request?

Either.swap : Either a b -> Either b a
Either.swap e = case e of
  Either.Left a -> Right a
  Either.Right b -> Left b

Weighted.eithers : Weighted a -> Weighted b -> Weighted (Either a b)
Weighted.eithers as bs = Weighted.map Left as <|> Weighted.map Right bs

Tuple.swap : Tuple a b -> Tuple b a
Tuple.swap t = case t of (Tuple.Cons a b) -> Cons b a

Weighted.tuples : Weighted a -> Weighted b -> Weighted (Tuple a b)
Weighted.tuples = Weighted.mergeWith (a b -> Cons a b)

…jj7fpk8t4fe3e6i5umopac2eult9i6pvbopl1dmtiv1ci8
@aryairani
Copy link
Collaborator

aryairani commented Oct 28, 2019

Thanks @puffnfresh. I'm trying to sort that out right now, and will use yours as a test case :)

@francisdb
Copy link

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants