lab08: init
This commit is contained in:
8
lab08/applyMaybe.hs
Normal file
8
lab08/applyMaybe.hs
Normal file
@@ -0,0 +1,8 @@
|
||||
applyMaybe :: Maybe a -> (a -> Maybe b) -> Maybe b
|
||||
applyMaybe Nothing f = Nothing
|
||||
applyMaybe (Just x) f = f x
|
||||
|
||||
test1 = Just 3 `applyMaybe` (\x -> Just $ x * 2) `applyMaybe` (\x -> Just $ x - 1)
|
||||
|
||||
test2 = Just 3 `applyMaybe` (\_ -> Nothing) `applyMaybe` (\x -> Just $ x - 1)
|
||||
|
||||
Reference in New Issue
Block a user