module Synthesizer.ApplicativeUtility where
import Control.Arrow (Arrow, (<<<), )
import Control.Monad.Fix (fix, )
import Control.Applicative (Applicative, (<*>), (<$>), liftA2, )
import Data.Traversable (Traversable, sequenceA, )
{-# INLINE liftA4 #-}
liftA4 :: Applicative f =>
(a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
liftA4 f a b c d = f <$> a <*> b <*> c <*> d
{-# INLINE liftA5 #-}
liftA5 :: Applicative f =>
(a -> b -> c -> d -> e -> g) -> f a -> f b -> f c -> f d -> f e -> f g
liftA5 f a b c d e = f <$> a <*> b <*> c <*> d <*> e
{-# 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 f a b c d e g = f <$> a <*> b <*> c <*> d <*> e <*> g
{-# INLINE loop #-}
loop :: (Functor f) =>
f (a -> a)
-> f a
loop = fmap fix
infixl 0 $:, $::, $^, $#
infixr 9 .:, .^
{-# INLINE ($:) #-}
($:) :: (Applicative f) => f (a -> b) -> f a -> f b
($:) = (<*>)
{-# INLINE ($::) #-}
($::) :: (Applicative f, Traversable t) =>
f (t a -> b) -> t (f a) -> f b
($::) f arg = f $: sequenceA arg
{-# INLINE (.:) #-}
(.:) :: (Applicative f, Arrow arrow) =>
f (arrow b c) -> f (arrow a b) -> f (arrow a c)
(.:) = liftA2 (<<<)
{-# INLINE ($^) #-}
($^) :: (Functor f) => (a -> b) -> f a -> f b
($^) = fmap
{-# INLINE (.^) #-}
(.^) :: (Functor f, Arrow arrow) =>
arrow b c -> f (arrow a b) -> f (arrow a c)
(.^) f = fmap (f <<<)
{-# INLINE ($#) #-}
($#) :: (Functor f) => f (a -> b) -> a -> f b
($#) f x = fmap ($x) f
{-# INLINE liftP #-}
liftP :: (Applicative f) =>
f (a -> b) -> f a -> f b
liftP = ($:)
{-# INLINE liftP2 #-}
liftP2 :: (Applicative f) =>
f (a -> b -> c) -> f a -> f b -> f c
liftP2 f a b = f $: a $: b
{-# INLINE liftP3 #-}
liftP3 :: (Applicative f) =>
f (a -> b -> c -> d) -> f a -> f b -> f c -> f d
liftP3 f a b c = f $: a $: b $: c
{-# INLINE liftP4 #-}
liftP4 :: (Applicative f) =>
f (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
liftP4 f a b c d = f $: a $: b $: c $: d