module Music.Theory.Function where
import Data.Bifunctor
import Data.Function
type UOp t = t -> t
type BinOp t = t -> t -> t
recur_n :: Integral n => n -> (t -> t) -> t -> t
recur_n :: forall n t. Integral n => n -> (t -> t) -> t -> t
recur_n n
n t -> t
f t
x = if n
n forall a. Ord a => a -> a -> Bool
< n
1 then t
x else forall n t. Integral n => n -> (t -> t) -> t -> t
recur_n (n
n forall a. Num a => a -> a -> a
- n
1) t -> t
f (t -> t
f t
x)
const2 :: a -> b -> c -> a
const2 :: forall a b c. a -> b -> c -> a
const2 a
x b
_ c
_ = a
x
predicate_and :: (t -> Bool) -> (t -> Bool) -> t -> Bool
predicate_and :: forall t. (t -> Bool) -> (t -> Bool) -> t -> Bool
predicate_and t -> Bool
f t -> Bool
g t
x = t -> Bool
f t
x Bool -> Bool -> Bool
&& t -> Bool
g t
x
predicate_all :: [t -> Bool] -> t -> Bool
predicate_all :: forall t. [t -> Bool] -> t -> Bool
predicate_all = forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 forall t. (t -> Bool) -> (t -> Bool) -> t -> Bool
predicate_and
predicate_or :: (t -> Bool) -> (t -> Bool) -> t -> Bool
predicate_or :: forall t. (t -> Bool) -> (t -> Bool) -> t -> Bool
predicate_or t -> Bool
f t -> Bool
g t
x = t -> Bool
f t
x Bool -> Bool -> Bool
|| t -> Bool
g t
x
predicate_any :: [t -> Bool] -> t -> Bool
predicate_any :: forall t. [t -> Bool] -> t -> Bool
predicate_any [t -> Bool]
p t
x = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (forall a b. (a -> b) -> a -> b
$ t
x) [t -> Bool]
p
eq_on :: Eq t => (u -> t) -> u -> u -> Bool
eq_on :: forall t u. Eq t => (u -> t) -> u -> u -> Bool
eq_on u -> t
f = forall a. Eq a => a -> a -> Bool
(==) forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` u -> t
f
fmap2 :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
fmap2 :: forall (f :: * -> *) (g :: * -> *) a b.
(Functor f, Functor g) =>
(a -> b) -> f (g a) -> f (g b)
fmap2 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
fmap3 :: (Functor f, Functor g, Functor h) => (a -> b) -> f (g (h a)) -> f (g (h b))
fmap3 :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Functor f, Functor g, Functor h) =>
(a -> b) -> f (g (h a)) -> f (g (h b))
fmap3 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) (g :: * -> *) a b.
(Functor f, Functor g) =>
(a -> b) -> f (g a) -> f (g b)
fmap2
fmap4 :: (Functor f, Functor g, Functor h, Functor i) => (a -> b) -> f (g (h (i a))) -> f (g (h (i b)))
fmap4 :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i) =>
(a -> b) -> f (g (h (i a))) -> f (g (h (i b)))
fmap4 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Functor f, Functor g, Functor h) =>
(a -> b) -> f (g (h a)) -> f (g (h b))
fmap3
fmap5 :: (Functor f, Functor g, Functor h, Functor i, Functor j) => (a -> b) -> f (g (h (i (j a)))) -> f (g (h (i (j b))))
fmap5 :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *)
(j :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i, Functor j) =>
(a -> b) -> f (g (h (i (j a)))) -> f (g (h (i (j b))))
fmap5 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i) =>
(a -> b) -> f (g (h (i a))) -> f (g (h (i b)))
fmap4
fmap6 :: (Functor f, Functor g, Functor h, Functor i, Functor j, Functor k) => (a -> b) -> f (g (h (i (j (k a))))) -> f (g (h (i (j (k b)))))
fmap6 :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *)
(j :: * -> *) (k :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i, Functor j,
Functor k) =>
(a -> b) -> f (g (h (i (j (k a))))) -> f (g (h (i (j (k b)))))
fmap6 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *)
(j :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i, Functor j) =>
(a -> b) -> f (g (h (i (j a)))) -> f (g (h (i (j b))))
fmap5
infixr 8 .:, .::, .:::, .::::, .:::::
(.:) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
.: :: forall (f :: * -> *) (g :: * -> *) a b.
(Functor f, Functor g) =>
(a -> b) -> f (g a) -> f (g b)
(.:) = forall (f :: * -> *) (g :: * -> *) a b.
(Functor f, Functor g) =>
(a -> b) -> f (g a) -> f (g b)
fmap2
(.::) :: (Functor f, Functor g, Functor h) => (a -> b) -> f (g (h a)) -> f (g (h b))
.:: :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Functor f, Functor g, Functor h) =>
(a -> b) -> f (g (h a)) -> f (g (h b))
(.::) = forall (f :: * -> *) (g :: * -> *) (h :: * -> *) a b.
(Functor f, Functor g, Functor h) =>
(a -> b) -> f (g (h a)) -> f (g (h b))
fmap3
(.:::) :: (Functor f, Functor g, Functor h,Functor i) => (a -> b) -> f (g (h (i a))) -> f (g (h (i b)))
.::: :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i) =>
(a -> b) -> f (g (h (i a))) -> f (g (h (i b)))
(.:::) = forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i) =>
(a -> b) -> f (g (h (i a))) -> f (g (h (i b)))
fmap4
(.::::) :: (Functor f, Functor g, Functor h,Functor i,Functor j) => (a -> b) -> f (g (h (i (j a)))) -> f (g (h (i (j b))))
.:::: :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *)
(j :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i, Functor j) =>
(a -> b) -> f (g (h (i (j a)))) -> f (g (h (i (j b))))
(.::::) = forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *)
(j :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i, Functor j) =>
(a -> b) -> f (g (h (i (j a)))) -> f (g (h (i (j b))))
fmap5
(.:::::) :: (Functor f, Functor g, Functor h,Functor i,Functor j,Functor k) => (a -> b) -> f (g (h (i (j (k a))))) -> f (g (h (i (j (k b)))))
.::::: :: forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *)
(j :: * -> *) (k :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i, Functor j,
Functor k) =>
(a -> b) -> f (g (h (i (j (k a))))) -> f (g (h (i (j (k b)))))
(.:::::) = forall (f :: * -> *) (g :: * -> *) (h :: * -> *) (i :: * -> *)
(j :: * -> *) (k :: * -> *) a b.
(Functor f, Functor g, Functor h, Functor i, Functor j,
Functor k) =>
(a -> b) -> f (g (h (i (j (k a))))) -> f (g (h (i (j (k b)))))
fmap6
bimap1f :: Bifunctor p => (a -> b) -> p a a -> p b b
bimap1f :: forall (p :: * -> * -> *) a b.
Bifunctor p =>
(a -> b) -> p a a -> p b b
bimap1f a -> b
f = forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap a -> b
f a -> b
f
bimap1 :: (t -> u) -> (t,t) -> (u,u)
bimap1 :: forall t u. (t -> u) -> (t, t) -> (u, u)
bimap1 = forall (p :: * -> * -> *) a b.
Bifunctor p =>
(a -> b) -> p a a -> p b b
bimap1f