Created
December 10, 2010 00:39
-
-
Save ghulette/735577 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
mapAll :: (a -> Maybe a) -> [a] -> Maybe [a] | |
mapAll _ [] = Just [] | |
mapAll f (x:xs) = case f x of | |
Just x' -> case mapAll f xs of | |
Just xs' -> Just (x':xs') | |
Nothing -> Nothing | |
Nothing -> Nothing | |
mapOne :: (a -> Maybe a) -> [a] -> Maybe [a] | |
mapOne _ [] = Nothing | |
mapOne f (x:xs) = case f x of | |
Just x' -> Just (x':xs) | |
Nothing -> case mapOne f xs of | |
Just xs' -> Just (x:xs') | |
Nothing -> Nothing | |
mapSome :: (a -> Maybe a) -> [a] -> Maybe [a] | |
mapSome _ [] = Nothing | |
mapSome f (x:xs) = case f x of | |
Just x' -> case mapSome f xs of | |
Just xs' -> Just (x':xs') | |
Nothing -> Just (x':xs) | |
Nothing -> case mapSome f xs of | |
Just xs' -> Just (x:xs') | |
Nothing -> Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment