question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sequence in haskell

See original GitHub issue

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 missing

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
davidchamberscommented, Jan 14, 2017

Here are the Sanctuary equivalents of your Haskell expressions, @functor-soup, on the dc-fantasy-land branch:

> 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. 😃

1reaction
joneshfcommented, Jan 8, 2017
λ: :t sequenceA [Left 4, Right 5]
sequenceA [Left 4, Right 5] :: (Num a1, Num a) => Either a1 [a]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Data.Sequence - Hackage - Haskell.org
The Seq a type represents a finite sequence of values of type a . Sequences generally behave very much like lists. The class...
Read more >
Sequences - Monday Morning Haskell
Haskell's Sequence type is your go-to for double-ended queue operations. They are comparable to linked lists in other languages, with a few performance ......
Read more >
Sequences — containers 0.5.10.2 documentation
Sequences allow you to store a finite number of sequential elements, providing fast access to both ends of the sequence as well as...
Read more >
Why does application of `sequence` on List of Lists lead to ...
I noticed that applying sequence on List of List s gives its Cartesian Product. Can someone please help me understand how/why this happens?...
Read more >
Haskell 'sequence' Over Functions - Explained - Flarfnoogins
Haskell 'sequence' Over Functions - Explained ... A look into how Haskell's Applicative's work. We'll dissect it, along with how it works with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found