Created
January 11, 2016 18:42
-
-
Save Solonarv/b9c4a0ed2ee061e81d15 to your computer and use it in GitHub Desktop.
This file contains 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 characters
-- formulate in standard style, as a mental crutch | |
tryUntilSuccess :: [a -> Either e b] -> a -> Either [e] b | |
tryUntilSuccess fs x = let ys = map ($ x) fs | |
in case dropWhile isLeft ys of | |
[] -> Left $ lefts $ takeWhile isLeft ys | |
(Right y):_ -> Right y | |
-- Formulate in simply polymorphic CPS next | |
-- This is the signature of the... thing... I'm trying to write | |
tryUntilSuccessCPS :: [a -> (Either f b -> c) -> c] -> ((a -> (Either [f] b -> e) -> e) -> d) -> d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment