module Synthesizer.ApplicativeUtility where
import Control.Applicative (Applicative, pure, (<*>), (<$>), liftA2, )
import Data.Traversable (Traversable, sequenceA, )
import Control.Monad.Fix (fix, )
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
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) => f (b -> c) -> f (a -> b) -> f (a -> c)
(.:) = liftA2 (.)
($^) :: (Functor f) => (a -> b) -> f a -> f b
($^) = fmap
(.^) :: (Functor f) => (b -> c) -> f (a -> b) -> f (a -> c)
(.^) f = fmap (f.)
($#) :: (Applicative f) => f (a -> b) -> a -> f b
($#) f x = f $: pure x
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