{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Pandora.Paradigm.Structure.Splay where

import Pandora.Pattern.Category ((.), ($))
import Pandora.Pattern.Functor.Covariant (Covariant ((<$>)))
import Pandora.Pattern.Functor.Extractable (extract)
import Pandora.Pattern.Functor.Bindable (Bindable ((>>=)))
import Pandora.Paradigm.Primary.Functor (left, right, branches)
import Pandora.Paradigm.Primary.Functor.Function ((%))
import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Just))
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))
import Pandora.Paradigm.Structure.Ability.Morphable (Morphable (Morphing, morphing), morph)
import Pandora.Paradigm.Structure.Ability.Substructure (substitute)
import Pandora.Paradigm.Structure.Binary (Binary)

data Splay a = Zig a | Zag a

instance Morphable (Left Zig) (Construction Wye) where
	type Morphing (Left Zig) (Construction Wye) = Binary
	morphing :: (<:.>) (Tagged ('Left 'Zig)) (Construction Wye) a
-> Morphing ('Left 'Zig) (Construction Wye) a
morphing (Construction Wye a <:= Tagged ('Left 'Zig)
forall (t :: * -> *) a. Extractable t => a <:= t
extract (Construction Wye a <:= Tagged ('Left 'Zig))
-> ((<:.>) (Tagged ('Left 'Zig)) (Construction Wye) a
    -> Tagged ('Left 'Zig) (Construction Wye a))
-> (<:.>) (Tagged ('Left 'Zig)) (Construction Wye) a
-> Construction Wye a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged ('Left 'Zig)) (Construction Wye) a
-> Tagged ('Left 'Zig) (Construction Wye a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run -> Construct a
parent (Wye :. Construction Wye) := a
st) = ((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 :: * -> * -> *) a b. Category m => m a b -> m a b
$ 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)
-> ((Wye :. Construction Wye) := a) -> a -> Construction Wye a
forall a b c. (a -> b -> c) -> b -> a -> c
% (Wye :. Construction Wye) := a
subtree (a -> Construction Wye a)
-> (Construction Wye a -> a)
-> Construction Wye a
-> Construction Wye a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Wye a -> a
forall (t :: * -> *) a. Extractable t => a <:= t
extract (Construction Wye a -> Construction Wye a)
-> ((Maybe :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> ((Wye :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
left (Wye :. Construction Wye) := a
st where

		subtree :: (Wye :. Construction Wye) := a
subtree = ((Maybe :. Construction Wye) := a)
-> ((Maybe :. Construction Wye) := a)
-> (Wye :. Construction Wye) := a
forall a. Maybe a -> Maybe a -> Wye a
branches (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)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
left (Wye :. Construction Wye) := a
st 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
>>= ((Wye :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
left) (((Maybe :. Construction Wye) := a)
 -> (Wye :. Construction Wye) := a)
-> (((Wye :. Construction Wye) := a)
    -> (Maybe :. Construction Wye) := a)
-> ((Wye :. Construction Wye) := a)
-> (Wye :. 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)
-> (((Wye :. Construction Wye) := a) -> Construction Wye a)
-> ((Wye :. 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
parent
			(((Wye :. Construction Wye) := a)
 -> (Wye :. Construction Wye) := a)
-> ((Wye :. Construction Wye) := a)
-> (Wye :. Construction Wye) := a
forall (m :: * -> * -> *) a b. Category m => m a b -> m a b
$ ((Maybe :. Construction Wye) := a)
-> ((Maybe :. Construction Wye) := a)
-> (Wye :. Construction Wye) := a
forall a. Maybe a -> Maybe a -> Wye a
branches (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)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
left (Wye :. Construction Wye) := a
st 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
>>= ((Wye :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
right) (((Wye :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
right (Wye :. Construction Wye) := a
st)

instance Morphable (Right Zig) (Construction Wye) where
	type Morphing (Right Zig) (Construction Wye) = Binary
	morphing :: (<:.>) (Tagged ('Right 'Zig)) (Construction Wye) a
-> Morphing ('Right 'Zig) (Construction Wye) a
morphing (Construction Wye a <:= Tagged ('Right 'Zig)
forall (t :: * -> *) a. Extractable t => a <:= t
extract (Construction Wye a <:= Tagged ('Right 'Zig))
-> ((<:.>) (Tagged ('Right 'Zig)) (Construction Wye) a
    -> Tagged ('Right 'Zig) (Construction Wye a))
-> (<:.>) (Tagged ('Right 'Zig)) (Construction Wye) a
-> Construction Wye a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged ('Right 'Zig)) (Construction Wye) a
-> Tagged ('Right 'Zig) (Construction Wye a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run -> Construct a
parent (Wye :. Construction Wye) := a
st) = ((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 :: * -> * -> *) a b. Category m => m a b -> m a b
$ 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)
-> ((Wye :. Construction Wye) := a) -> a -> Construction Wye a
forall a b c. (a -> b -> c) -> b -> a -> c
% (Wye :. Construction Wye) := a
subtree (a -> Construction Wye a)
-> (Construction Wye a -> a)
-> Construction Wye a
-> Construction Wye a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Wye a -> a
forall (t :: * -> *) a. Extractable t => a <:= t
extract (Construction Wye a -> Construction Wye a)
-> ((Maybe :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> ((Wye :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
right (Wye :. Construction Wye) := a
st where

		subtree :: (Wye :. Construction Wye) := a
subtree = ((Maybe :. Construction Wye) := a)
-> ((Maybe :. Construction Wye) := a)
-> (Wye :. Construction Wye) := a
forall a. Maybe a -> Maybe a -> Wye a
branches (((Wye :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
left (Wye :. Construction Wye) := a
st) (((Maybe :. Construction Wye) := a)
 -> (Wye :. Construction Wye) := a)
-> (((Wye :. Construction Wye) := a)
    -> (Maybe :. Construction Wye) := a)
-> ((Wye :. Construction Wye) := a)
-> (Wye :. 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)
-> (((Wye :. Construction Wye) := a) -> Construction Wye a)
-> ((Wye :. 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
parent
			(((Wye :. Construction Wye) := a)
 -> (Wye :. Construction Wye) := a)
-> ((Wye :. Construction Wye) := a)
-> (Wye :. Construction Wye) := a
forall (m :: * -> * -> *) a b. Category m => m a b -> m a b
$ ((Maybe :. Construction Wye) := a)
-> ((Maybe :. Construction Wye) := a)
-> (Wye :. Construction Wye) := a
forall a. Maybe a -> Maybe a -> Wye a
branches (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)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
right (Wye :. Construction Wye) := a
st 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
>>= ((Wye :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
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)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
right (Wye :. Construction Wye) := a
st 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
>>= ((Wye :. Construction Wye) := a)
-> (Maybe :. Construction Wye) := a
Wye ~> Maybe
right)

instance Morphable (Left (Zig Zig)) (Construction Wye) where
	type Morphing (Left (Zig Zig)) (Construction Wye) = Binary
	morphing :: (<:.>) (Tagged ('Left ('Zig 'Zig))) (Construction Wye) a
-> Morphing ('Left ('Zig 'Zig)) (Construction Wye) a
morphing (Construction Wye a <:= Tagged ('Left ('Zig 'Zig))
forall (t :: * -> *) a. Extractable t => a <:= t
extract (Construction Wye a <:= Tagged ('Left ('Zig 'Zig)))
-> ((<:.>) (Tagged ('Left ('Zig 'Zig))) (Construction Wye) a
    -> Tagged ('Left ('Zig 'Zig)) (Construction Wye a))
-> (<:.>) (Tagged ('Left ('Zig 'Zig))) (Construction Wye) a
-> Construction Wye a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged ('Left ('Zig 'Zig))) (Construction Wye) a
-> Tagged ('Left ('Zig 'Zig)) (Construction Wye a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run -> 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 :: * -> * -> *) a b. Category m => m a b -> m a b
$ TU Covariant Covariant Maybe (Construction Wye) a
-> Primary (TU Covariant Covariant Maybe (Construction Wye)) a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (Construction Wye a -> Morphing ('Left 'Zig) (Construction Wye) a
forall k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t
morph @(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 k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t
forall (t :: * -> *).
Morphable ('Left 'Zig) t =>
t ~> Morphing ('Left 'Zig) t
morph @(Left Zig)

instance Morphable (Right (Zig Zig)) (Construction Wye) where
	type Morphing (Right (Zig Zig)) (Construction Wye) = Binary
	morphing :: (<:.>) (Tagged ('Right ('Zig 'Zig))) (Construction Wye) a
-> Morphing ('Right ('Zig 'Zig)) (Construction Wye) a
morphing (Construction Wye a <:= Tagged ('Right ('Zig 'Zig))
forall (t :: * -> *) a. Extractable t => a <:= t
extract (Construction Wye a <:= Tagged ('Right ('Zig 'Zig)))
-> ((<:.>) (Tagged ('Right ('Zig 'Zig))) (Construction Wye) a
    -> Tagged ('Right ('Zig 'Zig)) (Construction Wye a))
-> (<:.>) (Tagged ('Right ('Zig 'Zig))) (Construction Wye) a
-> Construction Wye a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged ('Right ('Zig 'Zig))) (Construction Wye) a
-> Tagged ('Right ('Zig 'Zig)) (Construction Wye a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run -> 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 :: * -> * -> *) a b. Category m => m a b -> m a b
$ TU Covariant Covariant Maybe (Construction Wye) a
-> Primary (TU Covariant Covariant Maybe (Construction Wye)) a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (Construction Wye a -> Morphing ('Right 'Zig) (Construction Wye) a
forall k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t
morph @(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 k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t
forall (t :: * -> *).
Morphable ('Right 'Zig) t =>
t ~> Morphing ('Right 'Zig) t
morph @(Right Zig)

instance Morphable (Left (Zig Zag)) (Construction Wye) where
	type Morphing (Left (Zig Zag)) (Construction Wye) = Binary
	morphing :: (<:.>) (Tagged ('Left ('Zig 'Zag))) (Construction Wye) a
-> Morphing ('Left ('Zig 'Zag)) (Construction Wye) a
morphing = forall k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t
forall (t :: * -> *).
Morphable ('Left 'Zig) t =>
t ~> Morphing ('Left 'Zig) t
morph @(Left Zig) (Construction Wye a -> Binary a)
-> ((<:.>) (Tagged ('Left ('Zig 'Zag))) (Construction Wye) a
    -> Construction Wye a)
-> (<:.>) (Tagged ('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 k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t
forall (t :: * -> *).
Morphable ('Right 'Zig) t =>
t ~> Morphing ('Right 'Zig) t
morph @(Right Zig)) (Primary (TU Covariant Covariant Maybe (Construction Wye)) a
 -> Primary (TU Covariant Covariant Maybe (Construction Wye)) a)
-> Binary a -> Binary a
forall (t :: * -> *) a b.
Interpreted t =>
(Primary t a -> Primary t b) -> t a -> t b
||=) (Construction Wye a -> Construction Wye a)
-> ((<:.>) (Tagged ('Left ('Zig 'Zag))) (Construction Wye) a
    -> Construction Wye a)
-> (<:.>) (Tagged ('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
. Construction Wye a <:= Tagged ('Left ('Zig 'Zag))
forall (t :: * -> *) a. Extractable t => a <:= t
extract (Construction Wye a <:= Tagged ('Left ('Zig 'Zag)))
-> ((<:.>) (Tagged ('Left ('Zig 'Zag))) (Construction Wye) a
    -> Tagged ('Left ('Zig 'Zag)) (Construction Wye a))
-> (<:.>) (Tagged ('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 ('Left ('Zig 'Zag))) (Construction Wye) a
-> Tagged ('Left ('Zig 'Zag)) (Construction Wye a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run

instance Morphable (Right (Zig Zag)) (Construction Wye) where
	type Morphing (Right (Zig Zag)) (Construction Wye) = Binary
	morphing :: (<:.>) (Tagged ('Right ('Zig 'Zag))) (Construction Wye) a
-> Morphing ('Right ('Zig 'Zag)) (Construction Wye) a
morphing = forall k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t
forall (t :: * -> *).
Morphable ('Right 'Zig) t =>
t ~> Morphing ('Right 'Zig) t
morph @(Right Zig) (Construction Wye a -> Binary a)
-> ((<:.>) (Tagged ('Right ('Zig 'Zag))) (Construction Wye) a
    -> Construction Wye a)
-> (<:.>) (Tagged ('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 k (f :: k) (t :: * -> *). Morphable f t => t ~> Morphing f t
forall (t :: * -> *).
Morphable ('Left 'Zig) t =>
t ~> Morphing ('Left 'Zig) t
morph @(Left Zig)) (Primary (TU Covariant Covariant Maybe (Construction Wye)) a
 -> Primary (TU Covariant Covariant Maybe (Construction Wye)) a)
-> Binary a -> Binary a
forall (t :: * -> *) a b.
Interpreted t =>
(Primary t a -> Primary t b) -> t a -> t b
||=) (Construction Wye a -> Construction Wye a)
-> ((<:.>) (Tagged ('Right ('Zig 'Zag))) (Construction Wye) a
    -> Construction Wye a)
-> (<:.>) (Tagged ('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
. Construction Wye a <:= Tagged ('Right ('Zig 'Zag))
forall (t :: * -> *) a. Extractable t => a <:= t
extract (Construction Wye a <:= Tagged ('Right ('Zig 'Zag)))
-> ((<:.>) (Tagged ('Right ('Zig 'Zag))) (Construction Wye) a
    -> Tagged ('Right ('Zig 'Zag)) (Construction Wye a))
-> (<:.>) (Tagged ('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 ('Right ('Zig 'Zag))) (Construction Wye) a
-> Tagged ('Right ('Zig 'Zag)) (Construction Wye a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run