From 47f6f9cc0bbfaed442d7ecdd21f232b134c40084 Mon Sep 17 00:00:00 2001 From: Joel Kaasinen Date: Fri, 25 Jun 2021 19:19:42 +0300 Subject: [PATCH] lecture 15: fix liftA2 definition --- part2.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/part2.html b/part2.html index 008968c..073a1ca 100644 --- a/part2.html +++ b/part2.html @@ -3704,8 +3704,7 @@ bob
instance Applicative Maybe where
   pure x = Just x
   liftA2 f (Just x) (Just y) = Just (f x y)
-  liftA2 f Nothing  (Just _) = Nothing
-  liftA2 f (Just _) Nothing  = Nothing
+ liftA2 f _ _ = Nothing

You’ll see the definition uses the same type of failure propagation as the Monad Maybe instance. Let’s use this when parsing monetary values:

data Currency = EUR | USD