ref: dbb071134b7ff96377388a879da164168e2cd278
parent: 13593bf35c35d09fc9e01c030d813c3de58a2fc8
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Mon Dec 18 11:29:33 EST 2023
Add more functions
--- a/lib/Control/Applicative.hs
+++ b/lib/Control/Applicative.hs
@@ -14,3 +14,9 @@
(<*) :: forall a b . f a -> f b -> f a
a1 *> a2 = (id <$ a1) <*> a2
a1 <* a2 = (const <$> a1) <*> a2
+
+liftA2 :: forall (f :: Type -> Type) a b c . Applicative f => (a -> b -> c) -> f a -> f b -> f c
+liftA2 f a b = f <$> a <*> b
+
+liftA3 :: forall (f :: Type -> Type) a b c d . Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
+liftA3 f a b c = f <$> a <*> b <*> c
--- a/lib/Data/Either.hs
+++ b/lib/Data/Either.hs
@@ -5,6 +5,7 @@
import Data.Bool
import Data.Eq
import Data.Function
+import Data.Functor
import Data.Int
import Data.Ord
import Text.Show
@@ -31,3 +32,7 @@
instance forall a b . (Show a, Show b) => Show (Either a b) where
showsPrec p (Left a) = showParen (p>=appPrec1) (showString "Left " . showsPrec appPrec1 a)
showsPrec p (Right b) = showParen (p>=appPrec1) (showString "Right " . showsPrec appPrec1 b)
+
+instance forall a . Functor (Either a) where
+ fmap _ (Left a) = Left a
+ fmap f (Right b) = Right (f b)
--
⑨