summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--foo.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/foo.hs b/foo.hs
index 1565904..08b79de 100644
--- a/foo.hs
+++ b/foo.hs
@@ -1,3 +1,5 @@
+import Data.Maybe (catMaybes)
+
foo :: [(Int, Int)]
foo = [(8, 14), (4,2), (3,4)]
@@ -33,4 +35,11 @@ func3 x = x * 5
funcs = [func1, func2, func3]
+maybeints = [ Just 1, Just 2, Nothing, Just 4]
+
+lift_tuple :: (Int, Maybe Int) -> Maybe (Int, Int)
+lift_tuple (a, Just b) = Just (a, b)
+lift_tuple (a, Nothing) = Nothing
+
+pairs = catMaybes $ map lift_tuple $ zip intlist maybeints