{-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE AllowAmbiguousTypes #-} module Pandora.Paradigm.Structure.Some.Splay where import Pandora.Core.Functor (type (~>), type (:.), type (:=)) import Pandora.Pattern.Category ((.), ($), (/)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Applicative ((<*>)) import Pandora.Pattern.Functor.Extractable (extract) import Pandora.Pattern.Functor.Bindable (Bindable ((>>=))) import Pandora.Paradigm.Primary () import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Just)) import Pandora.Paradigm.Primary.Functor.Product (twosome) import Pandora.Paradigm.Primary.Functor.Tagged (type (:#)) import Pandora.Paradigm.Primary.Functor.Wye (Wye (Left, Right)) import Pandora.Paradigm.Primary.Transformer.Construction (Construction (Construct), deconstruct) import Pandora.Paradigm.Controlflow.Effect.Interpreted (run, (||=)) import Pandora.Paradigm.Schemes (TU (TU), type (<:.>)) import Pandora.Paradigm.Structure.Ability.Morphable (Morphable (Morphing, morphing), Morph (Rotate, Into), premorph, rotate, into) import Pandora.Paradigm.Structure.Ability.Nonempty (Nonempty) import Pandora.Paradigm.Structure.Ability.Substructure (substitute) import Pandora.Paradigm.Structure.Some.Binary (Binary) data Splay a = Zig a | Zag a instance Morphable (Rotate (Left Zig)) (Construction Wye) where type Morphing (Rotate (Left Zig)) (Construction Wye) = Binary morphing :: forall a . (:#) (Rotate (Left Zig)) <:.> Construction Wye := a -> Binary a morphing :: (((:#) ('Rotate ('Left 'Zig)) <:.> Construction Wye) := a) -> Binary a morphing ((((:#) ('Rotate ('Left 'Zig)) <:.> Construction Wye) := a) -> Construction Wye a forall k (f :: k) (t :: * -> *). Morphable f t => (Tagged f <:.> t) ~> t premorph -> Construct a x (Wye :. Construction Wye) := a xs) = ((Maybe :. Construction Wye) := a) -> Binary a forall k k k k (ct :: k) (cu :: k) (t :: k -> *) (u :: k -> k) (a :: k). ((t :. u) := a) -> TU ct cu t u a TU (((Maybe :. Construction Wye) := a) -> Binary a) -> ((Maybe :. Construction Wye) := a) -> Binary a forall (m :: * -> * -> *). Category m => m ~~> m $ a -> ((Wye :. Construction Wye) := a) -> Construction Wye a forall (t :: * -> *) a. a -> ((t :. Construction t) := a) -> Construction t a Construct (a -> ((Wye :. Construction Wye) := a) -> Construction Wye a) -> Maybe a -> Maybe (((Wye :. Construction Wye) := a) -> Construction Wye a) forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> Maybe a parent Maybe (((Wye :. Construction Wye) := a) -> Construction Wye a) -> Maybe ((Wye :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a b. Applicative t => t (a -> b) -> t a -> t b <*> ((Wye :. Construction Wye) := a) -> Maybe ((Wye :. Construction Wye) := a) forall a. a -> Maybe a Just (Wye :. Nonempty Binary) := a (Wye :. Construction Wye) := a nodes where nodes :: Wye :. Nonempty Binary := a nodes :: (Wye :. Nonempty Binary) := a nodes = forall a (f :: a) (t :: * -> *). Morphable ('Into f) t => t ~> Morphing ('Into f) t forall (t :: * -> *). Morphable ('Into Wye) t => t ~> Morphing ('Into Wye) t into @Wye (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a) -> (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a)) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . ((Maybe :. Construction Wye) := a) -> ((Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) forall k (t :: k -> *) (a :: k) (u :: k -> *). t a -> u a -> (<:.:>) t u (:*:) a twosome (((Wye :. Construction Wye) := a) -> Morphing ('Into ('Left Maybe)) Wye (Construction Wye a) forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Left (Wye :. Construction Wye) := a xs) (((Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a)) -> (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Construction Wye a -> (Maybe :. Construction Wye) := a forall a. a -> Maybe a Just (Construction Wye a -> (Maybe :. Construction Wye) := a) -> (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> Construction Wye a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Maybe :. Construction Wye) := a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . a -> ((Wye :. Construction Wye) := a) -> Construction Wye a forall (t :: * -> *) a. a -> ((t :. Construction t) := a) -> Construction t a Construct a x (((Wye :. Construction Wye) := a) -> Construction Wye a) -> (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> Construction Wye a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . forall a (f :: a) (t :: * -> *). Morphable ('Into f) t => t ~> Morphing ('Into f) t forall (t :: * -> *). Morphable ('Into Wye) t => t ~> Morphing ('Into Wye) t into @Wye (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a forall (m :: * -> * -> *). Category m => m ~~> m $ ((Maybe :. Construction Wye) := a) -> ((Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) forall k (t :: k -> *) (a :: k) (u :: k -> *). t a -> u a -> (<:.:>) t u (:*:) a twosome (Construction Wye a -> (Wye :. Construction Wye) := a forall (t :: * -> *) a. Construction t a -> (t :. Construction t) := a deconstruct (Construction Wye a -> (Wye :. Construction Wye) := a) -> ((Maybe :. Construction Wye) := a) -> Maybe ((Wye :. Construction Wye) := a) forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> ((Wye :. Construction Wye) := a) -> Morphing ('Into ('Right Maybe)) Wye (Construction Wye a) forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Right (Wye :. Construction Wye) := a xs Maybe ((Wye :. Construction Wye) := a) -> (((Wye :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b >>= Morphable ('Into ('Left Maybe)) Wye => Wye ~> Morphing ('Into ('Left Maybe)) Wye forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Left) (Construction Wye a -> (Wye :. Construction Wye) := a forall (t :: * -> *) a. Construction t a -> (t :. Construction t) := a deconstruct (Construction Wye a -> (Wye :. Construction Wye) := a) -> ((Maybe :. Construction Wye) := a) -> Maybe ((Wye :. Construction Wye) := a) forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> ((Wye :. Construction Wye) := a) -> Morphing ('Into ('Right Maybe)) Wye (Construction Wye a) forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Right (Wye :. Construction Wye) := a xs Maybe ((Wye :. Construction Wye) := a) -> (((Wye :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b >>= Morphable ('Into ('Right Maybe)) Wye => Wye ~> Morphing ('Into ('Right Maybe)) Wye forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Right) parent :: Maybe a parent :: Maybe a parent = a <:= Construction Wye forall (t :: * -> *) a. Extractable t => a <:= t extract (a <:= Construction Wye) -> ((Maybe :. Construction Wye) := a) -> Maybe a forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> ((Wye :. Construction Wye) := a) -> Morphing ('Into ('Right Maybe)) Wye (Construction Wye a) forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Right (Wye :. Construction Wye) := a xs instance Morphable (Rotate (Right Zig)) (Construction Wye) where type Morphing (Rotate (Right Zig)) (Construction Wye) = Binary morphing :: forall a . (:#) (Rotate (Right Zig)) <:.> Construction Wye := a -> Binary a morphing :: (((:#) ('Rotate ('Right 'Zig)) <:.> Construction Wye) := a) -> Binary a morphing ((((:#) ('Rotate ('Right 'Zig)) <:.> Construction Wye) := a) -> Construction Wye a forall k (f :: k) (t :: * -> *). Morphable f t => (Tagged f <:.> t) ~> t premorph -> Construct a x (Wye :. Construction Wye) := a xs) = ((Maybe :. Construction Wye) := a) -> Binary a forall k k k k (ct :: k) (cu :: k) (t :: k -> *) (u :: k -> k) (a :: k). ((t :. u) := a) -> TU ct cu t u a TU (((Maybe :. Construction Wye) := a) -> Binary a) -> ((Maybe :. Construction Wye) := a) -> Binary a forall (m :: * -> * -> *). Category m => m ~~> m $ a -> ((Wye :. Construction Wye) := a) -> Construction Wye a forall (t :: * -> *) a. a -> ((t :. Construction t) := a) -> Construction t a Construct (a -> ((Wye :. Construction Wye) := a) -> Construction Wye a) -> Maybe a -> Maybe (((Wye :. Construction Wye) := a) -> Construction Wye a) forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> Maybe a parent Maybe (((Wye :. Construction Wye) := a) -> Construction Wye a) -> Maybe ((Wye :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a b. Applicative t => t (a -> b) -> t a -> t b <*> ((Wye :. Construction Wye) := a) -> Maybe ((Wye :. Construction Wye) := a) forall a. a -> Maybe a Just (Wye :. Nonempty Binary) := a (Wye :. Construction Wye) := a nodes where nodes :: Wye :. Nonempty Binary := a nodes :: (Wye :. Nonempty Binary) := a nodes = forall a (f :: a) (t :: * -> *). Morphable ('Into f) t => t ~> Morphing ('Into f) t forall (t :: * -> *). Morphable ('Into Wye) t => t ~> Morphing ('Into Wye) t into @Wye (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a) -> (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a)) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . ((Maybe :. Construction Wye) := a) -> ((Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) forall k (t :: k -> *) (a :: k) (u :: k -> *). t a -> u a -> (<:.:>) t u (:*:) a twosome (Construction Wye a -> (Wye :. Construction Wye) := a forall (t :: * -> *) a. Construction t a -> (t :. Construction t) := a deconstruct (Construction Wye a -> (Wye :. Construction Wye) := a) -> ((Maybe :. Construction Wye) := a) -> Maybe ((Wye :. Construction Wye) := a) forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> ((Wye :. Construction Wye) := a) -> Morphing ('Into ('Left Maybe)) Wye (Construction Wye a) forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Left (Wye :. Construction Wye) := a xs Maybe ((Wye :. Construction Wye) := a) -> (((Wye :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b >>= Morphable ('Into ('Left Maybe)) Wye => Wye ~> Morphing ('Into ('Left Maybe)) Wye forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Left) (((Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a)) -> (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . Construction Wye a -> (Maybe :. Construction Wye) := a forall a. a -> Maybe a Just (Construction Wye a -> (Maybe :. Construction Wye) := a) -> (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> Construction Wye a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Maybe :. Construction Wye) := a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . a -> ((Wye :. Construction Wye) := a) -> Construction Wye a forall (t :: * -> *) a. a -> ((t :. Construction t) := a) -> Construction t a Construct a x (((Wye :. Construction Wye) := a) -> Construction Wye a) -> (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> Construction Wye a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . forall a (f :: a) (t :: * -> *). Morphable ('Into f) t => t ~> Morphing ('Into f) t forall (t :: * -> *). Morphable ('Into Wye) t => t ~> Morphing ('Into Wye) t into @Wye (T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) -> (Wye :. Construction Wye) := a forall (m :: * -> * -> *). Category m => m ~~> m $ ((Maybe :. Construction Wye) := a) -> ((Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) forall k (t :: k -> *) (a :: k) (u :: k -> *). t a -> u a -> (<:.:>) t u (:*:) a twosome (Construction Wye a -> (Wye :. Construction Wye) := a forall (t :: * -> *) a. Construction t a -> (t :. Construction t) := a deconstruct (Construction Wye a -> (Wye :. Construction Wye) := a) -> ((Maybe :. Construction Wye) := a) -> Maybe ((Wye :. Construction Wye) := a) forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> ((Wye :. Construction Wye) := a) -> Morphing ('Into ('Left Maybe)) Wye (Construction Wye a) forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Left (Wye :. Construction Wye) := a xs Maybe ((Wye :. Construction Wye) := a) -> (((Wye :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b >>= Morphable ('Into ('Right Maybe)) Wye => Wye ~> Morphing ('Into ('Right Maybe)) Wye forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Right) (((Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a)) -> ((Maybe :. Construction Wye) := a) -> T_U Covariant Covariant (:*:) Maybe Maybe (Construction Wye a) forall (m :: * -> * -> *). Category m => m ~~> m / ((Wye :. Construction Wye) := a) -> Morphing ('Into ('Right Maybe)) Wye (Construction Wye a) forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Right (Wye :. Construction Wye) := a xs parent :: Maybe a parent :: Maybe a parent = a <:= Construction Wye forall (t :: * -> *) a. Extractable t => a <:= t extract (a <:= Construction Wye) -> ((Maybe :. Construction Wye) := a) -> Maybe a forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b <$> ((Wye :. Construction Wye) := a) -> Morphing ('Into ('Left Maybe)) Wye (Construction Wye a) forall a (b :: (* -> *) -> a). Morphable ('Into (b Maybe)) Wye => Wye ~> Morphing ('Into (b Maybe)) Wye branch @Left (Wye :. Construction Wye) := a xs instance Morphable (Rotate (Left (Zig Zig))) (Construction Wye) where type Morphing (Rotate (Left (Zig Zig))) (Construction Wye) = Binary morphing :: (<:.>) (Tagged ('Rotate ('Left ('Zig 'Zig)))) (Construction Wye) a -> Morphing ('Rotate ('Left ('Zig 'Zig))) (Construction Wye) a morphing ((<:.>) (Tagged ('Rotate ('Left ('Zig 'Zig)))) (Construction Wye) a -> Construction Wye a forall k (f :: k) (t :: * -> *). Morphable f t => (Tagged f <:.> t) ~> t premorph -> Construction Wye a tree) = ((Maybe :. Construction Wye) := a) -> TU Covariant Covariant Maybe (Construction Wye) a forall k k k k (ct :: k) (cu :: k) (t :: k -> *) (u :: k -> k) (a :: k). ((t :. u) := a) -> TU ct cu t u a TU (((Maybe :. Construction Wye) := a) -> TU Covariant Covariant Maybe (Construction Wye) a) -> ((Maybe :. Construction Wye) := a) -> TU Covariant Covariant Maybe (Construction Wye) a forall (m :: * -> * -> *). Category m => m ~~> m $ TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run (TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a) -> TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a forall (m :: * -> * -> *). Category m => m ~~> m / Construction Wye a -> Morphing ('Rotate ('Left 'Zig)) (Construction Wye) a forall a (f :: a) (t :: * -> *). Morphable ('Rotate f) t => t ~> Morphing ('Rotate f) t rotate @(Left Zig) Construction Wye a tree ((Maybe :. Construction Wye) := a) -> (Construction Wye a -> (Maybe :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b >>= TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run (TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a) -> (Construction Wye a -> TU Covariant Covariant Maybe (Construction Wye) a) -> Construction Wye a -> (Maybe :. Construction Wye) := a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . forall a (f :: a) (t :: * -> *). Morphable ('Rotate f) t => t ~> Morphing ('Rotate f) t forall (t :: * -> *). Morphable ('Rotate ('Left 'Zig)) t => t ~> Morphing ('Rotate ('Left 'Zig)) t rotate @(Left Zig) instance Morphable (Rotate (Right (Zig Zig))) (Construction Wye) where type Morphing (Rotate (Right (Zig Zig))) (Construction Wye) = Binary morphing :: (<:.>) (Tagged ('Rotate ('Right ('Zig 'Zig)))) (Construction Wye) a -> Morphing ('Rotate ('Right ('Zig 'Zig))) (Construction Wye) a morphing ((<:.>) (Tagged ('Rotate ('Right ('Zig 'Zig)))) (Construction Wye) a -> Construction Wye a forall k (f :: k) (t :: * -> *). Morphable f t => (Tagged f <:.> t) ~> t premorph -> Construction Wye a tree) = ((Maybe :. Construction Wye) := a) -> TU Covariant Covariant Maybe (Construction Wye) a forall k k k k (ct :: k) (cu :: k) (t :: k -> *) (u :: k -> k) (a :: k). ((t :. u) := a) -> TU ct cu t u a TU (((Maybe :. Construction Wye) := a) -> TU Covariant Covariant Maybe (Construction Wye) a) -> ((Maybe :. Construction Wye) := a) -> TU Covariant Covariant Maybe (Construction Wye) a forall (m :: * -> * -> *). Category m => m ~~> m $ TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run (TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a) -> TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a forall (m :: * -> * -> *). Category m => m ~~> m / Construction Wye a -> Morphing ('Rotate ('Right 'Zig)) (Construction Wye) a forall a (f :: a) (t :: * -> *). Morphable ('Rotate f) t => t ~> Morphing ('Rotate f) t rotate @(Right Zig) Construction Wye a tree ((Maybe :. Construction Wye) := a) -> (Construction Wye a -> (Maybe :. Construction Wye) := a) -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b >>= TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run (TU Covariant Covariant Maybe (Construction Wye) a -> (Maybe :. Construction Wye) := a) -> (Construction Wye a -> TU Covariant Covariant Maybe (Construction Wye) a) -> Construction Wye a -> (Maybe :. Construction Wye) := a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . forall a (f :: a) (t :: * -> *). Morphable ('Rotate f) t => t ~> Morphing ('Rotate f) t forall (t :: * -> *). Morphable ('Rotate ('Right 'Zig)) t => t ~> Morphing ('Rotate ('Right 'Zig)) t rotate @(Right Zig) instance Morphable (Rotate (Left (Zig Zag))) (Construction Wye) where type Morphing (Rotate (Left (Zig Zag))) (Construction Wye) = Binary morphing :: (<:.>) (Tagged ('Rotate ('Left ('Zig 'Zag)))) (Construction Wye) a -> Morphing ('Rotate ('Left ('Zig 'Zag))) (Construction Wye) a morphing = forall a (f :: a) (t :: * -> *). Morphable ('Rotate f) t => t ~> Morphing ('Rotate f) t forall (t :: * -> *). Morphable ('Rotate ('Left 'Zig)) t => t ~> Morphing ('Rotate ('Left 'Zig)) t rotate @(Left Zig) (Construction Wye a -> Binary a) -> ((<:.>) (Tagged ('Rotate ('Left ('Zig 'Zag)))) (Construction Wye) a -> Construction Wye a) -> (<:.>) (Tagged ('Rotate ('Left ('Zig 'Zag)))) (Construction Wye) a -> Binary a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (Substructural 'Left (Construction Wye) a -> Substructural 'Left (Construction Wye) a) -> Construction Wye a -> Construction Wye a forall k (f :: k) (t :: * -> *) a. Substructure f t => (Substructural f t a -> Substructural f t a) -> t a -> t a substitute @Left ((Maybe (Construction Wye a) -> (Construction Wye a -> Maybe (Construction Wye a)) -> Maybe (Construction Wye a) forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b >>= Binary a -> Maybe (Construction Wye a) forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run (Binary a -> Maybe (Construction Wye a)) -> (Construction Wye a -> Binary a) -> Construction Wye a -> Maybe (Construction Wye a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . forall a (f :: a) (t :: * -> *). Morphable ('Rotate f) t => t ~> Morphing ('Rotate f) t forall (t :: * -> *). Morphable ('Rotate ('Right 'Zig)) t => t ~> Morphing ('Rotate ('Right 'Zig)) t rotate @(Right Zig)) (Primary Binary a -> Primary Binary a) -> Binary a -> Binary a forall (t :: * -> *) (u :: * -> *) a b. (Interpreted t, Interpreted u) => (Primary t a -> Primary u b) -> t a -> u b ||=) (Construction Wye a -> Construction Wye a) -> ((<:.>) (Tagged ('Rotate ('Left ('Zig 'Zag)))) (Construction Wye) a -> Construction Wye a) -> (<:.>) (Tagged ('Rotate ('Left ('Zig 'Zag)))) (Construction Wye) a -> Construction Wye a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (<:.>) (Tagged ('Rotate ('Left ('Zig 'Zag)))) (Construction Wye) a -> Construction Wye a forall k (f :: k) (t :: * -> *). Morphable f t => (Tagged f <:.> t) ~> t premorph instance Morphable (Rotate (Right (Zig Zag))) (Construction Wye) where type Morphing (Rotate (Right (Zig Zag))) (Construction Wye) = Binary morphing :: (<:.>) (Tagged ('Rotate ('Right ('Zig 'Zag)))) (Construction Wye) a -> Morphing ('Rotate ('Right ('Zig 'Zag))) (Construction Wye) a morphing = forall a (f :: a) (t :: * -> *). Morphable ('Rotate f) t => t ~> Morphing ('Rotate f) t forall (t :: * -> *). Morphable ('Rotate ('Right 'Zig)) t => t ~> Morphing ('Rotate ('Right 'Zig)) t rotate @(Right Zig) (Construction Wye a -> Binary a) -> ((<:.>) (Tagged ('Rotate ('Right ('Zig 'Zag)))) (Construction Wye) a -> Construction Wye a) -> (<:.>) (Tagged ('Rotate ('Right ('Zig 'Zag)))) (Construction Wye) a -> Binary a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (Substructural 'Right (Construction Wye) a -> Substructural 'Right (Construction Wye) a) -> Construction Wye a -> Construction Wye a forall k (f :: k) (t :: * -> *) a. Substructure f t => (Substructural f t a -> Substructural f t a) -> t a -> t a substitute @Right ((Maybe (Construction Wye a) -> (Construction Wye a -> Maybe (Construction Wye a)) -> Maybe (Construction Wye a) forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b >>= Binary a -> Maybe (Construction Wye a) forall (t :: * -> *) a. Interpreted t => t a -> Primary t a run (Binary a -> Maybe (Construction Wye a)) -> (Construction Wye a -> Binary a) -> Construction Wye a -> Maybe (Construction Wye a) forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . forall a (f :: a) (t :: * -> *). Morphable ('Rotate f) t => t ~> Morphing ('Rotate f) t forall (t :: * -> *). Morphable ('Rotate ('Left 'Zig)) t => t ~> Morphing ('Rotate ('Left 'Zig)) t rotate @(Left Zig)) (Primary Binary a -> Primary Binary a) -> Binary a -> Binary a forall (t :: * -> *) (u :: * -> *) a b. (Interpreted t, Interpreted u) => (Primary t a -> Primary u b) -> t a -> u b ||=) (Construction Wye a -> Construction Wye a) -> ((<:.>) (Tagged ('Rotate ('Right ('Zig 'Zag)))) (Construction Wye) a -> Construction Wye a) -> (<:.>) (Tagged ('Rotate ('Right ('Zig 'Zag)))) (Construction Wye) a -> Construction Wye a forall (m :: * -> * -> *) b c a. Category m => m b c -> m a b -> m a c . (<:.>) (Tagged ('Rotate ('Right ('Zig 'Zag)))) (Construction Wye) a -> Construction Wye a forall k (f :: k) (t :: * -> *). Morphable f t => (Tagged f <:.> t) ~> t premorph branch :: forall b . Morphable (Into (b Maybe)) Wye => Wye ~> Morphing (Into (b Maybe)) Wye branch :: Wye ~> Morphing ('Into (b Maybe)) Wye branch = forall a (f :: a) (t :: * -> *). Morphable ('Into f) t => t ~> Morphing ('Into f) t forall (t :: * -> *). Morphable ('Into (b Maybe)) t => t ~> Morphing ('Into (b Maybe)) t into @(b Maybe)