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