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

module Pandora.Paradigm.Structure.Some.List where

import Pandora.Core.Functor (type (:.), type (:=), type (:::))
import Pandora.Core.Impliable (imply)
import Pandora.Pattern.Category ((.), ($), (#), identity)
import Pandora.Pattern.Functor.Covariant (Covariant ((<$>), (.#..)), Covariant_ ((-<$>-)))
import Pandora.Pattern.Functor.Applicative (Applicative ((<*>)))
import Pandora.Pattern.Functor.Extractable (extract)
import Pandora.Pattern.Functor.Avoidable (empty)
import Pandora.Pattern.Functor.Traversable (Traversable ((<<-)))
import Pandora.Pattern.Functor.Extendable (Extendable ((<<=)))
import Pandora.Pattern.Functor.Bindable (Bindable ((=<<)))
import Pandora.Pattern.Functor.Bivariant ((<->))
import Pandora.Pattern.Transformer.Liftable (lift)
import Pandora.Pattern.Transformer.Lowerable (lower)
import Pandora.Pattern.Object.Setoid (Setoid ((==)))
import Pandora.Pattern.Object.Semigroup (Semigroup ((+)))
import Pandora.Pattern.Object.Monoid (Monoid (zero))
import Pandora.Paradigm.Primary.Object.Boolean (Boolean (True, False), (?))
import Pandora.Paradigm.Primary.Object.Numerator (Numerator (Numerator))
import Pandora.Paradigm.Primary.Object.Denumerator (Denumerator (One))
import Pandora.Paradigm.Primary.Algebraic ((-<*>-))
import Pandora.Paradigm.Primary.Algebraic.Product ((:*:) ((:*:)), attached, twosome)
import Pandora.Paradigm.Primary.Algebraic.Exponential ((%))
import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Just, Nothing))
import Pandora.Paradigm.Primary.Functor.Identity (Identity (Identity))
import Pandora.Paradigm.Primary.Functor.Predicate (Predicate (Predicate))
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.Primary.Transformer.Reverse (Reverse (Reverse))
import Pandora.Paradigm.Inventory.State (State, fold, modify)
import Pandora.Paradigm.Inventory.Store (Store (Store))
import Pandora.Paradigm.Inventory.Optics (Convex, Lens, view)
import Pandora.Paradigm.Controlflow.Effect.Interpreted (run, (||=))
import Pandora.Paradigm.Schemes.TU (TU (TU), type (<:.>))
import Pandora.Paradigm.Schemes.T_U (T_U (T_U), type (<:.:>))
import Pandora.Paradigm.Schemes.P_Q_T (P_Q_T (P_Q_T))
import Pandora.Paradigm.Structure.Ability.Nonempty (Nonempty)
import Pandora.Paradigm.Structure.Ability.Nullable (Nullable (null))
import Pandora.Paradigm.Structure.Ability.Zipper (Zipper)
import Pandora.Paradigm.Structure.Ability.Measurable (Measurable (Measural, measurement), Scale (Length), measure)
import Pandora.Paradigm.Structure.Ability.Monotonic (resolve)
import Pandora.Paradigm.Structure.Ability.Morphable (Morphable (Morphing, morphing)
	, Morph (Rotate, Into, Push, Pop, Delete, Find, Lookup, Element, Key)
	, Occurrence (All, First), premorph, rotate, item, filter, find, lookup, into)
import Pandora.Paradigm.Structure.Ability.Substructure (Substructure (Available, Substance, substructure, sub), Segment (Root, Tail))
import Pandora.Paradigm.Structure.Interface.Stack (Stack)
import Pandora.Paradigm.Structure.Modification.Combinative (Combinative)
import Pandora.Paradigm.Structure.Modification.Comprehension (Comprehension (Comprehension))
import Pandora.Paradigm.Structure.Modification.Prefixed (Prefixed (Prefixed))

-- | Linear data structure that serves as a collection of elements
type List = Maybe <:.> Construction Maybe

instance Setoid a => Setoid (List a) where
	TU (Maybe :. Construction Maybe) := a
ls == :: List a -> List a -> Boolean
== TU (Maybe :. Construction Maybe) := a
rs = (Maybe :. Construction Maybe) := a
ls ((Maybe :. Construction Maybe) := a)
-> ((Maybe :. Construction Maybe) := a) -> Boolean
forall a. Setoid a => a -> a -> Boolean
== (Maybe :. Construction Maybe) := a
rs

instance Semigroup (List a) where
	TU Maybe (Construction Maybe a)
Nothing + :: List a -> List a -> List a
+ TU Maybe (Construction Maybe a)
ys = Maybe (Construction Maybe a) -> List 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 Maybe a)
ys
	TU (Just (Construct a
x Maybe (Construction Maybe a)
xs)) + TU Maybe (Construction Maybe a)
ys = Construction Maybe a -> List a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a -> List a)
-> (List a -> Construction Maybe a) -> List a -> List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. a -> Maybe (Construction Maybe a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct a
x (Maybe (Construction Maybe a) -> Construction Maybe a)
-> (List a -> Maybe (Construction Maybe a))
-> List a
-> Construction Maybe a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. List a -> Maybe (Construction Maybe a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run
		(List a -> List a) -> List a -> List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Maybe (Construction Maybe a) -> List 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 @Covariant @Covariant Maybe (Construction Maybe a)
xs List a -> List a -> List a
forall a. Semigroup a => a -> a -> a
+ Maybe (Construction Maybe a) -> List 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 @Covariant @Covariant Maybe (Construction Maybe a)
ys

instance Monoid (List a) where
	zero :: List a
zero = List a
forall (t :: * -> *) a. Avoidable t => t a
empty

instance Morphable Push List where
	type Morphing Push List = Identity <:.:> List := (->)
	morphing :: (<:.>) (Tagged 'Push) List a -> Morphing 'Push List a
morphing ((<:.>) (Tagged 'Push) List a -> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> List a
xs) = (Identity a -> List a)
-> T_U Covariant Covariant (->) Identity List a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Identity a -> List a)
 -> T_U Covariant Covariant (->) Identity List a)
-> (Identity a -> List a)
-> T_U Covariant Covariant (->) Identity List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Construction Maybe a -> List a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a -> List a)
-> (Identity a -> Construction Maybe a) -> Identity a -> List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct (a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a)
-> ((Maybe :. Construction Maybe) := a)
-> a
-> Construction Maybe a
forall a b c. (a -> b -> c) -> b -> a -> c
% List a -> Primary List a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run List a
xs) (a -> Construction Maybe a)
-> (Identity a -> a) -> Identity a -> Construction Maybe a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Identity a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract

instance Morphable Pop List where
	type Morphing Pop List = List
	morphing :: (<:.>) (Tagged 'Pop) List a -> Morphing 'Pop List a
morphing ((<:.>) (Tagged 'Pop) List a -> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> List a
xs) = (Construction Maybe a -> (Maybe :. Construction Maybe) := a)
-> ((Maybe :. Construction Maybe) := a)
-> ((Maybe :. Construction Maybe) := a)
-> (Maybe :. Construction Maybe) := a
forall a e r. Monotonic a e => (a -> r) -> r -> e -> r
resolve Construction Maybe a -> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) a.
Construction t a -> (t :. Construction t) := a
deconstruct (Maybe :. Construction Maybe) := a
forall a. Maybe a
Nothing (Primary List a -> Primary List a) -> List a -> List a
forall (t :: * -> *) (u :: * -> *) a b.
(Interpreted t, Interpreted u) =>
(Primary t a -> Primary u b) -> t a -> u b
||= List a
xs

instance Morphable (Find Element) List where
	type Morphing (Find Element) List = Predicate <:.:> Maybe := (->)
	morphing :: (<:.>) (Tagged ('Find 'Element)) List a
-> Morphing ('Find 'Element) List a
morphing ((<:.>) (Tagged ('Find 'Element)) List a -> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> TU Maybe (Construction Maybe a)
Nothing) = (Predicate a -> Maybe a)
-> T_U Covariant Covariant (->) Predicate Maybe a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Predicate a -> Maybe a)
 -> T_U Covariant Covariant (->) Predicate Maybe a)
-> (Predicate a -> Maybe a)
-> T_U Covariant Covariant (->) Predicate Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \Predicate a
_ -> Maybe a
forall a. Maybe a
Nothing
	morphing ((<:.>) (Tagged ('Find 'Element)) List a -> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> TU (Just (Construct a
x Maybe (Construction Maybe a)
xs))) = (Predicate a -> Maybe a)
-> T_U Covariant Covariant (->) Predicate Maybe a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Predicate a -> Maybe a)
 -> T_U Covariant Covariant (->) Predicate Maybe a)
-> (Predicate a -> Maybe a)
-> T_U Covariant Covariant (->) Predicate Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \Predicate a
p ->
		Predicate a -> a -> Boolean
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run Predicate a
p a
x Boolean -> Maybe a -> Maybe a -> Maybe a
forall a. Boolean -> a -> a -> a
? a -> Maybe a
forall a. a -> Maybe a
Just a
x (Maybe a -> Maybe a) -> Maybe a -> Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ forall a2.
Morphed ('Find 'Element) List ((Predicate <:.:> Maybe) := (->)) =>
Predicate a2 -> List a2 -> Maybe a2
forall a1 (mod :: a1) (struct :: * -> *) (result :: * -> *) a2.
Morphed ('Find mod) struct ((Predicate <:.:> result) := (->)) =>
Predicate a2 -> struct a2 -> result a2
find @Element @List @Maybe (Predicate a -> List a -> Maybe a)
-> Predicate a -> List a -> Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Predicate a
p (List a -> Maybe a) -> List a -> Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Maybe (Construction Maybe a) -> List 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 Maybe a)
xs

instance Morphable (Delete First) List where
	type Morphing (Delete First) List = Predicate <:.:> List := (->)
	morphing :: (<:.>) (Tagged ('Delete 'First)) List a
-> Morphing ('Delete 'First) List a
morphing ((<:.>) (Tagged ('Delete 'First)) List a -> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> TU Maybe (Construction Maybe a)
Nothing) = (Predicate a -> List a)
-> T_U Covariant Covariant (->) Predicate List a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Predicate a -> List a)
 -> T_U Covariant Covariant (->) Predicate List a)
-> (Predicate a -> List a)
-> T_U Covariant Covariant (->) Predicate List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \Predicate a
_ -> Maybe (Construction Maybe a) -> List 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 Maybe a)
forall a. Maybe a
Nothing
	morphing ((<:.>) (Tagged ('Delete 'First)) List a -> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> TU (Just (Construct a
x Maybe (Construction Maybe a)
xs))) = (Predicate a -> List a)
-> T_U Covariant Covariant (->) Predicate List a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Predicate a -> List a)
 -> T_U Covariant Covariant (->) Predicate List a)
-> (Predicate a -> List a)
-> T_U Covariant Covariant (->) Predicate List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \Predicate a
p ->
		Predicate a -> a -> Boolean
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run Predicate a
p a
x Boolean -> List a -> List a -> List a
forall a. Boolean -> a -> a -> a
? Maybe (Construction Maybe a) -> List 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 Maybe a)
xs (List a -> List a) -> List a -> List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Construction Maybe a -> List a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a -> List a)
-> (List a -> Construction Maybe a) -> List a -> List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. a -> Maybe (Construction Maybe a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct a
x (Maybe (Construction Maybe a) -> Construction Maybe a)
-> (List a -> Maybe (Construction Maybe a))
-> List a
-> Construction Maybe a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. List a -> Maybe (Construction Maybe a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (List a -> Maybe (Construction Maybe a))
-> (List a -> List a) -> List a -> Maybe (Construction Maybe a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Predicate a -> List a -> List a
forall a1 (mod :: a1) (struct :: * -> *) a2.
Morphed ('Delete mod) struct ((Predicate <:.:> struct) := (->)) =>
Predicate a2 -> struct a2 -> struct a2
filter @First @List Predicate a
p (List a -> List a) -> List a -> List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Maybe (Construction Maybe a) -> List 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 Maybe a)
xs

instance Morphable (Delete All) List where
	type Morphing (Delete All) List = Predicate <:.:> List := (->)
	morphing :: (<:.>) (Tagged ('Delete 'All)) List a
-> Morphing ('Delete 'All) List a
morphing ((<:.>) (Tagged ('Delete 'All)) List a -> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> TU Maybe (Construction Maybe a)
Nothing) = (Predicate a -> List a)
-> T_U Covariant Covariant (->) Predicate List a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Predicate a -> List a)
 -> T_U Covariant Covariant (->) Predicate List a)
-> (Predicate a -> List a)
-> T_U Covariant Covariant (->) Predicate List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \Predicate a
_ -> Maybe (Construction Maybe a) -> List 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 Maybe a)
forall a. Maybe a
Nothing
	morphing ((<:.>) (Tagged ('Delete 'All)) List a -> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> TU (Just (Construct a
x Maybe (Construction Maybe a)
xs))) = (Predicate a -> List a)
-> T_U Covariant Covariant (->) Predicate List a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Predicate a -> List a)
 -> T_U Covariant Covariant (->) Predicate List a)
-> (Predicate a -> List a)
-> T_U Covariant Covariant (->) Predicate List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \Predicate a
p ->
		Predicate a -> a -> Boolean
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run Predicate a
p a
x Boolean -> List a -> List a -> List a
forall a. Boolean -> a -> a -> a
? Predicate a -> List a -> List a
forall a1 (mod :: a1) (struct :: * -> *) a2.
Morphed ('Delete mod) struct ((Predicate <:.:> struct) := (->)) =>
Predicate a2 -> struct a2 -> struct a2
filter @All @List Predicate a
p (Maybe (Construction Maybe a) -> List 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 Maybe a)
xs) (List a -> List a) -> List a -> List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Construction Maybe a -> List a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a -> List a)
-> (List a -> Construction Maybe a) -> List a -> List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. a -> Maybe (Construction Maybe a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct a
x (Maybe (Construction Maybe a) -> Construction Maybe a)
-> (List a -> Maybe (Construction Maybe a))
-> List a
-> Construction Maybe a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. List a -> Maybe (Construction Maybe a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (List a -> Maybe (Construction Maybe a))
-> (List a -> List a) -> List a -> Maybe (Construction Maybe a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Predicate a -> List a -> List a
forall a1 (mod :: a1) (struct :: * -> *) a2.
Morphed ('Delete mod) struct ((Predicate <:.:> struct) := (->)) =>
Predicate a2 -> struct a2 -> struct a2
filter @All @List Predicate a
p (List a -> List a) -> List a -> List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Maybe (Construction Maybe a) -> List 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 Maybe a)
xs

instance Stack List where

instance Measurable Length List where
	type Measural Length List a = Numerator
	measurement :: Tagged 'Length (List a) -> Measural 'Length List a
measurement (List a -> Maybe (Construction Maybe a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (List a -> Maybe (Construction Maybe a))
-> (Tagged 'Length (List a) -> List a)
-> Tagged 'Length (List a)
-> Maybe (Construction Maybe a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Tagged 'Length (List a) -> List a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract -> Maybe (Construction Maybe a)
Nothing) = Measural 'Length List a
forall a. Monoid a => a
zero
	measurement (List a -> Maybe (Construction Maybe a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (List a -> Maybe (Construction Maybe a))
-> (Tagged 'Length (List a) -> List a)
-> Tagged 'Length (List a)
-> Maybe (Construction Maybe a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Tagged 'Length (List a) -> List a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract -> Just Construction Maybe a
xs) = Denumerator -> Numerator
Numerator (Denumerator -> Numerator) -> Denumerator -> Numerator
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Construction Maybe a -> Measural 'Length (Construction Maybe) a
forall k (f :: k) (t :: * -> *) a.
Measurable f t =>
t a -> Measural f t a
measure @Length Construction Maybe a
xs

instance Nullable List where
	null :: (Predicate :. List) := a
null = (List a -> Boolean) -> (Predicate :. List) := a
forall a. (a -> Boolean) -> Predicate a
Predicate ((List a -> Boolean) -> (Predicate :. List) := a)
-> (List a -> Boolean) -> (Predicate :. List) := a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \case { TU Maybe (Construction Maybe a)
Nothing -> Boolean
True ; List a
_ -> Boolean
False }

instance Substructure Root List where
	type Available Root List = Maybe
	type Substance Root List = Identity
	substructure :: Lens
  (Available 'Root List)
  ((<:.>) (Tagged 'Root) List a)
  (Substance 'Root List a)
substructure = ((<:.>) (Tagged 'Root) List a
 -> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a))
-> P_Q_T
     (->) Store Maybe ((<:.>) (Tagged 'Root) List a) (Identity a)
forall (p :: * -> * -> *) (q :: * -> * -> *) (t :: * -> *) a b.
p a (q (t b) a) -> P_Q_T p q t a b
P_Q_T (((<:.>) (Tagged 'Root) List a
  -> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a))
 -> P_Q_T
      (->) Store Maybe ((<:.>) (Tagged 'Root) List a) (Identity a))
-> ((<:.>) (Tagged 'Root) List a
    -> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a))
-> P_Q_T
     (->) Store Maybe ((<:.>) (Tagged 'Root) List a) (Identity a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \(<:.>) (Tagged 'Root) List a
zipper -> case TU Covariant Covariant Maybe (Construction Maybe) a
-> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (TU Covariant Covariant Maybe (Construction Maybe) a
 -> (Maybe :. Construction Maybe) := a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
-> (Maybe :. Construction Maybe) := a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# (<:.>) (Tagged 'Root) List a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Lowerable t, Covariant_ u (->) (->)) =>
t u ~> u
lower (<:.>) (Tagged 'Root) List a
zipper of
		Just (Construct a
x (Maybe :. Construction Maybe) := a
xs) -> (((:*:) (Maybe (Identity a)) :. (->) (Maybe (Identity a)))
 := (<:.>) (Tagged 'Root) List a)
-> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a)
forall s a. (((:*:) s :. (->) s) := a) -> Store s a
Store ((((:*:) (Maybe (Identity a)) :. (->) (Maybe (Identity a)))
  := (<:.>) (Tagged 'Root) List a)
 -> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a))
-> (((:*:) (Maybe (Identity a)) :. (->) (Maybe (Identity a)))
    := (<:.>) (Tagged 'Root) List a)
-> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Identity a -> Maybe (Identity a)
forall a. a -> Maybe a
Just (a -> Identity a
forall a. a -> Identity a
Identity a
x) Maybe (Identity a)
-> (Maybe (Identity a) -> (<:.>) (Tagged 'Root) List a)
-> ((:*:) (Maybe (Identity a)) :. (->) (Maybe (Identity a)))
   := (<:.>) (Tagged 'Root) List a
forall s a. s -> a -> s :*: a
:*: TU Covariant Covariant Maybe (Construction Maybe) a
-> (<:.>) (Tagged 'Root) List a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (TU Covariant Covariant Maybe (Construction Maybe) a
 -> (<:.>) (Tagged 'Root) List a)
-> (Maybe (Identity a)
    -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> Maybe (Identity a)
-> (<:.>) (Tagged 'Root) List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (Identity a -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
-> Maybe (Identity a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall a e r. Monotonic a e => (a -> r) -> r -> e -> r
resolve (Construction Maybe a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> (Identity a -> Construction Maybe a)
-> Identity a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct (a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a)
-> ((Maybe :. Construction Maybe) := a)
-> a
-> Construction Maybe a
forall a b c. (a -> b -> c) -> b -> a -> c
% (Maybe :. Construction Maybe) := a
xs) (a -> Construction Maybe a)
-> (Identity a -> a) -> Identity a -> Construction Maybe a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
forall (source :: * -> * -> *) a.
Extractable Identity source =>
source (Identity a) a
extract @Identity) TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: * -> *) a. Avoidable t => t a
empty
		(Maybe :. Construction Maybe) := a
Nothing -> (((:*:) (Maybe (Identity a)) :. (->) (Maybe (Identity a)))
 := (<:.>) (Tagged 'Root) List a)
-> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a)
forall s a. (((:*:) s :. (->) s) := a) -> Store s a
Store ((((:*:) (Maybe (Identity a)) :. (->) (Maybe (Identity a)))
  := (<:.>) (Tagged 'Root) List a)
 -> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a))
-> (((:*:) (Maybe (Identity a)) :. (->) (Maybe (Identity a)))
    := (<:.>) (Tagged 'Root) List a)
-> Store (Maybe (Identity a)) ((<:.>) (Tagged 'Root) List a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Maybe (Identity a)
forall a. Maybe a
Nothing Maybe (Identity a)
-> (Maybe (Identity a) -> (<:.>) (Tagged 'Root) List a)
-> ((:*:) (Maybe (Identity a)) :. (->) (Maybe (Identity a)))
   := (<:.>) (Tagged 'Root) List a
forall s a. s -> a -> s :*: a
:*: TU Covariant Covariant Maybe (Construction Maybe) a
-> (<:.>) (Tagged 'Root) List a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (TU Covariant Covariant Maybe (Construction Maybe) a
 -> (<:.>) (Tagged 'Root) List a)
-> (Maybe (Identity a)
    -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> Maybe (Identity a)
-> (<:.>) (Tagged 'Root) List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (Identity a -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
-> Maybe (Identity a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall a e r. Monotonic a e => (a -> r) -> r -> e -> r
resolve (Construction Maybe a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> (Identity a -> Construction Maybe a)
-> Identity a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct (a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a)
-> ((Maybe :. Construction Maybe) := a)
-> a
-> Construction Maybe a
forall a b c. (a -> b -> c) -> b -> a -> c
% (Maybe :. Construction Maybe) := a
forall (t :: * -> *) a. Avoidable t => t a
empty) (a -> Construction Maybe a)
-> (Identity a -> a) -> Identity a -> Construction Maybe a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
forall (source :: * -> * -> *) a.
Extractable Identity source =>
source (Identity a) a
extract @Identity) TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: * -> *) a. Avoidable t => t a
empty

instance Substructure Tail List where
	type Available Tail List = Identity
	type Substance Tail List = List
	substructure :: Lens
  (Available 'Tail List)
  ((<:.>) (Tagged 'Tail) List a)
  (Substance 'Tail List a)
substructure = ((<:.>) (Tagged 'Tail) List a
 -> Store
      (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
      ((<:.>) (Tagged 'Tail) List a))
-> P_Q_T
     (->)
     Store
     Identity
     ((<:.>) (Tagged 'Tail) List a)
     (TU Covariant Covariant Maybe (Construction Maybe) a)
forall (p :: * -> * -> *) (q :: * -> * -> *) (t :: * -> *) a b.
p a (q (t b) a) -> P_Q_T p q t a b
P_Q_T (((<:.>) (Tagged 'Tail) List a
  -> Store
       (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
       ((<:.>) (Tagged 'Tail) List a))
 -> P_Q_T
      (->)
      Store
      Identity
      ((<:.>) (Tagged 'Tail) List a)
      (TU Covariant Covariant Maybe (Construction Maybe) a))
-> ((<:.>) (Tagged 'Tail) List a
    -> Store
         (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
         ((<:.>) (Tagged 'Tail) List a))
-> P_Q_T
     (->)
     Store
     Identity
     ((<:.>) (Tagged 'Tail) List a)
     (TU Covariant Covariant Maybe (Construction Maybe) a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \(<:.>) (Tagged 'Tail) List a
x -> case TU Covariant Covariant Maybe (Construction Maybe) a
-> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (TU Covariant Covariant Maybe (Construction Maybe) a
 -> (Maybe :. Construction Maybe) := a)
-> ((<:.>) (Tagged 'Tail) List a
    -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> (<:.>) (Tagged 'Tail) List a
-> (Maybe :. Construction Maybe) := a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Tagged 'Tail (TU Covariant Covariant Maybe (Construction Maybe) a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract (Tagged 'Tail (TU Covariant Covariant Maybe (Construction Maybe) a)
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> ((<:.>) (Tagged 'Tail) List a
    -> Tagged
         'Tail (TU Covariant Covariant Maybe (Construction Maybe) a))
-> (<:.>) (Tagged 'Tail) List a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged 'Tail) List a
-> Tagged
     'Tail (TU Covariant Covariant Maybe (Construction Maybe) a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run ((<:.>) (Tagged 'Tail) List a
 -> (Maybe :. Construction Maybe) := a)
-> (<:.>) (Tagged 'Tail) List a
-> (Maybe :. Construction Maybe) := a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ (<:.>) (Tagged 'Tail) List a
x of
		Just Construction Maybe a
ns -> TU Covariant Covariant Maybe (Construction Maybe) a
-> (<:.>) (Tagged 'Tail) List a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (TU Covariant Covariant Maybe (Construction Maybe) a
 -> (<:.>) (Tagged 'Tail) List a)
-> (Construction Maybe a
    -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> Construction Maybe a
-> (<:.>) (Tagged 'Tail) List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Maybe a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a -> (<:.>) (Tagged 'Tail) List a)
-> Store
     (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
     (Construction Maybe a)
-> Store
     (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
     ((<:.>) (Tagged 'Tail) List a)
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> P_Q_T
  (->)
  Store
  Identity
  (Construction Maybe a)
  (TU Covariant Covariant Maybe (Construction Maybe) a)
-> Construction Maybe a
-> Store
     (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
     (Construction Maybe a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (forall k (segment :: k) (structure :: * -> *).
(Substructure segment structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance segment structure)
:= Available segment structure
forall (structure :: * -> *).
(Substructure 'Tail structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance 'Tail structure)
:= Available 'Tail structure
sub @Tail) Construction Maybe a
ns
		(Maybe :. Construction Maybe) := a
Nothing -> (((:*:)
    (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
  :. (->)
       (Identity (TU Covariant Covariant Maybe (Construction Maybe) a)))
 := (<:.>) (Tagged 'Tail) List a)
-> Store
     (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
     ((<:.>) (Tagged 'Tail) List a)
forall s a. (((:*:) s :. (->) s) := a) -> Store s a
Store ((((:*:)
     (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
   :. (->)
        (Identity (TU Covariant Covariant Maybe (Construction Maybe) a)))
  := (<:.>) (Tagged 'Tail) List a)
 -> Store
      (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
      ((<:.>) (Tagged 'Tail) List a))
-> (((:*:)
       (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
     :. (->)
          (Identity (TU Covariant Covariant Maybe (Construction Maybe) a)))
    := (<:.>) (Tagged 'Tail) List a)
-> Store
     (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
     ((<:.>) (Tagged 'Tail) List a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ TU Covariant Covariant Maybe (Construction Maybe) a
-> Identity (TU Covariant Covariant Maybe (Construction Maybe) a)
forall a. a -> Identity a
Identity TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: * -> *) a. Avoidable t => t a
empty Identity (TU Covariant Covariant Maybe (Construction Maybe) a)
-> (Identity (TU Covariant Covariant Maybe (Construction Maybe) a)
    -> (<:.>) (Tagged 'Tail) List a)
-> ((:*:)
      (Identity (TU Covariant Covariant Maybe (Construction Maybe) a))
    :. (->)
         (Identity (TU Covariant Covariant Maybe (Construction Maybe) a)))
   := (<:.>) (Tagged 'Tail) List a
forall s a. s -> a -> s :*: a
:*: TU Covariant Covariant Maybe (Construction Maybe) a
-> (<:.>) (Tagged 'Tail) List a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (TU Covariant Covariant Maybe (Construction Maybe) a
 -> (<:.>) (Tagged 'Tail) List a)
-> (Identity (TU Covariant Covariant Maybe (Construction Maybe) a)
    -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> Identity (TU Covariant Covariant Maybe (Construction Maybe) a)
-> (<:.>) (Tagged 'Tail) List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. TU Covariant Covariant Maybe (Construction Maybe) a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (m :: * -> * -> *) a. Category m => m a a
identity (TU Covariant Covariant Maybe (Construction Maybe) a
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> (Identity (TU Covariant Covariant Maybe (Construction Maybe) a)
    -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> Identity (TU Covariant Covariant Maybe (Construction Maybe) a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Identity (TU Covariant Covariant Maybe (Construction Maybe) a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract

-- | Transform any traversable structure into a stack
linearize :: forall t a . Traversable t (->) (->) => t a -> List a
linearize :: t a -> List a
linearize = ((Maybe :. Construction Maybe) := a) -> List 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 Maybe) := a) -> List a)
-> (t a -> (Maybe :. Construction Maybe) := a) -> t a -> List a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (((Maybe :. Construction Maybe) := a)
 :*: ((Maybe :. Construction Maybe) := a))
-> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract ((((Maybe :. Construction Maybe) := a)
  :*: ((Maybe :. Construction Maybe) := a))
 -> (Maybe :. Construction Maybe) := a)
-> (t a
    -> ((Maybe :. Construction Maybe) := a)
       :*: ((Maybe :. Construction Maybe) := a))
-> t a
-> (Maybe :. Construction Maybe) := a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (forall a.
Interpreted (State ((Maybe :. Nonempty List) := a)) =>
State ((Maybe :. Nonempty List) := a) a
-> Primary (State ((Maybe :. Nonempty List) := a)) a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run @(State (Maybe :. Nonempty List := a)) (State
   ((Maybe :. Construction Maybe) := a)
   ((Maybe :. Construction Maybe) := a)
 -> ((Maybe :. Construction Maybe) := a)
 -> ((Maybe :. Construction Maybe) := a)
    :*: ((Maybe :. Construction Maybe) := a))
-> ((Maybe :. Construction Maybe) := a)
-> State
     ((Maybe :. Construction Maybe) := a)
     ((Maybe :. Construction Maybe) := a)
-> ((Maybe :. Construction Maybe) := a)
   :*: ((Maybe :. Construction Maybe) := a)
forall a b c. (a -> b -> c) -> b -> a -> c
% (Maybe :. Construction Maybe) := a
forall a. Maybe a
Nothing) (State
   ((Maybe :. Construction Maybe) := a)
   ((Maybe :. Construction Maybe) := a)
 -> ((Maybe :. Construction Maybe) := a)
    :*: ((Maybe :. Construction Maybe) := a))
-> (t a
    -> State
         ((Maybe :. Construction Maybe) := a)
         ((Maybe :. Construction Maybe) := a))
-> t a
-> ((Maybe :. Construction Maybe) := a)
   :*: ((Maybe :. Construction Maybe) := a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (a
 -> ((Maybe :. Construction Maybe) := a)
 -> (Maybe :. Construction Maybe) := a)
-> t a
-> State
     ((Maybe :. Construction Maybe) := a)
     ((Maybe :. Construction Maybe) := a)
forall (t :: * -> *) s (u :: * -> *) a.
(Traversable t (->) (->), Memorable s u) =>
(a -> s -> s) -> t a -> u s
fold (Construction Maybe a -> (Maybe :. Construction Maybe) := a
forall a. a -> Maybe a
Just (Construction Maybe a -> (Maybe :. Construction Maybe) := a)
-> (((->) a :. (->) ((Maybe :. Construction Maybe) := a))
    := Construction Maybe a)
-> a
-> ((Maybe :. Construction Maybe) := a)
-> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) (v :: * -> * -> *) a c d b.
(Covariant t, t ~ v a, Category v) =>
v c d -> ((v a :. v b) := c) -> (v a :. v b) := d
.#.. ((->) a :. (->) ((Maybe :. Construction Maybe) := a))
:= Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct)

----------------------------------------- Non-empty list -------------------------------------------

type instance Nonempty List = Construction Maybe

instance {-# OVERLAPS #-} Semigroup (Construction Maybe a) where
	Construct a
x Maybe (Construction Maybe a)
Nothing + :: Construction Maybe a
-> Construction Maybe a -> Construction Maybe a
+ Construction Maybe a
ys = a -> Maybe (Construction Maybe a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct a
x (Maybe (Construction Maybe a) -> Construction Maybe a)
-> Maybe (Construction Maybe a) -> Construction Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Construction Maybe a -> Maybe (Construction Maybe a)
forall a. a -> Maybe a
Just Construction Maybe a
ys
	Construct a
x (Just Construction Maybe a
xs) + Construction Maybe a
ys = a -> Maybe (Construction Maybe a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct a
x (Maybe (Construction Maybe a) -> Construction Maybe a)
-> (Construction Maybe a -> Maybe (Construction Maybe a))
-> Construction Maybe a
-> Construction Maybe a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Maybe a -> Maybe (Construction Maybe a)
forall a. a -> Maybe a
Just (Construction Maybe a -> Construction Maybe a)
-> Construction Maybe a -> Construction Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Construction Maybe a
xs Construction Maybe a
-> Construction Maybe a -> Construction Maybe a
forall a. Semigroup a => a -> a -> a
+ Construction Maybe a
ys

instance Morphable (Find Element) (Construction Maybe) where
	type Morphing (Find Element) (Construction Maybe) = Predicate <:.:> Maybe := (->)
	morphing :: (<:.>) (Tagged ('Find 'Element)) (Construction Maybe) a
-> Morphing ('Find 'Element) (Construction Maybe) a
morphing ((<:.>) (Tagged ('Find 'Element)) (Construction Maybe) a
-> Construction Maybe a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Construct a
x (Maybe :. Construction Maybe) := a
xs) = (Predicate a -> Maybe a)
-> T_U Covariant Covariant (->) Predicate Maybe a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Predicate a -> Maybe a)
 -> T_U Covariant Covariant (->) Predicate Maybe a)
-> (Predicate a -> Maybe a)
-> T_U Covariant Covariant (->) Predicate Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \Predicate a
p ->
		Predicate a -> a -> Boolean
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run Predicate a
p a
x Boolean -> Maybe a -> Maybe a -> Maybe a
forall a. Boolean -> a -> a -> a
? a -> Maybe a
forall a. a -> Maybe a
Just a
x (Maybe a -> Maybe a) -> Maybe a -> Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ forall a2.
Morphed
  ('Find 'Element)
  (Nonempty List)
  ((Predicate <:.:> Maybe) := (->)) =>
Predicate a2 -> Nonempty List a2 -> Maybe a2
forall a1 (mod :: a1) (struct :: * -> *) (result :: * -> *) a2.
Morphed ('Find mod) struct ((Predicate <:.:> result) := (->)) =>
Predicate a2 -> struct a2 -> result a2
find @Element @(Nonempty List) @Maybe (Predicate a -> Construction Maybe a -> Maybe a)
-> Predicate a -> Construction Maybe a -> Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Predicate a
p (Construction Maybe a -> Maybe a)
-> ((Maybe :. Construction Maybe) := a) -> Maybe a
forall (t :: * -> *) (source :: * -> * -> *) a b.
Bindable t source =>
source a (t b) -> source (t a) (t b)
=<< (Maybe :. Construction Maybe) := a
xs

instance Morphable (Into List) (Construction Maybe) where
	type Morphing (Into List) (Construction Maybe) = List
	morphing :: (<:.>) (Tagged ('Into List)) (Construction Maybe) a
-> Morphing ('Into List) (Construction Maybe) a
morphing = Construction Maybe a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> ((<:.>) (Tagged ('Into List)) (Construction Maybe) a
    -> Construction Maybe a)
-> (<:.>) (Tagged ('Into List)) (Construction Maybe) a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged ('Into List)) (Construction Maybe) a
-> Construction Maybe a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph

instance Morphable Push (Construction Maybe) where
	type Morphing Push (Construction Maybe) = Identity <:.:> Construction Maybe := (->)
	morphing :: (<:.>) (Tagged 'Push) (Construction Maybe) a
-> Morphing 'Push (Construction Maybe) a
morphing ((<:.>) (Tagged 'Push) (Construction Maybe) a
-> Construction Maybe a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Construction Maybe a
xs) = (Identity a -> Construction Maybe a)
-> T_U Covariant Covariant (->) Identity (Construction Maybe) a
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U ((Identity a -> Construction Maybe a)
 -> T_U Covariant Covariant (->) Identity (Construction Maybe) a)
-> (Identity a -> Construction Maybe a)
-> T_U Covariant Covariant (->) Identity (Construction Maybe) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \(Identity a
x) -> a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct a
x (((Maybe :. Construction Maybe) := a) -> Construction Maybe a)
-> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Construction Maybe a -> (Maybe :. Construction Maybe) := a
forall a. a -> Maybe a
Just Construction Maybe a
xs

instance Measurable Length (Construction Maybe) where
	type Measural Length (Construction Maybe) a = Denumerator
	measurement :: Tagged 'Length (Construction Maybe a)
-> Measural 'Length (Construction Maybe) a
measurement (Construction Maybe a -> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) a.
Construction t a -> (t :. Construction t) := a
deconstruct (Construction Maybe a -> (Maybe :. Construction Maybe) := a)
-> (Tagged 'Length (Construction Maybe a) -> Construction Maybe a)
-> Tagged 'Length (Construction Maybe a)
-> (Maybe :. Construction Maybe) := a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Tagged 'Length (Construction Maybe a) -> Construction Maybe a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract -> (Maybe :. Construction Maybe) := a
Nothing) = Denumerator
Measural 'Length (Construction Maybe) a
One
	measurement (Construction Maybe a -> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) a.
Construction t a -> (t :. Construction t) := a
deconstruct (Construction Maybe a -> (Maybe :. Construction Maybe) := a)
-> (Tagged 'Length (Construction Maybe a) -> Construction Maybe a)
-> Tagged 'Length (Construction Maybe a)
-> (Maybe :. Construction Maybe) := a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Tagged 'Length (Construction Maybe a) -> Construction Maybe a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract -> Just Construction Maybe a
xs) = Denumerator
One Denumerator -> Denumerator -> Denumerator
forall a. Semigroup a => a -> a -> a
+ Construction Maybe a -> Measural 'Length (Construction Maybe) a
forall k (f :: k) (t :: * -> *) a.
Measurable f t =>
t a -> Measural f t a
measure @Length Construction Maybe a
xs

instance Substructure Root (Construction Maybe) where
	type Available Root (Construction Maybe) = Identity
	type Substance Root (Construction Maybe) = Identity
	substructure :: Lens
  (Available 'Root (Construction Maybe))
  ((<:.>) (Tagged 'Root) (Construction Maybe) a)
  (Substance 'Root (Construction Maybe) a)
substructure = ((<:.>) (Tagged 'Root) (Construction Maybe) a -> Identity a)
-> ((<:.>) (Tagged 'Root) (Construction Maybe) a
    -> Identity a -> (<:.>) (Tagged 'Root) (Construction Maybe) a)
-> Lens
     Identity
     ((<:.>) (Tagged 'Root) (Construction Maybe) a)
     (Identity a)
forall k (result :: k). Impliable result => Arguments result
imply @(Convex Lens _ _) (a -> Identity a
forall a. a -> Identity a
Identity (a -> Identity a)
-> ((<:.>) (Tagged 'Root) (Construction Maybe) a -> a)
-> (<:.>) (Tagged 'Root) (Construction Maybe) a
-> Identity a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Maybe a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract (Construction Maybe a -> a)
-> ((<:.>) (Tagged 'Root) (Construction Maybe) a
    -> Construction Maybe a)
-> (<:.>) (Tagged 'Root) (Construction Maybe) a
-> a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged 'Root) (Construction Maybe) a
-> Construction Maybe a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Lowerable t, Covariant_ u (->) (->)) =>
t u ~> u
lower)
		(\(<:.>) (Tagged 'Root) (Construction Maybe) a
source Identity a
target -> Construction Maybe a
-> (<:.>) (Tagged 'Root) (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a
 -> (<:.>) (Tagged 'Root) (Construction Maybe) a)
-> Construction Maybe a
-> (<:.>) (Tagged 'Root) (Construction Maybe) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct (a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a)
-> a
-> ((Maybe :. Construction Maybe) := a)
-> Construction Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Identity a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract Identity a
target (((Maybe :. Construction Maybe) := a) -> Construction Maybe a)
-> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Construction Maybe a -> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) a.
Construction t a -> (t :. Construction t) := a
deconstruct ((<:.>) (Tagged 'Root) (Construction Maybe) a
-> Construction Maybe a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Lowerable t, Covariant_ u (->) (->)) =>
t u ~> u
lower (<:.>) (Tagged 'Root) (Construction Maybe) a
source))

instance Substructure Tail (Construction Maybe) where
	type Available Tail (Construction Maybe) = Identity
	type Substance Tail (Construction Maybe) = List
	substructure :: Lens
  (Available 'Tail (Construction Maybe))
  ((<:.>) (Tagged 'Tail) (Construction Maybe) a)
  (Substance 'Tail (Construction Maybe) a)
substructure = ((<:.>) (Tagged 'Tail) (Construction Maybe) a
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> ((<:.>) (Tagged 'Tail) (Construction Maybe) a
    -> TU Covariant Covariant Maybe (Construction Maybe) a
    -> (<:.>) (Tagged 'Tail) (Construction Maybe) a)
-> Lens
     Identity
     ((<:.>) (Tagged 'Tail) (Construction Maybe) a)
     (TU Covariant Covariant Maybe (Construction Maybe) a)
forall k (result :: k). Impliable result => Arguments result
imply @(Convex Lens _ _) (((Maybe :. Construction Maybe) := a)
-> TU Covariant Covariant Maybe (Construction Maybe) 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 Maybe) := a)
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> ((<:.>) (Tagged 'Tail) (Construction Maybe) a
    -> (Maybe :. Construction Maybe) := a)
-> (<:.>) (Tagged 'Tail) (Construction Maybe) a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Maybe a -> (Maybe :. Construction Maybe) := a
forall (t :: * -> *) a.
Construction t a -> (t :. Construction t) := a
deconstruct (Construction Maybe a -> (Maybe :. Construction Maybe) := a)
-> ((<:.>) (Tagged 'Tail) (Construction Maybe) a
    -> Construction Maybe a)
-> (<:.>) (Tagged 'Tail) (Construction Maybe) a
-> (Maybe :. Construction Maybe) := a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged 'Tail) (Construction Maybe) a
-> Construction Maybe a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Lowerable t, Covariant_ u (->) (->)) =>
t u ~> u
lower)
		(\(<:.>) (Tagged 'Tail) (Construction Maybe) a
source TU Covariant Covariant Maybe (Construction Maybe) a
target -> Construction Maybe a
-> (<:.>) (Tagged 'Tail) (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a
 -> (<:.>) (Tagged 'Tail) (Construction Maybe) a)
-> Construction Maybe a
-> (<:.>) (Tagged 'Tail) (Construction Maybe) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (t :: * -> *) a.
a -> ((t :. Construction t) := a) -> Construction t a
Construct (a -> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a)
-> a
-> ((Maybe :. Construction Maybe) := a)
-> Construction Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Construction Maybe a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract ((<:.>) (Tagged 'Tail) (Construction Maybe) a
-> Construction Maybe a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Lowerable t, Covariant_ u (->) (->)) =>
t u ~> u
lower (<:.>) (Tagged 'Tail) (Construction Maybe) a
source) (((Maybe :. Construction Maybe) := a) -> Construction Maybe a)
-> ((Maybe :. Construction Maybe) := a) -> Construction Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# TU Covariant Covariant Maybe (Construction Maybe) a
-> Primary List a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run TU Covariant Covariant Maybe (Construction Maybe) a
target)

---------------------------------------- Combinative list ------------------------------------------

type instance Combinative List = Comprehension Maybe

----------------------------------------- Zipper of list -------------------------------------------

type instance Zipper List (Left ::: Right) = Tap (List <:.:> List := (:*:))

--instance {-# OVERLAPS #-} Applicative (Tap (List <:.:> List := (:*:))) where
	--Tap f (T_U (lfs :*: rfs)) <*> Tap x (T_U (ls :*: rs)) = Tap # f x # T_U (lfs <*> ls :*: rfs <*> rs)

instance {-# OVERLAPS #-} Traversable (Tap (List <:.:> List := (:*:))) (->) (->) where
	a -> u b
f <<- :: (a -> u b)
-> Tap ((List <:.:> List) := (:*:)) a
-> u (Tap ((List <:.:> List) := (:*:)) b)
<<- Tap a
x (T_U (List a
future :*: List a
past)) = (\Reverse List b
past' b
x' List b
future' -> b
-> T_U Covariant Covariant (:*:) List List b
-> Tap ((List <:.:> List) := (:*:)) b
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap b
x' (T_U Covariant Covariant (:*:) List List b
 -> Tap ((List <:.:> List) := (:*:)) b)
-> T_U Covariant Covariant (:*:) List List b
-> Tap ((List <:.:> List) := (:*:)) b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ List b -> List b -> T_U Covariant Covariant (:*:) List List b
forall k (t :: k -> *) (a :: k) (u :: k -> *).
t a -> u a -> (<:.:>) t u (:*:) a
twosome (List b -> List b -> T_U Covariant Covariant (:*:) List List b)
-> List b -> List b -> T_U Covariant Covariant (:*:) List List b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# List b
future' (List b -> T_U Covariant Covariant (:*:) List List b)
-> List b -> T_U Covariant Covariant (:*:) List List b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Reverse List b -> Primary (Reverse List) b
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run Reverse List b
past')
		(Reverse List b
 -> b -> List b -> Tap ((List <:.:> List) := (:*:)) b)
-> u (Reverse List b)
-> u (b -> List b -> Tap ((List <:.:> List) := (:*:)) b)
forall (t :: * -> *) (source :: * -> * -> *)
       (target :: * -> * -> *) a b.
Covariant_ t source target =>
source a b -> target (t a) (t b)
-<$>- a -> u b
f (a -> u b) -> Reverse List a -> u (Reverse List b)
forall (t :: * -> *) (source :: * -> * -> *)
       (target :: * -> * -> *) (u :: * -> *) a b.
(Traversable t source target, Covariant_ u source target,
 Pointable u target, Semimonoidal u (:*:) source target) =>
source a (u b) -> target (t a) (u (t b))
<<- List a -> Reverse List a
forall k (t :: k -> *) (a :: k). t a -> Reverse t a
Reverse List a
past u (b -> List b -> Tap ((List <:.:> List) := (:*:)) b)
-> u b -> u (List b -> Tap ((List <:.:> List) := (:*:)) b)
forall a b (t :: * -> *).
Semimonoidal t (:*:) (->) (->) =>
t (a -> b) -> t a -> t b
-<*>- a -> u b
f a
x u (List b -> Tap ((List <:.:> List) := (:*:)) b)
-> u (List b) -> u (Tap ((List <:.:> List) := (:*:)) b)
forall a b (t :: * -> *).
Semimonoidal t (:*:) (->) (->) =>
t (a -> b) -> t a -> t b
-<*>- a -> u b
f (a -> u b) -> List a -> u (List b)
forall (t :: * -> *) (source :: * -> * -> *)
       (target :: * -> * -> *) (u :: * -> *) a b.
(Traversable t source target, Covariant_ u source target,
 Pointable u target, Semimonoidal u (:*:) source target) =>
source a (u b) -> target (t a) (u (t b))
<<- List a
future

instance {-# OVERLAPS #-} Extendable (Tap (List <:.:> List := (:*:))) (->) where
	Tap ((List <:.:> List) := (:*:)) a -> b
f <<= :: (Tap ((List <:.:> List) := (:*:)) a -> b)
-> Tap ((List <:.:> List) := (:*:)) a
-> Tap ((List <:.:> List) := (:*:)) b
<<= Tap ((List <:.:> List) := (:*:)) a
z = let move :: (Tap ((List <:.:> List) := (:*:)) a
 -> (<:.>) Maybe (Tap ((List <:.:> List) := (:*:))) a)
-> TU
     Covariant
     Covariant
     Maybe
     (Construction Maybe)
     (Tap ((List <:.:> List) := (:*:)) a)
move Tap ((List <:.:> List) := (:*:)) a
-> (<:.>) Maybe (Tap ((List <:.:> List) := (:*:))) a
rtt = ((Maybe :. Construction Maybe)
 := Tap ((List <:.:> List) := (:*:)) a)
-> TU
     Covariant
     Covariant
     Maybe
     (Construction Maybe)
     (Tap ((List <:.:> List) := (:*:)) 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 Maybe)
  := Tap ((List <:.:> List) := (:*:)) a)
 -> TU
      Covariant
      Covariant
      Maybe
      (Construction Maybe)
      (Tap ((List <:.:> List) := (:*:)) a))
-> (Construction Maybe (Tap ((List <:.:> List) := (:*:)) a)
    -> (Maybe :. Construction Maybe)
       := Tap ((List <:.:> List) := (:*:)) a)
-> Construction Maybe (Tap ((List <:.:> List) := (:*:)) a)
-> TU
     Covariant
     Covariant
     Maybe
     (Construction Maybe)
     (Tap ((List <:.:> List) := (:*:)) a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Maybe (Tap ((List <:.:> List) := (:*:)) a)
-> (Maybe :. Construction Maybe)
   := Tap ((List <:.:> List) := (:*:)) a
forall (t :: * -> *) a.
Construction t a -> (t :. Construction t) := a
deconstruct (Construction Maybe (Tap ((List <:.:> List) := (:*:)) a)
 -> TU
      Covariant
      Covariant
      Maybe
      (Construction Maybe)
      (Tap ((List <:.:> List) := (:*:)) a))
-> Construction Maybe (Tap ((List <:.:> List) := (:*:)) a)
-> TU
     Covariant
     Covariant
     Maybe
     (Construction Maybe)
     (Tap ((List <:.:> List) := (:*:)) a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ (<:.>) Maybe (Tap ((List <:.:> List) := (:*:))) a
-> Maybe (Tap ((List <:.:> List) := (:*:)) a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run ((<:.>) Maybe (Tap ((List <:.:> List) := (:*:))) a
 -> Maybe (Tap ((List <:.:> List) := (:*:)) a))
-> (Tap ((List <:.:> List) := (:*:)) a
    -> (<:.>) Maybe (Tap ((List <:.:> List) := (:*:))) a)
-> Tap ((List <:.:> List) := (:*:)) a
-> Maybe (Tap ((List <:.:> List) := (:*:)) a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Tap ((List <:.:> List) := (:*:)) a
-> (<:.>) Maybe (Tap ((List <:.:> List) := (:*:))) a
rtt (Tap ((List <:.:> List) := (:*:)) a
 -> Maybe (Tap ((List <:.:> List) := (:*:)) a))
-> Tap ((List <:.:> List) := (:*:)) a :=> Construction Maybe
forall (t :: * -> *) a.
Covariant t =>
(a :=> t) -> a :=> Construction t
.-+ Tap ((List <:.:> List) := (:*:)) a
z in
		b
-> (:=) (List <:.:> List) (:*:) b
-> Tap ((List <:.:> List) := (:*:)) b
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap (b
 -> (:=) (List <:.:> List) (:*:) b
 -> Tap ((List <:.:> List) := (:*:)) b)
-> b
-> (:=) (List <:.:> List) (:*:) b
-> Tap ((List <:.:> List) := (:*:)) b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Tap ((List <:.:> List) := (:*:)) a -> b
f Tap ((List <:.:> List) := (:*:)) a
z ((:=) (List <:.:> List) (:*:) b
 -> Tap ((List <:.:> List) := (:*:)) b)
-> (:=) (List <:.:> List) (:*:) b
-> Tap ((List <:.:> List) := (:*:)) b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ List b -> List b -> (:=) (List <:.:> List) (:*:) b
forall k (t :: k -> *) (a :: k) (u :: k -> *).
t a -> u a -> (<:.:>) t u (:*:) a
twosome (List b -> List b -> (:=) (List <:.:> List) (:*:) b)
-> List b -> List b -> (:=) (List <:.:> List) (:*:) b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Tap ((List <:.:> List) := (:*:)) a -> b
f (Tap ((List <:.:> List) := (:*:)) a -> b)
-> TU
     Covariant
     Covariant
     Maybe
     (Construction Maybe)
     (Tap ((List <:.:> List) := (:*:)) a)
-> List b
forall (t :: * -> *) (source :: * -> * -> *)
       (target :: * -> * -> *) a b.
Covariant_ t source target =>
source a b -> target (t a) (t b)
-<$>- (Tap ((List <:.:> List) := (:*:)) a
 -> (<:.>) Maybe (Tap ((List <:.:> List) := (:*:))) a)
-> TU
     Covariant
     Covariant
     Maybe
     (Construction Maybe)
     (Tap ((List <:.:> List) := (:*:)) a)
move (forall a (mod :: a) (struct :: * -> *).
Morphable ('Rotate mod) struct =>
struct ~> Morphing ('Rotate mod) struct
forall (struct :: * -> *).
Morphable ('Rotate 'Left) struct =>
struct ~> Morphing ('Rotate 'Left) struct
rotate @Left) (List b -> (:=) (List <:.:> List) (:*:) b)
-> List b -> (:=) (List <:.:> List) (:*:) b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Tap ((List <:.:> List) := (:*:)) a -> b
f (Tap ((List <:.:> List) := (:*:)) a -> b)
-> TU
     Covariant
     Covariant
     Maybe
     (Construction Maybe)
     (Tap ((List <:.:> List) := (:*:)) a)
-> List b
forall (t :: * -> *) (source :: * -> * -> *)
       (target :: * -> * -> *) a b.
Covariant_ t source target =>
source a b -> target (t a) (t b)
-<$>- (Tap ((List <:.:> List) := (:*:)) a
 -> (<:.>) Maybe (Tap ((List <:.:> List) := (:*:))) a)
-> TU
     Covariant
     Covariant
     Maybe
     (Construction Maybe)
     (Tap ((List <:.:> List) := (:*:)) a)
move (forall a (mod :: a) (struct :: * -> *).
Morphable ('Rotate mod) struct =>
struct ~> Morphing ('Rotate mod) struct
forall (struct :: * -> *).
Morphable ('Rotate 'Right) struct =>
struct ~> Morphing ('Rotate 'Right) struct
rotate @Right)

instance Morphable (Rotate Left) (Tap (List <:.:> List := (:*:))) where
	type Morphing (Rotate Left) (Tap (List <:.:> List := (:*:))) = Maybe <:.> Tap (List <:.:> List := (:*:))
	morphing :: (<:.>)
  (Tagged ('Rotate 'Left)) (Tap ((List <:.:> List) := (:*:))) a
-> Morphing ('Rotate 'Left) (Tap ((List <:.:> List) := (:*:))) a
morphing ((<:.>)
  (Tagged ('Rotate 'Left)) (Tap ((List <:.:> List) := (:*:))) a
-> Tap ((List <:.:> List) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap a
x (T_U (List a
future :*: List a
past))) =
		let subtree :: T_U Covariant Covariant (:*:) List List a
subtree = List a -> List a -> T_U Covariant Covariant (:*:) List List a
forall k (t :: k -> *) (a :: k) (u :: k -> *).
t a -> u a -> (<:.:>) t u (:*:) a
twosome (List a -> List a -> T_U Covariant Covariant (:*:) List List a)
-> List a -> List a -> T_U Covariant Covariant (:*:) List List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Identity (List a) -> List a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract (Lens Identity (List a) (List a) -> List a -> Identity (List a)
forall (available :: * -> *) source target.
Lens available source target -> source -> available target
view (forall k (segment :: k) (structure :: * -> *).
(Substructure segment structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance segment structure)
:= Available segment structure
forall (structure :: * -> *).
(Substructure 'Tail structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance 'Tail structure)
:= Available 'Tail structure
sub @Tail) List a
future) (List a -> T_U Covariant Covariant (:*:) List List a)
-> List a -> T_U Covariant Covariant (:*:) List List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# a :=:=> List
forall k (mod :: k) (struct :: * -> *) a.
Morphed mod struct ((Identity <:.:> struct) := (->)) =>
a :=:=> struct
item @Push a
x List a
past in
		((Maybe :. Tap ((List <:.:> List) := (:*:))) := a)
-> TU
     Covariant Covariant Maybe (Tap ((List <:.:> List) := (:*:))) 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 :. Tap ((List <:.:> List) := (:*:))) := a)
 -> TU
      Covariant Covariant Maybe (Tap ((List <:.:> List) := (:*:))) a)
-> ((Maybe :. Tap ((List <:.:> List) := (:*:))) := a)
-> TU
     Covariant Covariant Maybe (Tap ((List <:.:> List) := (:*:))) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ (a
-> T_U Covariant Covariant (:*:) List List a
-> Tap ((List <:.:> List) := (:*:)) a
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap (a
 -> T_U Covariant Covariant (:*:) List List a
 -> Tap ((List <:.:> List) := (:*:)) a)
-> (Identity a -> a)
-> Identity a
-> T_U Covariant Covariant (:*:) List List a
-> Tap ((List <:.:> List) := (:*:)) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Identity a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract) (Identity a
 -> T_U Covariant Covariant (:*:) List List a
 -> Tap ((List <:.:> List) := (:*:)) a)
-> T_U Covariant Covariant (:*:) List List a
-> Identity a
-> Tap ((List <:.:> List) := (:*:)) a
forall a b c. (a -> b -> c) -> b -> a -> c
% T_U Covariant Covariant (:*:) List List a
subtree (Identity a -> Tap ((List <:.:> List) := (:*:)) a)
-> Maybe (Identity a)
-> (Maybe :. Tap ((List <:.:> List) := (:*:))) := a
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> Lens Maybe (List a) (Identity a) -> List a -> Maybe (Identity a)
forall (available :: * -> *) source target.
Lens available source target -> source -> available target
view (forall k (segment :: k) (structure :: * -> *).
(Substructure segment structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance segment structure)
:= Available segment structure
forall (structure :: * -> *).
(Substructure 'Root structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance 'Root structure)
:= Available 'Root structure
sub @Root) List a
future

instance Morphable (Rotate Right) (Tap (List <:.:> List := (:*:))) where
	type Morphing (Rotate Right) (Tap (List <:.:> List := (:*:))) = Maybe <:.> Tap (List <:.:> List := (:*:))
	morphing :: (<:.>)
  (Tagged ('Rotate 'Right)) (Tap ((List <:.:> List) := (:*:))) a
-> Morphing ('Rotate 'Right) (Tap ((List <:.:> List) := (:*:))) a
morphing ((<:.>)
  (Tagged ('Rotate 'Right)) (Tap ((List <:.:> List) := (:*:))) a
-> Tap ((List <:.:> List) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap a
x (T_U (List a
future :*: List a
past))) =
		let subtree :: T_U Covariant Covariant (:*:) List List a
subtree = List a -> List a -> T_U Covariant Covariant (:*:) List List a
forall k (t :: k -> *) (a :: k) (u :: k -> *).
t a -> u a -> (<:.:>) t u (:*:) a
twosome (List a -> List a -> T_U Covariant Covariant (:*:) List List a)
-> List a -> List a -> T_U Covariant Covariant (:*:) List List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# a :=:=> List
forall k (mod :: k) (struct :: * -> *) a.
Morphed mod struct ((Identity <:.:> struct) := (->)) =>
a :=:=> struct
item @Push a
x List a
future (List a -> T_U Covariant Covariant (:*:) List List a)
-> List a -> T_U Covariant Covariant (:*:) List List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Identity (List a) -> List a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract (Lens Identity (List a) (List a) -> List a -> Identity (List a)
forall (available :: * -> *) source target.
Lens available source target -> source -> available target
view (forall k (segment :: k) (structure :: * -> *).
(Substructure segment structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance segment structure)
:= Available segment structure
forall (structure :: * -> *).
(Substructure 'Tail structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance 'Tail structure)
:= Available 'Tail structure
sub @Tail) List a
past) in
		((Maybe :. Tap ((List <:.:> List) := (:*:))) := a)
-> TU
     Covariant Covariant Maybe (Tap ((List <:.:> List) := (:*:))) 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 :. Tap ((List <:.:> List) := (:*:))) := a)
 -> TU
      Covariant Covariant Maybe (Tap ((List <:.:> List) := (:*:))) a)
-> ((Maybe :. Tap ((List <:.:> List) := (:*:))) := a)
-> TU
     Covariant Covariant Maybe (Tap ((List <:.:> List) := (:*:))) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ (a
-> T_U Covariant Covariant (:*:) List List a
-> Tap ((List <:.:> List) := (:*:)) a
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap (a
 -> T_U Covariant Covariant (:*:) List List a
 -> Tap ((List <:.:> List) := (:*:)) a)
-> (Identity a -> a)
-> Identity a
-> T_U Covariant Covariant (:*:) List List a
-> Tap ((List <:.:> List) := (:*:)) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Identity a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract) (Identity a
 -> T_U Covariant Covariant (:*:) List List a
 -> Tap ((List <:.:> List) := (:*:)) a)
-> T_U Covariant Covariant (:*:) List List a
-> Identity a
-> Tap ((List <:.:> List) := (:*:)) a
forall a b c. (a -> b -> c) -> b -> a -> c
% T_U Covariant Covariant (:*:) List List a
subtree (Identity a -> Tap ((List <:.:> List) := (:*:)) a)
-> Maybe (Identity a)
-> (Maybe :. Tap ((List <:.:> List) := (:*:))) := a
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> Lens Maybe (List a) (Identity a) -> List a -> Maybe (Identity a)
forall (available :: * -> *) source target.
Lens available source target -> source -> available target
view (forall k (segment :: k) (structure :: * -> *).
(Substructure segment structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance segment structure)
:= Available segment structure
forall (structure :: * -> *).
(Substructure 'Root structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance 'Root structure)
:= Available 'Root structure
sub @Root) List a
past

instance Morphable (Into (Tap (List <:.:> List := (:*:)))) List where
	type Morphing (Into (Tap (List <:.:> List := (:*:)))) List = Maybe <:.> Tap (List <:.:> List := (:*:))
	morphing :: (<:.>) (Tagged ('Into (Tap ((List <:.:> List) := (:*:))))) List a
-> Morphing ('Into (Tap ((List <:.:> List) := (:*:)))) List a
morphing ((<:.>) (Tagged ('Into (Tap ((List <:.:> List) := (:*:))))) List a
-> List a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> List a
list) = (forall a (mod :: a) (struct :: * -> *).
Morphable ('Into mod) struct =>
struct ~> Morphing ('Into mod) struct
forall (struct :: * -> *).
Morphable ('Into (Zipper List ('Left ::: 'Right))) struct =>
struct ~> Morphing ('Into (Zipper List ('Left ::: 'Right))) struct
into @(Zipper List (Left ::: Right)) (Construction Maybe a -> Tap ((List <:.:> List) := (:*:)) a)
-> Maybe (Construction Maybe a)
-> Maybe (Tap ((List <:.:> List) := (:*:)) a)
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$>) (Primary List a
 -> Primary
      (TU Covariant Covariant Maybe (Tap ((List <:.:> List) := (:*:))))
      a)
-> List a
-> TU
     Covariant Covariant Maybe (Tap ((List <:.:> List) := (:*:))) a
forall (t :: * -> *) (u :: * -> *) a b.
(Interpreted t, Interpreted u) =>
(Primary t a -> Primary u b) -> t a -> u b
||= List a
list

instance Morphable (Into List) (Tap (List <:.:> List := (:*:))) where
	type Morphing (Into List) (Tap (List <:.:> List := (:*:))) = List
	morphing :: (<:.>) (Tagged ('Into List)) (Tap ((List <:.:> List) := (:*:))) a
-> Morphing ('Into List) (Tap ((List <:.:> List) := (:*:))) a
morphing ((<:.>) (Tagged ('Into List)) (Tap ((List <:.:> List) := (:*:))) a
-> Tap ((List <:.:> List) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap a
x (T_U (List a
future :*: List a
past))) = (List a
 :*: TU Covariant Covariant Maybe (Construction Maybe) (List a))
-> List a
forall a b. (a :*: b) -> a
attached ((List a
  :*: TU Covariant Covariant Maybe (Construction Maybe) (List a))
 -> List a)
-> (List a
    :*: TU Covariant Covariant Maybe (Construction Maybe) (List a))
-> List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ forall a.
Interpreted (State (List a)) =>
State (List a) a -> Primary (State (List a)) a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run @(State _)
		# modify . item @Push @List <<- past
		# item @Push x future

instance Morphable (Into (Comprehension Maybe)) (Tap (List <:.:> List := (:*:))) where
	type Morphing (Into (Comprehension Maybe)) (Tap (List <:.:> List := (:*:))) = Comprehension Maybe
	morphing :: (<:.>)
  (Tagged ('Into (Comprehension Maybe)))
  (Tap ((List <:.:> List) := (:*:)))
  a
-> Morphing
     ('Into (Comprehension Maybe)) (Tap ((List <:.:> List) := (:*:))) a
morphing ((<:.>)
  (Tagged ('Into (Comprehension Maybe)))
  (Tap ((List <:.:> List) := (:*:)))
  a
-> Tap ((List <:.:> List) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap a
x (T_U (List a
future :*: List a
past))) = (Comprehension Maybe a
 :*: TU
       Covariant
       Covariant
       Maybe
       (Construction Maybe)
       (Comprehension Maybe a))
-> Comprehension Maybe a
forall a b. (a :*: b) -> a
attached ((Comprehension Maybe a
  :*: TU
        Covariant
        Covariant
        Maybe
        (Construction Maybe)
        (Comprehension Maybe a))
 -> Comprehension Maybe a)
-> (Comprehension Maybe a
    :*: TU
          Covariant
          Covariant
          Maybe
          (Construction Maybe)
          (Comprehension Maybe a))
-> Comprehension Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ forall a.
Interpreted (State (Comprehension Maybe a)) =>
State (Comprehension Maybe a) a
-> Primary (State (Comprehension Maybe a)) a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run @(State _)
		# modify . item @Push @(Comprehension Maybe) <<- past
		# item @Push x (Comprehension future)

------------------------------------- Zipper of non-empty list -------------------------------------

type instance Zipper (Construction Maybe) (Left ::: Right) = Tap (Construction Maybe <:.:> Construction Maybe := (:*:))

instance Morphable (Rotate Left) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) where
	type Morphing (Rotate Left) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) =
		Maybe <:.> Tap (Construction Maybe <:.:> Construction Maybe := (:*:))
	morphing :: (<:.>)
  (Tagged ('Rotate 'Left))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Morphing
     ('Rotate 'Left)
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     a
morphing ((<:.>)
  (Tagged ('Rotate 'Left))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap a
x (T_U (Construction Maybe a
future :*: Construction Maybe a
past))) = ((Maybe
  :. Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
 := a)
-> TU
     Covariant
     Covariant
     Maybe
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     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
   :. Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  := a)
 -> TU
      Covariant
      Covariant
      Maybe
      (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
      a)
-> ((Maybe
     :. Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
    := a)
-> TU
     Covariant
     Covariant
     Maybe
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ a
-> T_U
     Covariant
     Covariant
     (:*:)
     (Construction Maybe)
     (Construction Maybe)
     a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap (Construction Maybe a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract Construction Maybe a
future) (T_U
   Covariant
   Covariant
   (:*:)
   (Construction Maybe)
   (Construction Maybe)
   a
 -> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a)
-> (Construction Maybe a
    -> T_U
         Covariant
         Covariant
         (:*:)
         (Construction Maybe)
         (Construction Maybe)
         a)
-> Construction Maybe a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Maybe a
-> Construction Maybe a
-> T_U
     Covariant
     Covariant
     (:*:)
     (Construction Maybe)
     (Construction Maybe)
     a
forall k (t :: k -> *) (a :: k) (u :: k -> *).
t a -> u a -> (<:.:>) t u (:*:) a
twosome (Construction Maybe a
 -> Construction Maybe a
 -> T_U
      Covariant
      Covariant
      (:*:)
      (Construction Maybe)
      (Construction Maybe)
      a)
-> Construction Maybe a
-> Construction Maybe a
-> T_U
     Covariant
     Covariant
     (:*:)
     (Construction Maybe)
     (Construction Maybe)
     a
forall a b c. (a -> b -> c) -> b -> a -> c
% a :=:=> Construction Maybe
forall k (mod :: k) (struct :: * -> *) a.
Morphed mod struct ((Identity <:.:> struct) := (->)) =>
a :=:=> struct
item @Push a
x Construction Maybe a
past (Construction Maybe a
 -> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a)
-> Maybe (Construction Maybe a)
-> (Maybe
    :. Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
   := a
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> Construction Maybe a -> Maybe (Construction Maybe a)
forall (t :: * -> *) a.
Construction t a -> (t :. Construction t) := a
deconstruct Construction Maybe a
future

instance Morphable (Rotate Right) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) where
	type Morphing (Rotate Right) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) =
		Maybe <:.> Tap (Construction Maybe <:.:> Construction Maybe := (:*:))
	morphing :: (<:.>)
  (Tagged ('Rotate 'Right))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Morphing
     ('Rotate 'Right)
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     a
morphing ((<:.>)
  (Tagged ('Rotate 'Right))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap a
x (T_U (Construction Maybe a
future :*: Construction Maybe a
past))) = ((Maybe
  :. Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
 := a)
-> TU
     Covariant
     Covariant
     Maybe
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     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
   :. Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  := a)
 -> TU
      Covariant
      Covariant
      Maybe
      (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
      a)
-> ((Maybe
     :. Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
    := a)
-> TU
     Covariant
     Covariant
     Maybe
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ a
-> T_U
     Covariant
     Covariant
     (:*:)
     (Construction Maybe)
     (Construction Maybe)
     a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap (Construction Maybe a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract Construction Maybe a
past) (T_U
   Covariant
   Covariant
   (:*:)
   (Construction Maybe)
   (Construction Maybe)
   a
 -> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a)
-> (Construction Maybe a
    -> T_U
         Covariant
         Covariant
         (:*:)
         (Construction Maybe)
         (Construction Maybe)
         a)
-> Construction Maybe a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. Construction Maybe a
-> Construction Maybe a
-> T_U
     Covariant
     Covariant
     (:*:)
     (Construction Maybe)
     (Construction Maybe)
     a
forall k (t :: k -> *) (a :: k) (u :: k -> *).
t a -> u a -> (<:.:>) t u (:*:) a
twosome (a :=:=> Construction Maybe
forall k (mod :: k) (struct :: * -> *) a.
Morphed mod struct ((Identity <:.:> struct) := (->)) =>
a :=:=> struct
item @Push a
x Construction Maybe a
future) (Construction Maybe a
 -> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a)
-> Maybe (Construction Maybe a)
-> (Maybe
    :. Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
   := a
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> Construction Maybe a -> Maybe (Construction Maybe a)
forall (t :: * -> *) a.
Construction t a -> (t :. Construction t) := a
deconstruct Construction Maybe a
past

instance Morphable (Into (Tap (List <:.:> List := (:*:)))) (Construction Maybe) where
	type Morphing (Into (Tap (List <:.:> List := (:*:)))) (Construction Maybe) = Tap (List <:.:> List := (:*:))
	morphing :: (<:.>)
  (Tagged ('Into (Tap ((List <:.:> List) := (:*:)))))
  (Construction Maybe)
  a
-> Morphing
     ('Into (Tap ((List <:.:> List) := (:*:)))) (Construction Maybe) a
morphing ((<:.>)
  (Tagged ('Into (Tap ((List <:.:> List) := (:*:)))))
  (Construction Maybe)
  a
-> Construction Maybe a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Construction Maybe a
ne) = a
-> T_U Covariant Covariant (:*:) List List a
-> Tap ((List <:.:> List) := (:*:)) a
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap (a
 -> T_U Covariant Covariant (:*:) List List a
 -> Tap ((List <:.:> List) := (:*:)) a)
-> a
-> T_U Covariant Covariant (:*:) List List a
-> Tap ((List <:.:> List) := (:*:)) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Construction Maybe a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract Construction Maybe a
ne (T_U Covariant Covariant (:*:) List List a
 -> Tap ((List <:.:> List) := (:*:)) a)
-> T_U Covariant Covariant (:*:) List List a
-> Tap ((List <:.:> List) := (:*:)) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ List a -> List a -> T_U Covariant Covariant (:*:) List List a
forall k (t :: k -> *) (a :: k) (u :: k -> *).
t a -> u a -> (<:.:>) t u (:*:) a
twosome (List a -> List a -> T_U Covariant Covariant (:*:) List List a)
-> List a -> List a -> T_U Covariant Covariant (:*:) List List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Identity (List a) -> List a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract (Lens Identity (Construction Maybe a) (List a)
-> Construction Maybe a -> Identity (List a)
forall (available :: * -> *) source target.
Lens available source target -> source -> available target
view (Lens Identity (Construction Maybe a) (List a)
 -> Construction Maybe a -> Identity (List a))
-> Lens Identity (Construction Maybe a) (List a)
-> Construction Maybe a
-> Identity (List a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# forall k (segment :: k) (structure :: * -> *).
(Substructure segment structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance segment structure)
:= Available segment structure
forall (structure :: * -> *).
(Substructure 'Tail structure, Covariant structure,
 Covariant_ structure (->) (->)) =>
(structure #=@ Substance 'Tail structure)
:= Available 'Tail structure
sub @Tail (Construction Maybe a -> Identity (List a))
-> Construction Maybe a -> Identity (List a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Construction Maybe a
ne) (List a -> T_U Covariant Covariant (:*:) List List a)
-> List a -> T_U Covariant Covariant (:*:) List List a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# List a
forall (t :: * -> *) a. Avoidable t => t a
empty

instance Morphable (Into (Tap (List <:.:> List := (:*:)))) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) where
	type Morphing (Into (Tap (List <:.:> List := (:*:)))) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) = Tap (List <:.:> List := (:*:))
	morphing :: (<:.>)
  (Tagged ('Into (Tap ((List <:.:> List) := (:*:)))))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Morphing
     ('Into (Tap ((List <:.:> List) := (:*:))))
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     a
morphing ((<:.>)
  (Tagged ('Into (Tap ((List <:.:> List) := (:*:)))))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
zipper) = a
-> (:=) (List <:.:> List) (:*:) a
-> Tap ((List <:.:> List) := (:*:)) a
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap (a
 -> (:=) (List <:.:> List) (:*:) a
 -> Tap ((List <:.:> List) := (:*:)) a)
-> a
-> (:=) (List <:.:> List) (:*:) a
-> Tap ((List <:.:> List) := (:*:)) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
zipper ((:=) (List <:.:> List) (:*:) a
 -> Tap ((List <:.:> List) := (:*:)) a)
-> (:=) (List <:.:> List) (:*:) a
-> Tap ((List <:.:> List) := (:*:)) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ Construction Maybe a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Construction Maybe a
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> (Construction Maybe a
    -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> (Construction Maybe a :*: Construction Maybe a)
-> TU Covariant Covariant Maybe (Construction Maybe) a
   :*: TU Covariant Covariant Maybe (Construction Maybe) a
forall (v :: * -> * -> *) (left :: * -> * -> *)
       (right :: * -> * -> *) (target :: * -> * -> *) a b c d.
Bivariant v left right target =>
left a b -> right c d -> target (v a c) (v b d)
<-> Construction Maybe a
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Liftable t, Covariant_ u (->) (->)) =>
u ~> t u
lift (Primary ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
 -> Primary ((List <:.:> List) := (:*:)) a)
-> (:=) (Construction Maybe <:.:> Construction Maybe) (:*:) a
-> (:=) (List <:.:> List) (:*:) a
forall (t :: * -> *) (u :: * -> *) a b.
(Interpreted t, Interpreted u) =>
(Primary t a -> Primary u b) -> t a -> u b
||= Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
-> (:=) (Construction Maybe <:.:> Construction Maybe) (:*:) a
forall (t :: (* -> *) -> * -> *) (u :: * -> *).
(Lowerable t, Covariant_ u (->) (->)) =>
t u ~> u
lower Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
zipper

--instance Morphable (Into (Tap (Construction Maybe <:.:> Construction Maybe := (:*:)))) (Tap (List <:.:> List := (:*:))) where
	--type Morphing (Into (Tap (Construction Maybe <:.:> Construction Maybe := (:*:)))) (Tap (List <:.:> List := (:*:))) =
		--Maybe <:.> Tap (Construction Maybe <:.:> Construction Maybe := (:*:))
	--morphing (premorph -> zipper) = let spread x y = (:*:) -<$>- x -<*>- y in TU $
		--Tap (extract zipper) . T_U -<$>- ((spread |-) . (run <-> run) . run $ lower zipper)

instance Morphable (Into (Construction Maybe)) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) where
	type Morphing (Into (Construction Maybe)) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) = Construction Maybe
	morphing :: (<:.>)
  (Tagged ('Into (Construction Maybe)))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Morphing
     ('Into (Construction Maybe))
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     a
morphing ((<:.>)
  (Tagged ('Into (Construction Maybe)))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap a
x (T_U (Construction Maybe a
future :*: Construction Maybe a
past))) = (Construction Maybe a
 :*: Construction Maybe (Construction Maybe a))
-> Construction Maybe a
forall a b. (a :*: b) -> a
attached ((Construction Maybe a
  :*: Construction Maybe (Construction Maybe a))
 -> Construction Maybe a)
-> (Construction Maybe a
    :*: Construction Maybe (Construction Maybe a))
-> Construction Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ forall a.
Interpreted (State (Construction Maybe a)) =>
State (Construction Maybe a) a
-> Primary (State (Construction Maybe a)) a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run @(State _)
		# modify . item @Push @(Nonempty List) <<- past
		# item @Push x future

instance Morphable (Into List) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) where
	type Morphing (Into List) (Tap (Construction Maybe <:.:> Construction Maybe := (:*:))) = List
	morphing :: (<:.>)
  (Tagged ('Into List))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Morphing
     ('Into List)
     (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
     a
morphing ((<:.>)
  (Tagged ('Into List))
  (Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)))
  a
-> Tap ((Construction Maybe <:.:> Construction Maybe) := (:*:)) a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Tap a
x (T_U (Construction Maybe a
future :*: Construction Maybe a
past))) = (TU Covariant Covariant Maybe (Construction Maybe) a
 :*: Construction
       Maybe (TU Covariant Covariant Maybe (Construction Maybe) a))
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall a b. (a :*: b) -> a
attached ((TU Covariant Covariant Maybe (Construction Maybe) a
  :*: Construction
        Maybe (TU Covariant Covariant Maybe (Construction Maybe) a))
 -> TU Covariant Covariant Maybe (Construction Maybe) a)
-> (TU Covariant Covariant Maybe (Construction Maybe) a
    :*: Construction
          Maybe (TU Covariant Covariant Maybe (Construction Maybe) a))
-> TU Covariant Covariant Maybe (Construction Maybe) a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ forall a.
Interpreted
  (State (TU Covariant Covariant Maybe (Construction Maybe) a)) =>
State (TU Covariant Covariant Maybe (Construction Maybe) a) a
-> Primary
     (State (TU Covariant Covariant Maybe (Construction Maybe) a)) a
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run @(State _)
		# modify . item @Push @List <<- past
		# item @Push x (lift future)

------------------------------------ Zipper of combinative list ------------------------------------

type instance Zipper (Comprehension Maybe) (Left ::: Right) = Tap (Comprehension Maybe <:.:> Comprehension Maybe := (:*:))

instance {-# OVERLAPS #-} Applicative (Tap (Comprehension Maybe <:.:> Comprehension Maybe := (:*:))) where
	Tap a -> b
f (T_U (Comprehension Maybe (a -> b)
lfs :*: Comprehension Maybe (a -> b)
rfs)) <*> :: Tap
  ((Comprehension Maybe <:.:> Comprehension Maybe) := (:*:)) (a -> b)
-> Tap ((Comprehension Maybe <:.:> Comprehension Maybe) := (:*:)) a
-> Tap ((Comprehension Maybe <:.:> Comprehension Maybe) := (:*:)) b
<*> Tap a
x (T_U (Comprehension Maybe a
ls :*: Comprehension Maybe a
rs)) = b
-> (:=) (Comprehension Maybe <:.:> Comprehension Maybe) (:*:) b
-> Tap ((Comprehension Maybe <:.:> Comprehension Maybe) := (:*:)) b
forall (t :: * -> *) a. a -> t a -> Tap t a
Tap (b
 -> (:=) (Comprehension Maybe <:.:> Comprehension Maybe) (:*:) b
 -> Tap
      ((Comprehension Maybe <:.:> Comprehension Maybe) := (:*:)) b)
-> b
-> (:=) (Comprehension Maybe <:.:> Comprehension Maybe) (:*:) b
-> Tap ((Comprehension Maybe <:.:> Comprehension Maybe) := (:*:)) b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# a -> b
f a
x ((:=) (Comprehension Maybe <:.:> Comprehension Maybe) (:*:) b
 -> Tap
      ((Comprehension Maybe <:.:> Comprehension Maybe) := (:*:)) b)
-> (:=) (Comprehension Maybe <:.:> Comprehension Maybe) (:*:) b
-> Tap ((Comprehension Maybe <:.:> Comprehension Maybe) := (:*:)) b
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# (Comprehension Maybe b :*: Comprehension Maybe b)
-> (:=) (Comprehension Maybe <:.:> Comprehension Maybe) (:*:) b
forall k k k k k (ct :: k) (cu :: k) (p :: k -> k -> *)
       (t :: k -> k) (u :: k -> k) (a :: k).
p (t a) (u a) -> T_U ct cu p t u a
T_U (Comprehension Maybe (a -> b)
lfs Comprehension Maybe (a -> b)
-> Comprehension Maybe a -> Comprehension Maybe b
forall (t :: * -> *) a b. Applicative t => t (a -> b) -> t a -> t b
<*> Comprehension Maybe a
ls Comprehension Maybe b
-> Comprehension Maybe b
-> Comprehension Maybe b :*: Comprehension Maybe b
forall s a. s -> a -> s :*: a
:*: Comprehension Maybe (a -> b)
rfs Comprehension Maybe (a -> b)
-> Comprehension Maybe a -> Comprehension Maybe b
forall (t :: * -> *) a b. Applicative t => t (a -> b) -> t a -> t b
<*> Comprehension Maybe a
rs)

----------------------------------------- Prefixed list --------------------------------------------

instance Setoid key => Morphable (Lookup Key) (Prefixed List key) where
	type Morphing (Lookup Key) (Prefixed List key) = (->) key <:.> Maybe
	morphing :: (<:.>) (Tagged ('Lookup 'Key)) (Prefixed List key) a
-> Morphing ('Lookup 'Key) (Prefixed List key) a
morphing (Prefixed List key a
-> TU Covariant Covariant Maybe (Construction Maybe) (key :*: a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (Prefixed List key a
 -> TU Covariant Covariant Maybe (Construction Maybe) (key :*: a))
-> ((<:.>) (Tagged ('Lookup 'Key)) (Prefixed List key) a
    -> Prefixed List key a)
-> (<:.>) (Tagged ('Lookup 'Key)) (Prefixed List key) a
-> TU Covariant Covariant Maybe (Construction Maybe) (key :*: a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>) (Tagged ('Lookup 'Key)) (Prefixed List key) a
-> Prefixed List key a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> TU Covariant Covariant Maybe (Construction Maybe) (key :*: a)
list) = (((->) key :. Maybe) := a)
-> TU Covariant Covariant ((->) key) Maybe 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 ((((->) key :. Maybe) := a)
 -> TU Covariant Covariant ((->) key) Maybe a)
-> (((->) key :. Maybe) := a)
-> TU Covariant Covariant ((->) key) Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \key
key -> key -> Prefixed (Construction Maybe) key a -> Maybe a
forall a1 (mod :: a1) key (struct :: * -> *) a2.
Morphed ('Lookup mod) struct ((->) key <:.> Maybe) =>
key -> struct a2 -> Maybe a2
lookup @Key key
key (Prefixed (Construction Maybe) key a -> Maybe a)
-> Maybe (Prefixed (Construction Maybe) key a) -> Maybe a
forall (t :: * -> *) (source :: * -> * -> *) a b.
Bindable t source =>
source a (t b) -> source (t a) (t b)
=<< ((Construction Maybe :. (:*:) key) := a)
-> Prefixed (Construction Maybe) key a
forall (t :: * -> *) k a. ((t :. (:*:) k) := a) -> Prefixed t k a
Prefixed (((Construction Maybe :. (:*:) key) := a)
 -> Prefixed (Construction Maybe) key a)
-> Maybe ((Construction Maybe :. (:*:) key) := a)
-> Maybe (Prefixed (Construction Maybe) key a)
forall (t :: * -> *) (source :: * -> * -> *)
       (target :: * -> * -> *) a b.
Covariant_ t source target =>
source a b -> target (t a) (t b)
-<$>- TU Covariant Covariant Maybe (Construction Maybe) (key :*: a)
-> Primary List (key :*: a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run TU Covariant Covariant Maybe (Construction Maybe) (key :*: a)
list 

------------------------------------ Prefixed non-empty list ---------------------------------------

instance Setoid key => Morphable (Lookup Key) (Prefixed (Construction Maybe) key) where
	type Morphing (Lookup Key) (Prefixed (Construction Maybe) key) = (->) key <:.> Maybe
	morphing :: (<:.>)
  (Tagged ('Lookup 'Key)) (Prefixed (Construction Maybe) key) a
-> Morphing ('Lookup 'Key) (Prefixed (Construction Maybe) key) a
morphing (Prefixed (Construction Maybe) key a
-> Construction Maybe (key :*: a)
forall (t :: * -> *) a. Interpreted t => t a -> Primary t a
run (Prefixed (Construction Maybe) key a
 -> Construction Maybe (key :*: a))
-> ((<:.>)
      (Tagged ('Lookup 'Key)) (Prefixed (Construction Maybe) key) a
    -> Prefixed (Construction Maybe) key a)
-> (<:.>)
     (Tagged ('Lookup 'Key)) (Prefixed (Construction Maybe) key) a
-> Construction Maybe (key :*: a)
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (<:.>)
  (Tagged ('Lookup 'Key)) (Prefixed (Construction Maybe) key) a
-> Prefixed (Construction Maybe) key a
forall k (mod :: k) (struct :: * -> *).
Morphable mod struct =>
(Tagged mod <:.> struct) ~> struct
premorph -> Construct key :*: a
x (Maybe :. Construction Maybe) := (key :*: a)
xs) = (((->) key :. Maybe) := a)
-> TU Covariant Covariant ((->) key) Maybe 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 ((((->) key :. Maybe) := a)
 -> TU Covariant Covariant ((->) key) Maybe a)
-> (((->) key :. Maybe) := a)
-> TU Covariant Covariant ((->) key) Maybe a
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ \key
key -> (key :*: a) -> a
forall (t :: * -> *) (source :: * -> * -> *) a.
Extractable t source =>
source (t a) a
extract ((key :*: a) -> a) -> Maybe (key :*: a) -> Maybe a
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> key -> Maybe (key :*: a)
search key
key where
		search :: key -> Maybe (key :*: a)
search key
key = key
key key -> key -> Boolean
forall a. Setoid a => a -> a -> Boolean
== (key :*: a) -> key
forall a b. (a :*: b) -> a
attached key :*: a
x Boolean
-> Maybe (key :*: a) -> Maybe (key :*: a) -> Maybe (key :*: a)
forall a. Boolean -> a -> a -> a
? (key :*: a) -> Maybe (key :*: a)
forall a. a -> Maybe a
Just key :*: a
x (Maybe (key :*: a) -> Maybe (key :*: a))
-> Maybe (key :*: a) -> Maybe (key :*: a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
$ forall a1 (mod :: a1) (struct :: * -> *) (result :: * -> *) a2.
Morphed ('Find mod) struct ((Predicate <:.:> result) := (->)) =>
Predicate a2 -> struct a2 -> result a2
forall (struct :: * -> *) (result :: * -> *) a2.
Morphed
  ('Find 'Element) struct ((Predicate <:.:> result) := (->)) =>
Predicate a2 -> struct a2 -> result a2
find @Element (Predicate (key :*: a)
 -> Construction Maybe (key :*: a) -> Maybe (key :*: a))
-> Predicate (key :*: a)
-> Construction Maybe (key :*: a)
-> Maybe (key :*: a)
forall (m :: * -> * -> *) a b. Category m => m (m a b) (m a b)
# ((key :*: a) -> Boolean) -> Predicate (key :*: a)
forall a. (a -> Boolean) -> Predicate a
Predicate ((key
key key -> key -> Boolean
forall a. Setoid a => a -> a -> Boolean
==) (key -> Boolean) -> ((key :*: a) -> key) -> (key :*: a) -> Boolean
forall (m :: * -> * -> *) b c a.
Category m =>
m b c -> m a b -> m a c
. (key :*: a) -> key
forall a b. (a :*: b) -> a
attached) (Construction Maybe (key :*: a) -> Maybe (key :*: a))
-> ((Maybe :. Construction Maybe) := (key :*: a))
-> Maybe (key :*: a)
forall (t :: * -> *) (source :: * -> * -> *) a b.
Bindable t source =>
source a (t b) -> source (t a) (t b)
=<< (Maybe :. Construction Maybe) := (key :*: a)
xs