{-# OPTIONS_GHC -fno-warn-orphans #-} module Pandora.Paradigm.Structure (module Exports) where import Pandora.Paradigm.Structure.Ability as Exports import Pandora.Paradigm.Structure.Interface as Exports import Pandora.Paradigm.Structure.Rose as Exports import Pandora.Paradigm.Structure.Splay as Exports import Pandora.Paradigm.Structure.Binary as Exports import Pandora.Paradigm.Structure.Stack as Exports import Pandora.Paradigm.Structure.Stream as Exports import Pandora.Pattern (($), (.), extract) import Pandora.Paradigm.Controlflow.Effect.Interpreted (run, unite) import Pandora.Paradigm.Inventory.Store (Store (Store)) import Pandora.Paradigm.Primary.Object.Boolean (Boolean (True, False)) import Pandora.Paradigm.Primary.Functor.Delta (Delta ((:^:))) import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Just)) import Pandora.Paradigm.Primary.Functor.Predicate (Predicate (Predicate)) import Pandora.Paradigm.Primary.Functor.Product (Product ((:*:)), type (:*:), attached) import Pandora.Paradigm.Primary.Functor.Tagged (Tagged (Tag)) import Pandora.Paradigm.Primary.Functor.Wye (Wye (Left, Right)) import Pandora.Paradigm.Primary.Transformer.Tap (Tap (Tap)) import Pandora.Paradigm.Schemes.TU (type (<:.>)) instance Monotonic s a => Monotonic s (s :*: a) where reduce :: (s -> r -> r) -> r -> (s :*: a) -> r reduce s -> r -> r f r r s :*: a x = (s -> r -> r) -> r -> a -> r forall a e r. Monotonic a e => (a -> r -> r) -> r -> e -> r reduce s -> r -> r f (s -> r -> r f ((s :*: a) -> s forall a b. (a :*: b) -> a attached s :*: a x) r r) (a -> r) -> a -> r forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ a <-| Product s forall (t :: * -> *) a. Extractable t => a <-| t extract s :*: a x instance Nullable Maybe where null :: (Predicate :. Maybe) := a null = (Maybe a -> Boolean) -> (Predicate :. Maybe) := a forall a. (a -> Boolean) -> Predicate a Predicate ((Maybe a -> Boolean) -> (Predicate :. Maybe) := a) -> (Maybe a -> Boolean) -> (Predicate :. Maybe) := a forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ \case { Just a _ -> Boolean True ; Maybe a _ -> Boolean False } instance Substructure Left (Product s) a where type Substructural Left (Product s) a = s substructure :: Tagged 'Left (Product s a) :-. Substructural 'Left (Product s) a substructure (Product s a <-| Tagged 'Left forall (t :: * -> *) a. Extractable t => a <-| t extract -> s s :*: a x) = ((Product s :. (->) s) := Tagged 'Left (Product s a)) -> Store s (Tagged 'Left (Product s a)) forall s a. (((:*:) s :. (->) s) := a) -> Store s a Store (((Product s :. (->) s) := Tagged 'Left (Product s a)) -> Store s (Tagged 'Left (Product s a))) -> ((Product s :. (->) s) := Tagged 'Left (Product s a)) -> Store s (Tagged 'Left (Product s a)) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ s s s -> (s -> Tagged 'Left (Product s a)) -> (Product s :. (->) s) := Tagged 'Left (Product s a) forall s a. s -> a -> Product s a :*: Product s a -> Tagged 'Left (Product s a) forall k (tag :: k) a. a -> Tagged tag a Tag (Product s a -> Tagged 'Left (Product s a)) -> (s -> Product s a) -> s -> Tagged 'Left (Product s a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (s -> a -> Product s a forall s a. s -> a -> Product s a :*: a x) instance Substructure Right (Product s) a where type Substructural Right (Product s) a = a substructure :: Tagged 'Right (Product s a) :-. Substructural 'Right (Product s) a substructure (Product s a <-| Tagged 'Right forall (t :: * -> *) a. Extractable t => a <-| t extract -> s s :*: a x) = (((:*:) a :. (->) a) := Tagged 'Right (Product s a)) -> Store a (Tagged 'Right (Product s a)) forall s a. (((:*:) s :. (->) s) := a) -> Store s a Store ((((:*:) a :. (->) a) := Tagged 'Right (Product s a)) -> Store a (Tagged 'Right (Product s a))) -> (((:*:) a :. (->) a) := Tagged 'Right (Product s a)) -> Store a (Tagged 'Right (Product s a)) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ a x a -> (a -> Tagged 'Right (Product s a)) -> ((:*:) a :. (->) a) := Tagged 'Right (Product s a) forall s a. s -> a -> Product s a :*: Product s a -> Tagged 'Right (Product s a) forall k (tag :: k) a. a -> Tagged tag a Tag (Product s a -> Tagged 'Right (Product s a)) -> (a -> Product s a) -> a -> Tagged 'Right (Product s a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (s s s -> a -> Product s a forall s a. s -> a -> Product s a :*:) instance Substructure Left Delta a where type Substructural Left Delta a = a substructure :: Tagged 'Left (Delta a) :-. Substructural 'Left Delta a substructure (Delta a <-| Tagged 'Left forall (t :: * -> *) a. Extractable t => a <-| t extract -> a l :^: a r) = (((:*:) a :. (->) a) := Tagged 'Left (Delta a)) -> Store a (Tagged 'Left (Delta a)) forall s a. (((:*:) s :. (->) s) := a) -> Store s a Store ((((:*:) a :. (->) a) := Tagged 'Left (Delta a)) -> Store a (Tagged 'Left (Delta a))) -> (((:*:) a :. (->) a) := Tagged 'Left (Delta a)) -> Store a (Tagged 'Left (Delta a)) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ a l a -> (a -> Tagged 'Left (Delta a)) -> ((:*:) a :. (->) a) := Tagged 'Left (Delta a) forall s a. s -> a -> Product s a :*: Delta a -> Tagged 'Left (Delta a) forall k (tag :: k) a. a -> Tagged tag a Tag (Delta a -> Tagged 'Left (Delta a)) -> (a -> Delta a) -> a -> Tagged 'Left (Delta a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (a -> a -> Delta a forall a. a -> a -> Delta a :^: a r) instance Substructure Right Delta a where type Substructural Right Delta a = a substructure :: Tagged 'Right (Delta a) :-. Substructural 'Right Delta a substructure (Delta a <-| Tagged 'Right forall (t :: * -> *) a. Extractable t => a <-| t extract -> a l :^: a r) = (((:*:) a :. (->) a) := Tagged 'Right (Delta a)) -> Store a (Tagged 'Right (Delta a)) forall s a. (((:*:) s :. (->) s) := a) -> Store s a Store ((((:*:) a :. (->) a) := Tagged 'Right (Delta a)) -> Store a (Tagged 'Right (Delta a))) -> (((:*:) a :. (->) a) := Tagged 'Right (Delta a)) -> Store a (Tagged 'Right (Delta a)) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ a r a -> (a -> Tagged 'Right (Delta a)) -> ((:*:) a :. (->) a) := Tagged 'Right (Delta a) forall s a. s -> a -> Product s a :*: Delta a -> Tagged 'Right (Delta a) forall k (tag :: k) a. a -> Tagged tag a Tag (Delta a -> Tagged 'Right (Delta a)) -> (a -> Delta a) -> a -> Tagged 'Right (Delta a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (a l a -> a -> Delta a forall a. a -> a -> Delta a :^:) instance Substructure Left (Delta <:.> t) a where type Substructural Left (Delta <:.> t) a = t a substructure :: Tagged 'Left ((<:.>) Delta t a) :-. Substructural 'Left (Delta <:.> t) a substructure ((<:.>) Delta t a -> Delta (t a) forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run ((<:.>) Delta t a -> Delta (t a)) -> (Tagged 'Left ((<:.>) Delta t a) -> (<:.>) Delta t a) -> Tagged 'Left ((<:.>) Delta t a) -> Delta (t a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Tagged 'Left ((<:.>) Delta t a) -> (<:.>) Delta t a forall (t :: * -> *) a. Extractable t => a <-| t extract -> t a l :^: t a r) = (((:*:) (t a) :. (->) (t a)) := Tagged 'Left ((<:.>) Delta t a)) -> Store (t a) (Tagged 'Left ((<:.>) Delta t a)) forall s a. (((:*:) s :. (->) s) := a) -> Store s a Store ((((:*:) (t a) :. (->) (t a)) := Tagged 'Left ((<:.>) Delta t a)) -> Store (t a) (Tagged 'Left ((<:.>) Delta t a))) -> (((:*:) (t a) :. (->) (t a)) := Tagged 'Left ((<:.>) Delta t a)) -> Store (t a) (Tagged 'Left ((<:.>) Delta t a)) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ t a r t a -> (t a -> Tagged 'Left ((<:.>) Delta t a)) -> ((:*:) (t a) :. (->) (t a)) := Tagged 'Left ((<:.>) Delta t a) forall s a. s -> a -> Product s a :*: (<:.>) Delta t a -> Tagged 'Left ((<:.>) Delta t a) forall k (tag :: k) a. a -> Tagged tag a Tag ((<:.>) Delta t a -> Tagged 'Left ((<:.>) Delta t a)) -> (t a -> (<:.>) Delta t a) -> t a -> Tagged 'Left ((<:.>) Delta t a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Delta (t a) -> (<:.>) Delta t a forall (t :: * -> *) a. Interpreted t => Primary t a -> t a unite (Delta (t a) -> (<:.>) Delta t a) -> (t a -> Delta (t a)) -> t a -> (<:.>) Delta t a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (t a l t a -> t a -> Delta (t a) forall a. a -> a -> Delta a :^:) instance Substructure Right (Delta <:.> t) a where type Substructural Right (Delta <:.> t) a = t a substructure :: Tagged 'Right ((<:.>) Delta t a) :-. Substructural 'Right (Delta <:.> t) a substructure ((<:.>) Delta t a -> Delta (t a) forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run ((<:.>) Delta t a -> Delta (t a)) -> (Tagged 'Right ((<:.>) Delta t a) -> (<:.>) Delta t a) -> Tagged 'Right ((<:.>) Delta t a) -> Delta (t a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Tagged 'Right ((<:.>) Delta t a) -> (<:.>) Delta t a forall (t :: * -> *) a. Extractable t => a <-| t extract -> t a l :^: t a r) = (((:*:) (t a) :. (->) (t a)) := Tagged 'Right ((<:.>) Delta t a)) -> Store (t a) (Tagged 'Right ((<:.>) Delta t a)) forall s a. (((:*:) s :. (->) s) := a) -> Store s a Store ((((:*:) (t a) :. (->) (t a)) := Tagged 'Right ((<:.>) Delta t a)) -> Store (t a) (Tagged 'Right ((<:.>) Delta t a))) -> (((:*:) (t a) :. (->) (t a)) := Tagged 'Right ((<:.>) Delta t a)) -> Store (t a) (Tagged 'Right ((<:.>) Delta t a)) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ t a l t a -> (t a -> Tagged 'Right ((<:.>) Delta t a)) -> ((:*:) (t a) :. (->) (t a)) := Tagged 'Right ((<:.>) Delta t a) forall s a. s -> a -> Product s a :*: (<:.>) Delta t a -> Tagged 'Right ((<:.>) Delta t a) forall k (tag :: k) a. a -> Tagged tag a Tag ((<:.>) Delta t a -> Tagged 'Right ((<:.>) Delta t a)) -> (t a -> (<:.>) Delta t a) -> t a -> Tagged 'Right ((<:.>) Delta t a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Delta (t a) -> (<:.>) Delta t a forall (t :: * -> *) a. Interpreted t => Primary t a -> t a unite (Delta (t a) -> (<:.>) Delta t a) -> (t a -> Delta (t a)) -> t a -> (<:.>) Delta t a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (t a -> t a -> Delta (t a) forall a. a -> a -> Delta a :^: t a r) instance Substructure Tail (Tap t) a where type Substructural Tail (Tap t) a = t a substructure :: Tagged 'Tail (Tap t a) :-. Substructural 'Tail (Tap t) a substructure (Tap t a <-| Tagged 'Tail forall (t :: * -> *) a. Extractable t => a <-| t extract -> Tap a x t a xs) = (((:*:) (t a) :. (->) (t a)) := Tagged 'Tail (Tap t a)) -> Store (t a) (Tagged 'Tail (Tap t a)) forall s a. (((:*:) s :. (->) s) := a) -> Store s a Store ((((:*:) (t a) :. (->) (t a)) := Tagged 'Tail (Tap t a)) -> Store (t a) (Tagged 'Tail (Tap t a))) -> (((:*:) (t a) :. (->) (t a)) := Tagged 'Tail (Tap t a)) -> Store (t a) (Tagged 'Tail (Tap t a)) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ t a xs t a -> (t a -> Tagged 'Tail (Tap t a)) -> ((:*:) (t a) :. (->) (t a)) := Tagged 'Tail (Tap t a) forall s a. s -> a -> Product s a :*: Tap t a -> Tagged 'Tail (Tap t a) forall k (tag :: k) a. a -> Tagged tag a Tag (Tap t a -> Tagged 'Tail (Tap t a)) -> (t a -> Tap t a) -> t a -> Tagged 'Tail (Tap t a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . a -> t a -> Tap t a forall (t :: * -> *) a. a -> t a -> Tap t a Tap a x