{-# OPTIONS_GHC -fno-warn-orphans #-} module Pandora.Paradigm.Structure.Stream where import Pandora.Core.Functor (type (:=>)) import Pandora.Pattern.Category ((.), ($)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Pointable (point) import Pandora.Pattern.Functor.Extractable (extract) import Pandora.Pattern.Functor.Extendable (Extendable ((=>>))) import Pandora.Paradigm.Controlflow.Effect.Interpreted (run) import Pandora.Paradigm.Primary.Functor.Product (Product ((:*:)), type (:*:)) import Pandora.Paradigm.Primary.Functor.Identity (Identity (Identity)) import Pandora.Paradigm.Primary.Functor.Wye (Wye (Left, Right)) import Pandora.Paradigm.Primary.Transformer.Construction (Construction (Construct), deconstruct, (.-+)) import Pandora.Paradigm.Primary.Transformer.Tap (Tap (Tap)) import Pandora.Paradigm.Structure.Ability.Morphable (Morphable (Morphing, morphing), Morph (Rotate), morph) import Pandora.Paradigm.Structure.Ability.Zipper (Zipper) import Pandora.Paradigm.Schemes.T_U (T_U (T_U), type (<:.:>)) type Stream = Construction Identity type instance Zipper Stream = Tap ((:*:) <:.:> Stream) instance Morphable (Rotate Left) (Tap ((:*:) <:.:> Stream)) where type Morphing (Rotate Left) (Tap ((:*:) <:.:> Stream)) = Tap ((:*:) <:.:> Stream) morphing :: (<:.>) (Tagged ('Rotate 'Left)) (Tap ((:*:) <:.:> Stream)) a -> Morphing ('Rotate 'Left) (Tap ((:*:) <:.:> Stream)) a morphing (Tap ((:*:) <:.:> Stream) a <:= Tagged ('Rotate 'Left) forall (t :: * -> *) a. Extractable t => a <:= t extract (Tap ((:*:) <:.:> Stream) a <:= Tagged ('Rotate 'Left)) -> ((<:.>) (Tagged ('Rotate 'Left)) (Tap ((:*:) <:.:> Stream)) a -> Tagged ('Rotate 'Left) (Tap ((:*:) <:.:> Stream) a)) -> (<:.>) (Tagged ('Rotate 'Left)) (Tap ((:*:) <:.:> Stream)) a -> Tap ((:*:) <:.:> Stream) a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (<:.>) (Tagged ('Rotate 'Left)) (Tap ((:*:) <:.:> Stream)) a -> Tagged ('Rotate 'Left) (Tap ((:*:) <:.:> Stream) a) forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run -> Tap a x (T_U (Construction Identity a bs :*: Construction Identity a fs))) = a -> T_U Covariant Covariant Stream (:*:) Stream a -> Tap ((:*:) <:.:> Stream) a forall (t :: * -> *) a. a -> t a -> Tap t a Tap (a <:= Stream forall (t :: * -> *) a. Extractable t => a <:= t extract Construction Identity a bs) (T_U Covariant Covariant Stream (:*:) Stream a -> Tap ((:*:) <:.:> Stream) a) -> (Product (Construction Identity a) (Construction Identity a) -> T_U Covariant Covariant Stream (:*:) Stream a) -> Product (Construction Identity a) (Construction Identity a) -> Tap ((:*:) <:.:> Stream) a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Product (Construction Identity a) (Construction Identity a) -> T_U Covariant Covariant Stream (:*:) Stream a forall k k k k k (ct :: k) (cu :: k) (t :: k -> k) (p :: k -> k -> *) (u :: k -> k) (a :: k). p (t a) (u a) -> T_U ct cu t p u a T_U (Product (Construction Identity a) (Construction Identity a) -> Tap ((:*:) <:.:> Stream) a) -> Product (Construction Identity a) (Construction Identity a) -> Tap ((:*:) <:.:> Stream) a forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ Construction Identity a <:= Identity forall (t :: * -> *) a. Extractable t => a <:= t extract (Construction Identity a -> (Identity :. Stream) := a forall (t :: * -> *) a. Construction t a -> (t :. Construction t) := a deconstruct Construction Identity a bs) Construction Identity a -> Construction Identity a -> Product (Construction Identity a) (Construction Identity a) forall s a. s -> a -> Product s a :*: a -> Construction Identity a <:= Identity forall (t :: * -> *) a. a -> ((t :. Construction t) := a) -> Construction t a Construct a x (Construction Identity a -> (Identity :. Stream) := a forall (t :: * -> *) a. Pointable t => a :=> t point Construction Identity a fs) instance Morphable (Rotate Right) (Tap ((:*:) <:.:> Stream)) where type Morphing (Rotate Right) (Tap ((:*:) <:.:> Stream)) = Tap ((:*:) <:.:> Stream) morphing :: (<:.>) (Tagged ('Rotate 'Right)) (Tap ((:*:) <:.:> Stream)) a -> Morphing ('Rotate 'Right) (Tap ((:*:) <:.:> Stream)) a morphing (Tap ((:*:) <:.:> Stream) a <:= Tagged ('Rotate 'Right) forall (t :: * -> *) a. Extractable t => a <:= t extract (Tap ((:*:) <:.:> Stream) a <:= Tagged ('Rotate 'Right)) -> ((<:.>) (Tagged ('Rotate 'Right)) (Tap ((:*:) <:.:> Stream)) a -> Tagged ('Rotate 'Right) (Tap ((:*:) <:.:> Stream) a)) -> (<:.>) (Tagged ('Rotate 'Right)) (Tap ((:*:) <:.:> Stream)) a -> Tap ((:*:) <:.:> Stream) a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (<:.>) (Tagged ('Rotate 'Right)) (Tap ((:*:) <:.:> Stream)) a -> Tagged ('Rotate 'Right) (Tap ((:*:) <:.:> Stream) a) forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run -> Tap a x (T_U (Construction Identity a bs :*: Construction Identity a fs))) = a -> T_U Covariant Covariant Stream (:*:) Stream a -> Tap ((:*:) <:.:> Stream) a forall (t :: * -> *) a. a -> t a -> Tap t a Tap (a <:= Stream forall (t :: * -> *) a. Extractable t => a <:= t extract Construction Identity a fs) (T_U Covariant Covariant Stream (:*:) Stream a -> Tap ((:*:) <:.:> Stream) a) -> (Product (Construction Identity a) (Construction Identity a) -> T_U Covariant Covariant Stream (:*:) Stream a) -> Product (Construction Identity a) (Construction Identity a) -> Tap ((:*:) <:.:> Stream) a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Product (Construction Identity a) (Construction Identity a) -> T_U Covariant Covariant Stream (:*:) Stream a forall k k k k k (ct :: k) (cu :: k) (t :: k -> k) (p :: k -> k -> *) (u :: k -> k) (a :: k). p (t a) (u a) -> T_U ct cu t p u a T_U (Product (Construction Identity a) (Construction Identity a) -> Tap ((:*:) <:.:> Stream) a) -> Product (Construction Identity a) (Construction Identity a) -> Tap ((:*:) <:.:> Stream) a forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ a -> ((Identity :. Stream) := a) -> Construction Identity a forall (t :: * -> *) a. a -> ((t :. Construction t) := a) -> Construction t a Construct a x (Construction Identity a :=> Identity forall (t :: * -> *) a. Pointable t => a :=> t point Construction Identity a bs) Construction Identity a -> Construction Identity a -> Product (Construction Identity a) (Construction Identity a) forall s a. s -> a -> Product s a :*: ((Identity :. Stream) := a) -> Construction Identity a forall (t :: * -> *) a. Extractable t => a <:= t extract (Construction Identity a :=> Identity forall (t :: * -> *) a. Construction t a -> (t :. Construction t) := a deconstruct Construction Identity a fs) instance {-# OVERLAPS #-} Extendable (Tap ((:*:) <:.:> Stream)) where Tap ((:*:) <:.:> Stream) a z =>> :: Tap ((:*:) <:.:> Stream) a -> (Tap ((:*:) <:.:> Stream) a -> b) -> Tap ((:*:) <:.:> Stream) b =>> Tap ((:*:) <:.:> Stream) a -> b f = let move :: (Tap ((:*:) <:.:> Stream) a -> Tap ((:*:) <:.:> Stream) a) -> Construction Identity (Tap ((:*:) <:.:> Stream) a) move Tap ((:*:) <:.:> Stream) a -> Tap ((:*:) <:.:> Stream) a rtt = Construction Identity (Tap ((:*:) <:.:> Stream) a) <:= Identity forall (t :: * -> *) a. Extractable t => a <:= t extract (Construction Identity (Tap ((:*:) <:.:> Stream) a) <:= Identity) -> (Construction Identity (Tap ((:*:) <:.:> Stream) a) -> Identity (Construction Identity (Tap ((:*:) <:.:> Stream) a))) -> Construction Identity (Tap ((:*:) <:.:> Stream) a) -> Construction Identity (Tap ((:*:) <:.:> Stream) a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Construction Identity (Tap ((:*:) <:.:> Stream) a) -> Identity (Construction Identity (Tap ((:*:) <:.:> Stream) a)) forall (t :: * -> *) a. Construction t a -> (t :. Construction t) := a deconstruct (Construction Identity (Tap ((:*:) <:.:> Stream) a) -> Construction Identity (Tap ((:*:) <:.:> Stream) a)) -> Construction Identity (Tap ((:*:) <:.:> Stream) a) -> Construction Identity (Tap ((:*:) <:.:> Stream) a) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ Tap ((:*:) <:.:> Stream) a -> Identity (Tap ((:*:) <:.:> Stream) a) forall (t :: * -> *) a. Pointable t => a :=> t point (Tap ((:*:) <:.:> Stream) a -> Identity (Tap ((:*:) <:.:> Stream) a)) -> (Tap ((:*:) <:.:> Stream) a -> Tap ((:*:) <:.:> Stream) a) -> Tap ((:*:) <:.:> Stream) a -> Identity (Tap ((:*:) <:.:> Stream) a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Tap ((:*:) <:.:> Stream) a -> Tap ((:*:) <:.:> Stream) a rtt (Tap ((:*:) <:.:> Stream) a -> Identity (Tap ((:*:) <:.:> Stream) a)) -> Tap ((:*:) <:.:> Stream) a :=> Stream forall (t :: * -> *) a. Covariant t => (a :=> t) -> a :=> Construction t .-+ Tap ((:*:) <:.:> Stream) a z in Tap ((:*:) <:.:> Stream) a -> b f (Tap ((:*:) <:.:> Stream) a -> b) -> Tap ((:*:) <:.:> Stream) (Tap ((:*:) <:.:> Stream) a) -> Tap ((:*:) <:.:> Stream) b forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> Tap ((:*:) <:.:> Stream) a -> (<:.:>) (:*:) Stream (Tap ((:*:) <:.:> Stream) a) -> Tap ((:*:) <:.:> Stream) (Tap ((:*:) <:.:> Stream) a) forall (t :: * -> *) a. a -> t a -> Tap t a Tap Tap ((:*:) <:.:> Stream) a z (Product (Construction Identity (Tap ((:*:) <:.:> Stream) a)) (Construction Identity (Tap ((:*:) <:.:> Stream) a)) -> (<:.:>) (:*:) Stream (Tap ((:*:) <:.:> Stream) a) forall k k k k k (ct :: k) (cu :: k) (t :: k -> k) (p :: k -> k -> *) (u :: k -> k) (a :: k). p (t a) (u a) -> T_U ct cu t p u a T_U (Product (Construction Identity (Tap ((:*:) <:.:> Stream) a)) (Construction Identity (Tap ((:*:) <:.:> Stream) a)) -> (<:.:>) (:*:) Stream (Tap ((:*:) <:.:> Stream) a)) -> Product (Construction Identity (Tap ((:*:) <:.:> Stream) a)) (Construction Identity (Tap ((:*:) <:.:> Stream) a)) -> (<:.:>) (:*:) Stream (Tap ((:*:) <:.:> Stream) a) forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ (Tap ((:*:) <:.:> Stream) a -> Tap ((:*:) <:.:> Stream) a) -> Construction Identity (Tap ((:*:) <:.:> Stream) a) move (forall k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t forall (t :: * -> *). Morphable ('Rotate 'Left) t => t ~> Morphing ('Rotate 'Left) t morph @(Rotate Left)) Construction Identity (Tap ((:*:) <:.:> Stream) a) -> Construction Identity (Tap ((:*:) <:.:> Stream) a) -> Product (Construction Identity (Tap ((:*:) <:.:> Stream) a)) (Construction Identity (Tap ((:*:) <:.:> Stream) a)) forall s a. s -> a -> Product s a :*: (Tap ((:*:) <:.:> Stream) a -> Tap ((:*:) <:.:> Stream) a) -> Construction Identity (Tap ((:*:) <:.:> Stream) a) move (forall k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t forall (t :: * -> *). Morphable ('Rotate 'Right) t => t ~> Morphing ('Rotate 'Right) t morph @(Rotate Right))) repeat :: a :=> Stream repeat :: a :=> Stream repeat a x = a -> ((Identity :. Stream) := a) -> Construction Identity a forall (t :: * -> *) a. a -> ((t :. Construction t) := a) -> Construction t a Construct a x (((Identity :. Stream) := a) -> Construction Identity a) -> (Construction Identity a -> (Identity :. Stream) := a) -> Construction Identity a -> Construction Identity a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Construction Identity a -> (Identity :. Stream) := a forall a. a -> Identity a Identity (Construction Identity a -> Construction Identity a) -> Construction Identity a -> Construction Identity a forall (m :: * -> * -> *) a b. Category m => m a b -> m a b $ a :=> Stream forall a. a :=> Stream repeat a x