-
-
Save dminuoso/da18ac7bbde18267cad32d1a3217f183 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
doFoo :: (a -> Maybe a) -> Foo a -> ([a], Foo a) | |
doFoo f (Foo int list) = | |
let (old, new) = foldr go ([],[]) list | |
in (old, Foo int new) | |
where go item (old,new) = case f item of | |
Nothing -> (old , item:new) | |
Just new_item -> (item:old, new_item:new) | |
|| | |
|| | |
|| | |
VV | |
doFoo :: (a -> Maybe a) -> Foo a -> ([a], Foo a) | |
doFoo f (Foo int list) = (old, Foo int new) | |
where | |
(old, new) = foldr go ([],[]) list | |
go item (old,new) = case f item of | |
Nothing -> (old , item:new) | |
Just new_item -> (item:old, new_item:new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment