-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
sequence in haskell #319
Comments
v0.11.1 provides:
v0.12.0 will provide Does this answer your question, @functor-soup? |
I think you would get |
λ: :t sequenceA [Left 4, Right 5]
sequenceA [Left 4, Right 5] :: (Num a1, Num a) => Either a1 [a] |
@davidchambers Hmm I do remember looking at that for quite some time, thought it was something else. I see I am wrong. How would you use @safareli I believe @joneshf's comment clarifies that the answer would be |
@functor-soup correct |
Here are the Sanctuary equivalents of your Haskell expressions, @functor-soup, on the > S.sequence
sequence :: (Applicative f, Traversable t) => TypeRep f -> t (f b) -> f (t b)
> S.sequence(S.Either, [S.Left(4), S.Right(5)])
Left(4)
> S.sequence(S.Either, [S.Right(6), S.Right(9)])
Right([6, 9]) I'll close this issue as I believe we've answered your question. :) |
the type signature of sequence in Haskell is
sequence :: (Monad m, Traversable t) => t (m a) -> m (t a)
so I could have
sequence [Left 4, Right 5] => Left 4
and
sequence [Right 6, Right 9] => Right [6,9]
Is there an equivalent in sanctuary? I've been scanning libraries that implement the fantasy-land spec, none of them seem to have this (so far)
Edit : I understand it can be implemented as such (atleast for my task at hand)
x => S.reduce(S.lift2(S.C(S.append)),S.Right([]),x)
, was wondering why something as such is missingThe text was updated successfully, but these errors were encountered: