{-# OPTIONS_GHC -fno-warn-orphans #-} module Pandora.Paradigm.Primary.Algebraic.Exponential where import Pandora.Pattern.Semigroupoid (Semigroupoid ((.))) import Pandora.Pattern.Category (Category (($), (#), identity)) import Pandora.Pattern.Functor.Covariant (Covariant ((-<$>-))) import Pandora.Pattern.Functor.Contravariant (Contravariant ((->$<-))) import Pandora.Pattern.Functor.Distributive (Distributive ((-<<))) import Pandora.Pattern.Functor.Pointable (Pointable (point)) import Pandora.Pattern.Functor.Bindable (Bindable ((=<<))) import Pandora.Pattern.Functor.Representable (Representable (Representation, (<#>), tabulate)) import Pandora.Pattern.Functor.Divariant (Divariant ((>->))) import Pandora.Pattern.Object.Semigroup (Semigroup ((+))) import Pandora.Pattern.Object.Ringoid (Ringoid ((*))) import Pandora.Paradigm.Primary.Transformer.Flip (Flip (Flip)) infixr 2 !. infixr 7 -.#..- infixr 9 % infixl 1 & instance Semigroupoid (->) where b -> c f . :: (b -> c) -> (a -> b) -> a -> c . a -> b g = \a x -> b -> c f (a -> b g a x) instance Category (->) where identity :: a -> a identity a x = a x instance Covariant ((->) a) (->) (->) where -<$>- :: (a -> b) -> (a -> a) -> a -> b (-<$>-) = (a -> b) -> (a -> a) -> a -> b forall (m :: * -> * -> *) b c a. Semigroupoid m => m b c -> m a b -> m a c (.) instance Contravariant (Flip (->) a) (->) (->) where a -> b f ->$<- :: (a -> b) -> Flip (->) a b -> Flip (->) a a ->$<- Flip b -> a g = (a -> a) -> Flip (->) a a forall (v :: * -> * -> *) a e. v e a -> Flip v a e Flip ((a -> a) -> Flip (->) a a) -> (a -> a) -> Flip (->) a a forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b) $ b -> a g (b -> a) -> (a -> b) -> a -> a forall (m :: * -> * -> *) b c a. Semigroupoid m => m b c -> m a b -> m a c . a -> b f instance Distributive ((->) e) (->) (->) where a -> e -> b f -<< :: (a -> e -> b) -> u a -> e -> u b -<< u a g = \e e -> (a -> e -> b f (a -> e -> b) -> e -> a -> b forall a b c. (a -> b -> c) -> b -> a -> c % e e) (a -> b) -> u a -> u b forall (t :: * -> *) (source :: * -> * -> *) (target :: * -> * -> *) a b. Covariant t source target => source a b -> target (t a) (t b) -<$>- u a g instance Pointable ((->) e) (->) where point :: a -> e -> a point = a -> e -> a forall a b. a -> b -> a (!.) instance Bindable ((->) e) (->) where a -> e -> b f =<< :: (a -> e -> b) -> (e -> a) -> e -> b =<< e -> a g = \e x -> a -> e -> b f (a -> e -> b) -> a -> e -> b forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b) # e -> a g e x (e -> b) -> e -> b forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b) # e x instance Representable ((->) e) where type Representation ((->) e) = e <#> :: Representation ((->) e) -> a <:= (->) e (<#>) = ((e -> a) -> e -> a forall (m :: * -> * -> *) a. Category m => m a a identity ((e -> a) -> e -> a) -> e -> a <:= (->) e forall a b c. (a -> b -> c) -> b -> a -> c %) tabulate :: (Representation ((->) e) -> a) -> e -> a tabulate = (Representation ((->) e) -> a) -> e -> a forall (m :: * -> * -> *) a. Category m => m a a identity instance Divariant ((->)) (->) (->) (->) where >-> :: (a -> b) -> (c -> d) -> (b -> c) -> a -> d (>->) a -> b ab c -> d cd b -> c bc = c -> d cd (c -> d) -> (a -> c) -> a -> d forall (m :: * -> * -> *) b c a. Semigroupoid m => m b c -> m a b -> m a c . b -> c bc (b -> c) -> (a -> b) -> a -> c forall (m :: * -> * -> *) b c a. Semigroupoid m => m b c -> m a b -> m a c . a -> b ab instance Semigroup r => Semigroup (e -> r) where e -> r f + :: (e -> r) -> (e -> r) -> e -> r + e -> r g = \e e -> e -> r f e e r -> r -> r forall a. Semigroup a => a -> a -> a + e -> r g e e instance Ringoid r => Ringoid (e -> r) where e -> r f * :: (e -> r) -> (e -> r) -> e -> r * e -> r g = \e e -> e -> r f e e r -> r -> r forall a. Ringoid a => a -> a -> a * e -> r g e e (-.#..-) :: (Covariant (v a) (->) target, Semigroupoid v) => v c d -> target (v a (v b c)) (v a (v b d)) -.#..- :: v c d -> target (v a (v b c)) (v a (v b d)) (-.#..-) v c d f = (v b c -> v b d) -> target (v a (v b c)) (v a (v b d)) forall (t :: * -> *) (source :: * -> * -> *) (target :: * -> * -> *) a b. Covariant t source target => source a b -> target (t a) (t b) (-<$>-) (v c d f v c d -> v b c -> v b d forall (m :: * -> * -> *) b c a. Semigroupoid m => m b c -> m a b -> m a c .) {-# INLINE (!.) #-} (!.) :: a -> b -> a a x !. :: a -> b -> a !. b _ = a x {-# INLINE (!..) #-} (!..) :: a -> b -> c -> a !.. :: a -> b -> c -> a (!..) a x b _ c _ = a x {-# INLINE (!...) #-} (!...) :: a -> b -> c -> d -> a !... :: a -> b -> c -> d -> a (!...) a x b _ c _ d _ = a x {-# INLINE (%) #-} (%) :: (a -> b -> c) -> b -> a -> c % :: (a -> b -> c) -> b -> a -> c (%) a -> b -> c f b x a y = a -> b -> c f a y b x {-# INLINE (&) #-} (&) :: a -> (a -> b) -> b a x & :: a -> (a -> b) -> b & a -> b f = a -> b f a x fix :: (a -> a) -> a fix :: (a -> a) -> a fix a -> a f = let x :: a x = a -> a f a x in a x