gcanti / flow-static-land

[DEPRECATED, please check out fp-ts] Implementation of common algebraic types in JavaScript + Flow
MIT License
408 stars 22 forks source link

Is `sequence` correct for `arr` and `maybe`? #56

Closed frontsideair closed 7 years ago

frontsideair commented 7 years ago

I'm trying get accustomed to this library, which I find awesome, but I think I hit a bug.

I want to sequence an arr of maybes to a maybe of an arr but it doesn't work the way I want. Here's a test case: https://gist.github.com/frontsideair/78b42850858f58105377f09f8e0ec792

I also write comparable code in Haskell, which seems to work the way I wanted:

Prelude> sequence [Just 3, Just 4, Just 5]
Just [3,4,5]
Prelude> sequence [Just 3, Just 4, Nothing]
Nothing

The problem may not be in traversable but one of the dependencies of traversable.

frontsideair commented 7 years ago

Okay, that was my bad. I should've used arr.of(one_item) or arr.inj(list_of_items).