Last active
August 18, 2016 13:47
-
-
Save PiDelport/f24f1a92e58f21f73c38a85d15781302 to your computer and use it in GitHub Desktop.
Revisions
-
PiDelport revised this gist
Aug 13, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ sequenceRights [] = pure (pure []) sequenceRights (x:xs) = handle =<< x where handle (Left e) = pure (Left e) handle (Right t) = (t:) <<$>> sequenceRights xs -- This should be in a standard library somewhere. -
PiDelport created this gist
Aug 13, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ -- Sequence a list of Either-yielding monadic actions. -- Sequencing stops on the first Left value, or yields a list successful Right values. sequenceRights :: Monad m => [m (Either e t)] -> m (Either e [t]) sequenceRights [] = pure (pure []) sequenceRights (x:xs) = handle =<< x where handle (Left e) = pure (Left e) handle (Right t) = (t:) <<$>> blah xs -- This should be in a standard library somewhere. (<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b) (<<$>>) = fmap . fmap