module Control.Applicative.HT where import qualified Data.Tuple.HT as Tuple import Control.Applicative (Applicative, liftA2, liftA3, (<$>), (<*>), ) mapPair :: (Applicative f) => (a -> f c, b -> f d) -> (a,b) -> f (c,d) mapPair :: (a -> f c, b -> f d) -> (a, b) -> f (c, d) mapPair (a -> f c, b -> f d) fg = (f c -> f d -> f (c, d)) -> (f c, f d) -> f (c, d) forall a b c. (a -> b -> c) -> (a, b) -> c uncurry ((c -> d -> (c, d)) -> f c -> f d -> f (c, d) forall (f :: * -> *) a b c. Applicative f => (a -> b -> c) -> f a -> f b -> f c liftA2 (,)) ((f c, f d) -> f (c, d)) -> ((a, b) -> (f c, f d)) -> (a, b) -> f (c, d) forall b c a. (b -> c) -> (a -> b) -> a -> c . (a -> f c, b -> f d) -> (a, b) -> (f c, f d) forall a c b d. (a -> c, b -> d) -> (a, b) -> (c, d) Tuple.mapPair (a -> f c, b -> f d) fg mapTriple :: (Applicative m) => (a -> m d, b -> m e, c -> m f) -> (a,b,c) -> m (d,e,f) mapTriple :: (a -> m d, b -> m e, c -> m f) -> (a, b, c) -> m (d, e, f) mapTriple (a -> m d, b -> m e, c -> m f) fgh = (m d -> m e -> m f -> m (d, e, f)) -> (m d, m e, m f) -> m (d, e, f) forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d Tuple.uncurry3 ((d -> e -> f -> (d, e, f)) -> m d -> m e -> m f -> m (d, e, f) forall (f :: * -> *) a b c d. Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d liftA3 (,,)) ((m d, m e, m f) -> m (d, e, f)) -> ((a, b, c) -> (m d, m e, m f)) -> (a, b, c) -> m (d, e, f) forall b c a. (b -> c) -> (a -> b) -> a -> c . (a -> m d, b -> m e, c -> m f) -> (a, b, c) -> (m d, m e, m f) forall a d b e c f. (a -> d, b -> e, c -> f) -> (a, b, c) -> (d, e, f) Tuple.mapTriple (a -> m d, b -> m e, c -> m f) fgh curry :: (Applicative f) => (f (a,b) -> g) -> f a -> f b -> g curry :: (f (a, b) -> g) -> f a -> f b -> g curry f (a, b) -> g f f a a f b b = f (a, b) -> g f (f (a, b) -> g) -> f (a, b) -> g forall a b. (a -> b) -> a -> b $ (a -> b -> (a, b)) -> f a -> f b -> f (a, b) forall (m :: * -> *) a b r. Applicative m => (a -> b -> r) -> m a -> m b -> m r lift2 (,) f a a f b b curry3 :: (Applicative f) => (f (a,b,c) -> g) -> f a -> f b -> f c -> g curry3 :: (f (a, b, c) -> g) -> f a -> f b -> f c -> g curry3 f (a, b, c) -> g f f a a f b b f c c = f (a, b, c) -> g f (f (a, b, c) -> g) -> f (a, b, c) -> g forall a b. (a -> b) -> a -> b $ (a -> b -> c -> (a, b, c)) -> f a -> f b -> f c -> f (a, b, c) forall (f :: * -> *) a b c d. Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d lift3 (,,) f a a f b b f c c {-# INLINE lift #-} lift :: Applicative m => (a -> r) -> m a -> m r lift :: (a -> r) -> m a -> m r lift = (a -> r) -> m a -> m r forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap {-# INLINE lift2 #-} lift2 :: Applicative m => (a -> b -> r) -> m a -> m b -> m r lift2 :: (a -> b -> r) -> m a -> m b -> m r lift2 = (a -> b -> r) -> m a -> m b -> m r forall (f :: * -> *) a b c. Applicative f => (a -> b -> c) -> f a -> f b -> f c liftA2 {-# INLINE lift3 #-} lift3 :: Applicative m => (a -> b -> c -> r) -> m a -> m b -> m c -> m r lift3 :: (a -> b -> c -> r) -> m a -> m b -> m c -> m r lift3 = (a -> b -> c -> r) -> m a -> m b -> m c -> m r forall (f :: * -> *) a b c d. Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d liftA3 {-# INLINE lift4 #-} lift4 :: Applicative m => (a -> b -> c -> d -> r) -> m a -> m b -> m c -> m d -> m r lift4 :: (a -> b -> c -> d -> r) -> m a -> m b -> m c -> m d -> m r lift4 a -> b -> c -> d -> r fn m a a m b b m c c m d d = a -> b -> c -> d -> r fn (a -> b -> c -> d -> r) -> m a -> m (b -> c -> d -> r) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> m a a m (b -> c -> d -> r) -> m b -> m (c -> d -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m b b m (c -> d -> r) -> m c -> m (d -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m c c m (d -> r) -> m d -> m r forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m d d {-# INLINE lift5 #-} lift5 :: Applicative m => (a -> b -> c -> d -> e -> r) -> m a -> m b -> m c -> m d -> m e -> m r lift5 :: (a -> b -> c -> d -> e -> r) -> m a -> m b -> m c -> m d -> m e -> m r lift5 a -> b -> c -> d -> e -> r fn m a a m b b m c c m d d m e e = a -> b -> c -> d -> e -> r fn (a -> b -> c -> d -> e -> r) -> m a -> m (b -> c -> d -> e -> r) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> m a a m (b -> c -> d -> e -> r) -> m b -> m (c -> d -> e -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m b b m (c -> d -> e -> r) -> m c -> m (d -> e -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m c c m (d -> e -> r) -> m d -> m (e -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m d d m (e -> r) -> m e -> m r forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m e e {-# INLINE lift6 #-} lift6 :: Applicative m => (a -> b -> c -> d -> e -> f -> r) -> m a -> m b -> m c -> m d -> m e -> m f -> m r lift6 :: (a -> b -> c -> d -> e -> f -> r) -> m a -> m b -> m c -> m d -> m e -> m f -> m r lift6 a -> b -> c -> d -> e -> f -> r fn m a a m b b m c c m d d m e e m f f = a -> b -> c -> d -> e -> f -> r fn (a -> b -> c -> d -> e -> f -> r) -> m a -> m (b -> c -> d -> e -> f -> r) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> m a a m (b -> c -> d -> e -> f -> r) -> m b -> m (c -> d -> e -> f -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m b b m (c -> d -> e -> f -> r) -> m c -> m (d -> e -> f -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m c c m (d -> e -> f -> r) -> m d -> m (e -> f -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m d d m (e -> f -> r) -> m e -> m (f -> r) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m e e m (f -> r) -> m f -> m r forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> m f f {-# DEPRECATED liftA4 "use App.lift4" #-} {-# INLINE liftA4 #-} liftA4 :: Applicative f => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e liftA4 :: (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e liftA4 a -> b -> c -> d -> e f f a a f b b f c c f d d = a -> b -> c -> d -> e f (a -> b -> c -> d -> e) -> f a -> f (b -> c -> d -> e) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> f a a f (b -> c -> d -> e) -> f b -> f (c -> d -> e) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f b b f (c -> d -> e) -> f c -> f (d -> e) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f c c f (d -> e) -> f d -> f e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f d d {-# DEPRECATED liftA5 "use App.lift5" #-} {-# INLINE liftA5 #-} liftA5 :: Applicative f => (a -> b -> c -> d -> e -> g) -> f a -> f b -> f c -> f d -> f e -> f g liftA5 :: (a -> b -> c -> d -> e -> g) -> f a -> f b -> f c -> f d -> f e -> f g liftA5 a -> b -> c -> d -> e -> g f f a a f b b f c c f d d f e e = a -> b -> c -> d -> e -> g f (a -> b -> c -> d -> e -> g) -> f a -> f (b -> c -> d -> e -> g) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> f a a f (b -> c -> d -> e -> g) -> f b -> f (c -> d -> e -> g) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f b b f (c -> d -> e -> g) -> f c -> f (d -> e -> g) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f c c f (d -> e -> g) -> f d -> f (e -> g) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f d d f (e -> g) -> f e -> f g forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f e e {-# DEPRECATED liftA6 "use App.lift6" #-} {-# INLINE liftA6 #-} liftA6 :: Applicative f => (a -> b -> c -> d -> e -> g -> h) -> f a -> f b -> f c -> f d -> f e -> f g -> f h liftA6 :: (a -> b -> c -> d -> e -> g -> h) -> f a -> f b -> f c -> f d -> f e -> f g -> f h liftA6 a -> b -> c -> d -> e -> g -> h f f a a f b b f c c f d d f e e f g g = a -> b -> c -> d -> e -> g -> h f (a -> b -> c -> d -> e -> g -> h) -> f a -> f (b -> c -> d -> e -> g -> h) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> f a a f (b -> c -> d -> e -> g -> h) -> f b -> f (c -> d -> e -> g -> h) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f b b f (c -> d -> e -> g -> h) -> f c -> f (d -> e -> g -> h) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f c c f (d -> e -> g -> h) -> f d -> f (e -> g -> h) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f d d f (e -> g -> h) -> f e -> f (g -> h) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f e e f (g -> h) -> f g -> f h forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> f g g