packages feed

pandora 0.3.2 → 0.3.3

raw patch · 25 files changed

+305/−57 lines, 25 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Pandora.Paradigm.Primary.Functor.Maybe: maybe :: b -> (a -> b) -> Maybe a -> b
- Pandora.Paradigm.Primary.Transformer.Construction: iterate :: Covariant t => (a |-> t) -> a |-> Construction t
- Pandora.Paradigm.Structure.Ability.Monotonic: bypass :: Monotonic e a => (a -> r -> r) -> r -> e -> r
- Pandora.Paradigm.Structure.Stack: backward :: Zipper Stack a -> Maybe (Zipper Stack a)
- Pandora.Paradigm.Structure.Stack: backward' :: Zipper (Nonempty Stack) a -> Maybe (Zipper (Nonempty Stack) a)
- Pandora.Paradigm.Structure.Stack: forward :: Zipper Stack a -> Maybe (Zipper Stack a)
- Pandora.Paradigm.Structure.Stack: forward' :: Zipper (Nonempty Stack) a -> Maybe (Zipper (Nonempty Stack) a)
- Pandora.Paradigm.Structure.Stack: instance Pandora.Paradigm.Structure.Ability.Monotonic.Monotonic ((Pandora.Paradigm.Primary.Functor.Maybe.Maybe Pandora.Core.Functor.:. Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Maybe.Maybe) Pandora.Core.Functor.:= a) a
+ Pandora.Paradigm.Controlflow.Effect.Interpreted: via :: (Liftable t, Interpreted (t u), Interpreted (t v), Covariant u) => (t u a -> t v b) -> u a -> Primary (t v) b
+ Pandora.Paradigm.Primary.Functor.Maybe: instance Pandora.Paradigm.Structure.Ability.Monotonic.Monotonic (Pandora.Paradigm.Primary.Functor.Maybe.Maybe a) a
+ Pandora.Paradigm.Primary.Functor.Maybe: instance Pandora.Paradigm.Structure.Ability.Monotonic.Monotonic (t a) a => Pandora.Paradigm.Structure.Ability.Monotonic.Monotonic ((Pandora.Paradigm.Primary.Functor.Maybe.Maybe Pandora.Core.Functor.:. t) Pandora.Core.Functor.:= a) a
+ Pandora.Paradigm.Primary.Object.Natural: Natural :: Natural -> Natural
+ Pandora.Paradigm.Primary.Object.Natural: Zero :: Natural
+ Pandora.Paradigm.Primary.Object.Natural: data Natural
+ Pandora.Paradigm.Primary.Object.Natural: instance Pandora.Pattern.Object.Chain.Chain Pandora.Paradigm.Primary.Object.Natural.Natural
+ Pandora.Paradigm.Primary.Object.Natural: instance Pandora.Pattern.Object.Monoid.Monoid Pandora.Paradigm.Primary.Object.Natural.Natural
+ Pandora.Paradigm.Primary.Object.Natural: instance Pandora.Pattern.Object.Quasiring.Quasiring Pandora.Paradigm.Primary.Object.Natural.Natural
+ Pandora.Paradigm.Primary.Object.Natural: instance Pandora.Pattern.Object.Ringoid.Ringoid Pandora.Paradigm.Primary.Object.Natural.Natural
+ Pandora.Paradigm.Primary.Object.Natural: instance Pandora.Pattern.Object.Semigroup.Semigroup Pandora.Paradigm.Primary.Object.Natural.Natural
+ Pandora.Paradigm.Primary.Object.Natural: instance Pandora.Pattern.Object.Setoid.Setoid Pandora.Paradigm.Primary.Object.Natural.Natural
+ Pandora.Paradigm.Primary.Transformer.Construction: (.-+) :: Covariant t => (a |-> t) -> a |-> Construction t
+ Pandora.Paradigm.Primary.Transformer.Construction: infixr 7 .-+
+ Pandora.Paradigm.Primary.Transformer.Jack: instance (Pandora.Pattern.Functor.Pointable.Pointable t, Pandora.Pattern.Functor.Bindable.Bindable t) => Pandora.Pattern.Functor.Bindable.Bindable (Pandora.Paradigm.Primary.Transformer.Jack.Jack t)
+ Pandora.Paradigm.Primary.Transformer.Jack: instance Pandora.Pattern.Functor.Extendable.Extendable t => Pandora.Pattern.Functor.Extendable.Extendable (Pandora.Paradigm.Primary.Transformer.Jack.Jack t)
+ Pandora.Paradigm.Primary.Transformer.Jack: instance Pandora.Pattern.Transformer.Hoistable.Hoistable Pandora.Paradigm.Primary.Transformer.Jack.Jack
+ Pandora.Paradigm.Schemes.T_: T_ :: (a :*: t a) -> T_ ct t a
+ Pandora.Paradigm.Schemes.T_: instance forall k (ct :: k) (t :: * -> *). Pandora.Paradigm.Controlflow.Effect.Interpreted.Interpreted (Pandora.Paradigm.Schemes.T_.T_ ct t)
+ Pandora.Paradigm.Schemes.T_: newtype T_ ct t a
+ Pandora.Paradigm.Schemes.T_U: T_U :: (t a :*: u a) -> T_U ct cu t u a
+ Pandora.Paradigm.Schemes.T_U: instance Pandora.Pattern.Functor.Avoidable.Avoidable t => Pandora.Pattern.Transformer.Liftable.Liftable (Pandora.Paradigm.Schemes.T_U.T_U Pandora.Pattern.Functor.Covariant.Covariant Pandora.Pattern.Functor.Covariant.Covariant t)
+ Pandora.Paradigm.Schemes.T_U: instance Pandora.Pattern.Functor.Covariant.Covariant t => Pandora.Pattern.Transformer.Hoistable.Hoistable (Pandora.Paradigm.Schemes.T_U.T_U Pandora.Pattern.Functor.Covariant.Covariant Pandora.Pattern.Functor.Covariant.Covariant t)
+ Pandora.Paradigm.Schemes.T_U: instance Pandora.Pattern.Transformer.Lowerable.Lowerable (Pandora.Paradigm.Schemes.T_U.T_U Pandora.Pattern.Functor.Covariant.Covariant Pandora.Pattern.Functor.Covariant.Covariant t)
+ Pandora.Paradigm.Schemes.T_U: instance forall k1 k2 (ct :: k1) (cu :: k2) (t :: * -> *) (u :: * -> *). Pandora.Paradigm.Controlflow.Effect.Interpreted.Interpreted (Pandora.Paradigm.Schemes.T_U.T_U ct cu t u)
+ Pandora.Paradigm.Schemes.T_U: newtype T_U ct cu t u a
+ Pandora.Paradigm.Schemes.T_U: type (>:.:<) = T_U Contravariant Contravariant
+ Pandora.Paradigm.Schemes.U_T: U_T :: (u a :*: t a) -> U_T ct cu t u a
+ Pandora.Paradigm.Schemes.U_T: instance Pandora.Pattern.Functor.Avoidable.Avoidable t => Pandora.Pattern.Transformer.Liftable.Liftable (Pandora.Paradigm.Schemes.U_T.U_T Pandora.Pattern.Functor.Covariant.Covariant Pandora.Pattern.Functor.Covariant.Covariant t)
+ Pandora.Paradigm.Schemes.U_T: instance Pandora.Pattern.Functor.Covariant.Covariant t => Pandora.Pattern.Transformer.Hoistable.Hoistable (Pandora.Paradigm.Schemes.U_T.U_T Pandora.Pattern.Functor.Covariant.Covariant Pandora.Pattern.Functor.Covariant.Covariant t)
+ Pandora.Paradigm.Schemes.U_T: instance Pandora.Pattern.Transformer.Lowerable.Lowerable (Pandora.Paradigm.Schemes.U_T.U_T Pandora.Pattern.Functor.Covariant.Covariant Pandora.Pattern.Functor.Covariant.Covariant t)
+ Pandora.Paradigm.Schemes.U_T: instance forall k1 k2 (ct :: k1) (cu :: k2) (t :: * -> *) (u :: * -> *). Pandora.Paradigm.Controlflow.Effect.Interpreted.Interpreted (Pandora.Paradigm.Schemes.U_T.U_T ct cu t u)
+ Pandora.Paradigm.Schemes.U_T: newtype U_T ct cu t u a
+ Pandora.Paradigm.Schemes.U_T: type (>.:.<) = U_T Contravariant Contravariant
+ Pandora.Paradigm.Structure.Ability.Monotonic: reduce :: Monotonic e a => (a -> r -> r) -> r -> e -> r
+ Pandora.Paradigm.Structure.Ability.Monotonic: resolve :: Monotonic e a => (a -> r) -> r -> e -> r
+ Pandora.Paradigm.Structure.Binary: Down :: a -> Direction a
+ Pandora.Paradigm.Structure.Binary: Leftward :: a -> Biforked a
+ Pandora.Paradigm.Structure.Binary: Rightward :: a -> Biforked a
+ Pandora.Paradigm.Structure.Binary: Top :: Biforked a
+ Pandora.Paradigm.Structure.Binary: Up :: a -> Direction a
+ Pandora.Paradigm.Structure.Binary: data Biforked a
+ Pandora.Paradigm.Structure.Binary: data Direction a
+ Pandora.Paradigm.Structure.Binary: instance Pandora.Paradigm.Structure.Ability.Rotatable.Rotatable 'Pandora.Paradigm.Structure.Binary.Up (Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Wye.Wye Pandora.Paradigm.Schemes.T_U.<:.:> ((Pandora.Paradigm.Structure.Binary.Biforked Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Structure.Binary.Biforked) Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Schemes.T_.T_ Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Primary.Functor.Maybe.Maybe Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Wye.Wye)))
+ Pandora.Paradigm.Structure.Binary: instance Pandora.Paradigm.Structure.Ability.Rotatable.Rotatable ('Pandora.Paradigm.Structure.Binary.Down 'Pandora.Paradigm.Primary.Functor.Wye.Left) (Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Wye.Wye Pandora.Paradigm.Schemes.T_U.<:.:> ((Pandora.Paradigm.Structure.Binary.Biforked Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Structure.Binary.Biforked) Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Schemes.T_.T_ Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Primary.Functor.Maybe.Maybe Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Wye.Wye)))
+ Pandora.Paradigm.Structure.Binary: instance Pandora.Paradigm.Structure.Ability.Rotatable.Rotatable ('Pandora.Paradigm.Structure.Binary.Down 'Pandora.Paradigm.Primary.Functor.Wye.Right) (Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Wye.Wye Pandora.Paradigm.Schemes.T_U.<:.:> ((Pandora.Paradigm.Structure.Binary.Biforked Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Structure.Binary.Biforked) Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Schemes.T_.T_ Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Primary.Functor.Maybe.Maybe Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Wye.Wye)))
+ Pandora.Paradigm.Structure.Interface.Set: cardinality :: Traversable t => t a -> Natural
+ Pandora.Paradigm.Structure.Stack: instance Pandora.Paradigm.Structure.Ability.Rotatable.Rotatable 'Pandora.Paradigm.Primary.Functor.Wye.Left (Pandora.Paradigm.Primary.Transformer.Tap.Tap (Pandora.Paradigm.Primary.Functor.Delta.Delta Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Maybe.Maybe))
+ Pandora.Paradigm.Structure.Stack: instance Pandora.Paradigm.Structure.Ability.Rotatable.Rotatable 'Pandora.Paradigm.Primary.Functor.Wye.Left (Pandora.Paradigm.Primary.Transformer.Tap.Tap (Pandora.Paradigm.Primary.Functor.Delta.Delta Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Structure.Stack.Stack))
+ Pandora.Paradigm.Structure.Stack: instance Pandora.Paradigm.Structure.Ability.Rotatable.Rotatable 'Pandora.Paradigm.Primary.Functor.Wye.Right (Pandora.Paradigm.Primary.Transformer.Tap.Tap (Pandora.Paradigm.Primary.Functor.Delta.Delta Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Primary.Transformer.Construction.Construction Pandora.Paradigm.Primary.Functor.Maybe.Maybe))
+ Pandora.Paradigm.Structure.Stack: instance Pandora.Paradigm.Structure.Ability.Rotatable.Rotatable 'Pandora.Paradigm.Primary.Functor.Wye.Right (Pandora.Paradigm.Primary.Transformer.Tap.Tap (Pandora.Paradigm.Primary.Functor.Delta.Delta Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Structure.Stack.Stack))
+ Pandora.Paradigm.Structure.Stream: instance Pandora.Pattern.Functor.Extendable.Extendable (Pandora.Paradigm.Primary.Transformer.Tap.Tap (Pandora.Paradigm.Primary.Functor.Delta.Delta Pandora.Paradigm.Schemes.TU.<:.> Pandora.Paradigm.Structure.Stream.Stream))
+ Pandora.Pattern.Functor.Invariant: (>-<) :: Invariant t => (a -> b) -> (b -> a) -> t a -> t b
- Pandora.Paradigm.Inventory.Optics: type (:-.) src tgt = Lens src tgt
+ Pandora.Paradigm.Inventory.Optics: type (:~.) t u a = Lens (t a) (u a)
- Pandora.Paradigm.Structure.Interface.Set: member :: (Setoid a, Monotonic e a) => a -> e -> Boolean
+ Pandora.Paradigm.Structure.Interface.Set: member :: forall e a. (Setoid a, Monotonic e a) => a -> e -> Boolean

Files

CHANGELOG.md view
@@ -282,3 +282,17 @@ * Define `forward'` and `backward'` methods for `Zipper` of `Nonempty Stack` * Rename `iterate` method of `Monotonic` typeclass to `bypass` * Rename `coiterate` method of `Construction` datatype to `iterate`++# 0.3.3+* Define inductive `Natural` number datatype in `Object` module+* Add `cardinality` method to `Set` interface+* Define new functor schemes: `T_`, `T_U`, `U_T`+* Define `Zipper` instance for `Nonempty Binary`+* Replace `forward`, `forward'`, `backward`, `backward'` methods with `Rotatable` instances+* Add `>-<` operator to `Invariant` typeclass+* Add `:~.` type synonymous for polymorphic lens+* Replace `maybe` with more generic `bypass`+* Rename `bypass` method of `Monotonic` to `reduce`+* Add `resolve` method of `Monotonic` typeclass+* Rename `iterate` method of `Construction` to `.-+`+* Define `via` method to use transformer as wrappers
Pandora/Paradigm/Controlflow/Effect/Interpreted.hs view
@@ -1,8 +1,16 @@-module Pandora.Paradigm.Controlflow.Effect.Interpreted (Schematic, Interpreted (..)) where+module Pandora.Paradigm.Controlflow.Effect.Interpreted where +import Pandora.Pattern.Category ((.))+import Pandora.Pattern.Functor.Covariant (Covariant)+import Pandora.Pattern.Transformer.Liftable (Liftable (lift))+ type family Schematic (c :: (* -> *) -> k) (t :: * -> *) = (r :: (* -> *) -> * -> *) | r -> t  class Interpreted t where 	{-# MINIMAL run #-} 	type Primary t a :: * 	run :: t a -> Primary t a++via :: (Liftable t, Interpreted (t u), Interpreted (t v), Covariant u)+	=> (t u a -> t v b) -> u a -> Primary (t v) b+via f = run . f . lift
Pandora/Paradigm/Inventory/Optics.hs view
@@ -17,6 +17,8 @@  type Lens src tgt = src |-> Store tgt +type (:~.) t u a = Lens (t a) (u a)+ -- | Lens composition infix operator (|>) :: Lens src old -> Lens old new -> Lens src new from |> to = \x -> ((<$) x . to) . position . from $ x
Pandora/Paradigm/Primary/Functor.hs view
@@ -24,6 +24,7 @@ import Pandora.Core.Functor (type (~>)) import Pandora.Pattern.Category (($)) import Pandora.Pattern.Functor.Adjoint (Adjoint ((-|), (|-)))+import Pandora.Paradigm.Structure.Ability.Monotonic (reduce)  instance Adjoint (Product s) ((->) s) where 	(-|) :: a -> ((s :*: a) -> b) -> (s -> b)@@ -32,7 +33,7 @@ 	~(s :*: x) |- f = f x s  note :: e -> Maybe ~> Conclusion e-note x = maybe (Failure x) Success+note x = reduce (\y _ -> Success y) (Failure x)  hush :: Conclusion e ~> Maybe hush = conclusion (Nothing !) Just
Pandora/Paradigm/Primary/Functor/Constant.hs view
@@ -3,7 +3,7 @@ import Pandora.Pattern.Category (($)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Contravariant (Contravariant ((>$<)))-import Pandora.Pattern.Functor.Invariant (Invariant (invmap))+import Pandora.Pattern.Functor.Invariant (Invariant ((>-<))) import Pandora.Pattern.Functor.Pointable (Pointable (point)) import Pandora.Pattern.Functor.Traversable (Traversable ((->>))) import Pandora.Pattern.Functor.Bivariant (Bivariant ((<->)))@@ -26,7 +26,7 @@ 	_ >$< Constant x = Constant x  instance Invariant (Constant a) where-	invmap _ _ (Constant x) = Constant x+	_ >-< _ = \(Constant x) -> Constant x  instance Traversable (Constant a) where 	Constant x ->> _ = point (Constant x)
Pandora/Paradigm/Primary/Functor/Endo.hs view
@@ -1,14 +1,14 @@ module Pandora.Paradigm.Primary.Functor.Endo where  import Pandora.Pattern.Category (identity, (.))-import Pandora.Pattern.Functor.Invariant (Invariant (invmap))+import Pandora.Pattern.Functor.Invariant (Invariant ((>-<))) import Pandora.Pattern.Object.Semigroup (Semigroup ((+))) import Pandora.Pattern.Object.Monoid (Monoid (zero))  newtype Endo a = Endo { endo :: a -> a }  instance Invariant Endo where-	invmap f g (Endo x) = Endo (f . x . g)+	f >-< g = \(Endo x) -> Endo (f . x . g)  instance Semigroup (Endo a) where 	Endo f + Endo g = Endo (g . f)
Pandora/Paradigm/Primary/Functor/Maybe.hs view
@@ -1,5 +1,6 @@ module Pandora.Paradigm.Primary.Functor.Maybe where +import Pandora.Core.Functor (type (:.), type (:=)) import Pandora.Pattern.Category (identity, (.), ($)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>), (<$$>))) import Pandora.Pattern.Functor.Avoidable (Avoidable (empty))@@ -21,6 +22,7 @@ import Pandora.Paradigm.Controlflow.Effect.Transformer.Monadic (Monadic (wrap), (:>) (TM)) import Pandora.Paradigm.Controlflow.Effect.Adaptable (Adaptable (adapt)) import Pandora.Paradigm.Schemes.UT (UT (UT), type (<.:>))+import Pandora.Paradigm.Structure.Ability.Monotonic (Monotonic (reduce, resolve))  data Maybe a = Nothing | Just a @@ -83,10 +85,6 @@  instance Lattice a => Lattice (Maybe a) where -maybe :: b -> (a -> b) -> Maybe a -> b-maybe x _ Nothing = x-maybe _ f (Just y) = f y- type instance Schematic Monad Maybe = (<.:>) Maybe  instance Interpreted Maybe where@@ -96,6 +94,14 @@ instance Monadic Maybe where 	wrap = TM . UT . point +instance Monotonic (Maybe a) a where+	reduce f r (Just x) = f x r+	reduce _ r Nothing = r++instance Monotonic (t a) a => Monotonic (Maybe :. t := a) a where+	reduce f r (Just x) = reduce f r x+	reduce _ r Nothing = r+ type Optional = Adaptable Maybe  instance Covariant u => Covariant (Maybe <.:> u) where@@ -108,7 +114,7 @@ 	point = UT . point . point  instance (Pointable u, Bindable u) => Bindable (Maybe <.:> u) where-	UT x >>= f = UT $ x >>= maybe (point Nothing) (run . f)+	UT x >>= f = UT $ x >>= resolve (run . f) (point Nothing)  instance Monad u => Monad (Maybe <.:> u) where 
Pandora/Paradigm/Primary/Object.hs view
@@ -2,6 +2,7 @@  module Pandora.Paradigm.Primary.Object (module Exports) where +import Pandora.Paradigm.Primary.Object.Natural as Exports import Pandora.Paradigm.Primary.Object.Ordering as Exports import Pandora.Paradigm.Primary.Object.Boolean as Exports 
+ Pandora/Paradigm/Primary/Object/Natural.hs view
@@ -0,0 +1,38 @@+module Pandora.Paradigm.Primary.Object.Natural where++import Pandora.Pattern.Category (($))+import Pandora.Pattern.Object.Setoid (Setoid ((==)))+import Pandora.Pattern.Object.Chain (Chain ((<=>)))+import Pandora.Pattern.Object.Semigroup (Semigroup ((+)))+import Pandora.Pattern.Object.Ringoid (Ringoid ((*)))+import Pandora.Pattern.Object.Monoid (Monoid (zero))+import Pandora.Pattern.Object.Quasiring (Quasiring (one))+import Pandora.Paradigm.Primary.Object.Boolean (Boolean (True, False))+import Pandora.Paradigm.Primary.Object.Ordering (Ordering (Less, Equal, Greater))++data Natural = Zero | Natural Natural++instance Setoid Natural where+	Zero == Zero = True+	Natural n == Natural m = n == m+	_ == _ = False++instance Chain Natural where+	Zero <=> Zero = Equal+	Zero <=> Natural _ = Less+	Natural _ <=> Zero = Greater+	Natural n <=> Natural m = n <=> m++instance Semigroup Natural where+	Zero + m = m+	Natural n + m = Natural $ n + m++instance Ringoid Natural where+	Zero * _ = Zero+	Natural n * m = m + n * m++instance Monoid Natural where+	zero = Zero++instance Quasiring Natural where+	one = Natural Zero
Pandora/Paradigm/Primary/Transformer/Construction.hs view
@@ -22,6 +22,8 @@ import Pandora.Paradigm.Controlflow (run) import Pandora.Paradigm.Schemes.TU (TU (TU), type (<:.>)) +infixr 7 .-++ data Construction t a = Construct a (t :. Construction t := a)  instance Covariant t => Covariant (Construction t) where@@ -69,8 +71,9 @@ deconstruct :: Construction t a -> (t :. Construction t) a deconstruct ~(Construct _ xs) = xs -iterate :: Covariant t => (a |-> t) -> (a |-> Construction t)-iterate f x = Construct x $ iterate f <$> f x+-- Generate a construction from seed using effectful computation+(.-+) :: Covariant t => a |-> t -> a |-> Construction t+f .-+ x = Construct x $ (f .-+) <$> f x  section :: Comonad t => t ~> Construction t section xs = Construct (extract xs) $ xs =>> section
Pandora/Paradigm/Primary/Transformer/Jack.hs view
@@ -1,15 +1,18 @@ module Pandora.Paradigm.Primary.Transformer.Jack where -import Pandora.Pattern.Category ((.), ($))-import Pandora.Pattern.Functor.Covariant (Covariant ((<$>)), comap)+import Pandora.Pattern.Category (identity, (.), ($))+import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Pointable (Pointable (point)) import Pandora.Pattern.Functor.Extractable (Extractable (extract)) import Pandora.Pattern.Functor.Alternative (Alternative ((<+>))) import Pandora.Pattern.Functor.Avoidable (Avoidable (empty)) import Pandora.Pattern.Functor.Applicative (Applicative ((<*>)))-import Pandora.Pattern.Functor.Traversable (Traversable ((->>), traverse))+import Pandora.Pattern.Functor.Traversable (Traversable ((->>))) import Pandora.Pattern.Functor.Distributive (Distributive ((>>-), distribute))+import Pandora.Pattern.Functor.Bindable (Bindable ((>>=)))+import Pandora.Pattern.Functor.Extendable (Extendable ((=>>))) import Pandora.Pattern.Transformer.Liftable (Liftable (lift))+import Pandora.Pattern.Transformer.Hoistable (Hoistable (hoist)) import Pandora.Pattern.Object.Setoid (Setoid ((==))) import Pandora.Pattern.Object.Chain (Chain ((<=>))) import Pandora.Paradigm.Primary.Object.Boolean (Boolean (False))@@ -44,13 +47,25 @@  instance Traversable t => Traversable (Jack t) where 	It x ->> f = It <$> f x-	Other y ->> f = comap Other . traverse f $ y+	Other y ->> f = Other <$> y ->> f  instance Distributive t => Distributive (Jack t) where 	x >>- f = distribute $ f <$> x +instance (Pointable t, Bindable t) => Bindable (Jack t) where+	It x >>= f = f x+	Other x >>= f = Other $ x >>= jack point identity . f++instance Extendable t => Extendable (Jack t) where+	It x =>> f = It . f $ It x+	Other x =>> f = Other $ x =>> f . Other+ instance Liftable Jack where 	lift = Other++instance Hoistable Jack where+	hoist _ (It x) = It x+	hoist f (Other x) = Other $ f x  instance (Setoid a, Setoid (t a)) => Setoid (Jack t a) where 	It x == It y = x == y
Pandora/Paradigm/Primary/Transformer/Jet.hs view
@@ -10,10 +10,10 @@ data Jet t a = Jet a (Jet t (t a))  instance Covariant t => Covariant (Jet t) where-	f <$> Jet a as = Jet (f a) (f <$$> as)+	f <$> Jet x xs = Jet (f x) (f <$$> xs)  instance Traversable t => Traversable (Jet t) where-	Jet a as ->> f = Jet <$> f a <*> as ->>> f+	Jet x xs ->> f = Jet <$> f x <*> xs ->>> f  instance (forall u . Avoidable u) => Pointable (Jet t) where 	point x = Jet x empty
Pandora/Paradigm/Schemes.hs view
@@ -2,6 +2,9 @@  module Pandora.Paradigm.Schemes (module Exports) where +import Pandora.Paradigm.Schemes.U_T as Exports+import Pandora.Paradigm.Schemes.T_U as Exports+import Pandora.Paradigm.Schemes.T_ as Exports import Pandora.Paradigm.Schemes.UTU as Exports import Pandora.Paradigm.Schemes.UT as Exports import Pandora.Paradigm.Schemes.TUVW as Exports
+ Pandora/Paradigm/Schemes/T_.hs view
@@ -0,0 +1,10 @@+module Pandora.Paradigm.Schemes.T_ where++import Pandora.Paradigm.Primary.Functor.Product (type (:*:))+import Pandora.Paradigm.Controlflow.Effect.Interpreted (Interpreted (Primary, run))++newtype T_ ct t a = T_ (a :*: t a)++instance Interpreted (T_ ct t) where+	type Primary (T_ ct t) a = a :*: t a+	run ~(T_ x) = x
+ Pandora/Paradigm/Schemes/T_U.hs view
@@ -0,0 +1,35 @@+module Pandora.Paradigm.Schemes.T_U where++import Pandora.Core.Functor (type (~>))+import Pandora.Pattern.Category (($))+import Pandora.Pattern.Functor.Covariant (Covariant)+import Pandora.Pattern.Functor.Contravariant (Contravariant)+import Pandora.Pattern.Functor.Avoidable (Avoidable (empty))+import Pandora.Pattern.Transformer.Liftable (Liftable (lift))+import Pandora.Pattern.Transformer.Lowerable (Lowerable (lower))+import Pandora.Pattern.Transformer.Hoistable (Hoistable (hoist))+import Pandora.Paradigm.Primary.Functor.Product (Product ((:*:)), type (:*:))+import Pandora.Paradigm.Controlflow.Effect.Interpreted (Interpreted (Primary, run))++newtype T_U ct cu t u a = T_U (t a :*: u a)++type (<:.:>) = T_U Covariant Covariant+type (>:.:>) = T_U Contravariant Covariant+type (<:.:<) = T_U Covariant Contravariant+type (>:.:<) = T_U Contravariant Contravariant++instance Interpreted (T_U ct cu t u) where+	type Primary (T_U ct cu t u) a = t a :*: u a+	run ~(T_U x) = x++instance Avoidable t => Liftable (T_U Covariant Covariant t) where+	lift :: Covariant u => u ~> t <:.:> u+	lift x = T_U $ empty :*: x++instance Lowerable (T_U Covariant Covariant t) where+	lower :: t <:.:> u ~> u+	lower ~(T_U (_ :*: y)) = y++instance Covariant t => Hoistable (T_U Covariant Covariant t) where+	hoist :: u ~> v -> (t <:.:> u ~> t <:.:> v)+	hoist f (T_U (x :*: y)) = T_U $ x :*: f y
+ Pandora/Paradigm/Schemes/U_T.hs view
@@ -0,0 +1,35 @@+module Pandora.Paradigm.Schemes.U_T where++import Pandora.Core.Functor (type (~>))+import Pandora.Pattern.Category (($))+import Pandora.Pattern.Functor.Covariant (Covariant)+import Pandora.Pattern.Functor.Contravariant (Contravariant)+import Pandora.Pattern.Functor.Avoidable (Avoidable (empty))+import Pandora.Pattern.Transformer.Liftable (Liftable (lift))+import Pandora.Pattern.Transformer.Lowerable (Lowerable (lower))+import Pandora.Pattern.Transformer.Hoistable (Hoistable (hoist))+import Pandora.Paradigm.Primary.Functor.Product (Product ((:*:)), type (:*:))+import Pandora.Paradigm.Controlflow.Effect.Interpreted (Interpreted (Primary, run))++newtype U_T ct cu t u a = U_T (u a :*: t a)++type (<.:.>) = U_T Covariant Covariant+type (>.:.>) = U_T Contravariant Covariant+type (<.:.<) = U_T Covariant Contravariant+type (>.:.<) = U_T Contravariant Contravariant++instance Interpreted (U_T ct cu t u) where+	type Primary (U_T ct cu t u) a = u a :*: t a+	run ~(U_T x) = x++instance Avoidable t => Liftable (U_T Covariant Covariant t) where+	lift :: Covariant u => u ~> t <.:.> u+	lift x = U_T $ x :*: empty++instance Lowerable (U_T Covariant Covariant t) where+	lower :: t <.:.> u ~> u+	lower (U_T (x :*: _)) = x++instance Covariant t => Hoistable (U_T Covariant Covariant t) where+	hoist :: u ~> v -> (t <.:.> u ~> t <.:.> v)+	hoist f (U_T (x :*: y)) = U_T $ f x :*: y
Pandora/Paradigm/Structure.hs view
@@ -21,7 +21,7 @@ import Pandora.Paradigm.Schemes.TU (type (<:.>))  instance Monotonic a s => Monotonic (s :*: a) s where-	bypass f r x = bypass f (f (attached x) r) $ extract x+	reduce f r x = reduce f (f (attached x) r) $ extract x  instance Substructure Left (Product s) where 	type Substructural Left (Product s) a = s
Pandora/Paradigm/Structure/Ability/Monotonic.hs view
@@ -1,15 +1,22 @@ module Pandora.Paradigm.Structure.Ability.Monotonic where +import Pandora.Core.Morphism ((!))+import Pandora.Pattern ((.|..)) import Pandora.Pattern.Functor ((<+>)) import Pandora.Pattern.Functor.Pointable (Pointable) import Pandora.Pattern.Functor.Avoidable (Avoidable (empty)) import Pandora.Paradigm.Primary.Functor.Predicate (Predicate, satisfy)  class Monotonic e a where-	bypass :: (a -> r -> r) -> r -> e -> r+	{-# MINIMAL reduce #-}+	reduce :: (a -> r -> r) -> r -> e -> r +	-- | Version of `reduce` which ignores accumulator+	resolve :: (a -> r) -> r -> e -> r+	resolve g = reduce (g .|.. (!))+ instance Monotonic a a where-	bypass f r x = f x r+	reduce f r x = f x r  find :: (Monotonic e a, Pointable t, Avoidable t) => Predicate a -> e -> t a-find p struct = bypass (\x r -> r <+> satisfy p x) empty struct+find p struct = reduce (\x r -> r <+> satisfy p x) empty struct
Pandora/Paradigm/Structure/Binary.hs view
@@ -11,19 +11,22 @@ import Pandora.Pattern.Transformer.Liftable (lift) import Pandora.Pattern.Object.Chain (Chain ((<=>))) import Pandora.Paradigm.Primary.Object.Ordering (order)-import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Just, Nothing), maybe)+import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Just, Nothing)) import Pandora.Paradigm.Primary.Functor.Product (Product ((:*:))) import Pandora.Paradigm.Primary.Functor.Wye (Wye (End, Left, Right, Both)) import Pandora.Paradigm.Primary.Functor.Tagged (Tagged (Tag)) import Pandora.Paradigm.Primary.Transformer.Construction (Construction (Construct), deconstruct)-import Pandora.Paradigm.Schemes.TU (TU (TU), type (<:.>))+import Pandora.Paradigm.Schemes (TU (TU), T_ (T_), T_U (T_U), type (<:.>), type (<:.:>)) import Pandora.Paradigm.Controlflow.Effect.Interpreted (run) import Pandora.Paradigm.Inventory.Store (Store (Store)) import Pandora.Paradigm.Inventory.Optics (type (:-.), (|>), (%~)) import Pandora.Paradigm.Structure.Ability.Nonempty (Nonempty) import Pandora.Paradigm.Structure.Ability.Focusable (Focusable (Focusing, focusing), Location (Root))+import Pandora.Paradigm.Structure.Ability.Monotonic (Monotonic (resolve)) import Pandora.Paradigm.Structure.Ability.Insertable (Insertable (insert))+import Pandora.Paradigm.Structure.Ability.Rotatable (Rotatable (Rotational, rotation)) import Pandora.Paradigm.Structure.Ability.Substructure (Substructure (Substructural, substructure), sub)+import Pandora.Paradigm.Structure.Ability.Zipper (Zipper)  type Binary = Maybe <:.> Construction Wye @@ -41,7 +44,7 @@ instance (forall a . Chain a) => Focusable Root Binary where 	type Focusing Root Binary a = Maybe a 	focusing (run . extract -> Nothing) = Store $ Nothing :*: Tag . TU . comap (Construct % End)-	focusing (run . extract -> Just x) = Store $ Just (extract x) :*: Tag . lift . maybe (rebalance $ deconstruct x) (Construct % deconstruct x)+	focusing (run . extract -> Just x) = Store $ Just (extract x) :*: Tag . lift . resolve (Construct % deconstruct x) (rebalance $ deconstruct x)  instance Substructure Left Binary where 	type Substructural Left Binary a = Binary a@@ -63,19 +66,54 @@ 	focusing (extract -> Construct x xs) = Store $ x :*: Tag . Construct % xs  instance (forall a . Chain a) => Insertable (Construction Wye) where-	insert x nonempty = let change = Just . maybe (Construct x End) (insert x) in+	insert x nonempty = let change = Just . resolve (insert x) (Construct x End) in 		x <=> extract nonempty & order (sub @Left %~ change $ nonempty) nonempty (sub @Right %~ change $ nonempty)  instance Substructure Left (Construction Wye) where 	type Substructural Left (Construction Wye) a = Maybe :. Construction Wye := a 	substructure empty_tree@(extract -> Construct _ End) = Store $ Nothing :*: (!) empty_tree-	substructure (extract -> Construct x (Left lst)) = Store $ Just lst :*: Tag . Construct x . maybe End Left-	substructure (extract -> Construct x (Right rst)) = Store $ Nothing :*: Tag . Construct x . maybe (Right rst) (Both % rst)-	substructure (extract -> Construct x (Both lst rst)) = Store $ Just lst :*: Tag . Construct x . maybe (Right rst) (Both % rst)+	substructure (extract -> Construct x (Left lst)) = Store $ Just lst :*: Tag . Construct x . resolve (Left) End+	substructure (extract -> Construct x (Right rst)) = Store $ Nothing :*: Tag . Construct x . resolve (Both % rst) (Right rst)+	substructure (extract -> Construct x (Both lst rst)) = Store $ Just lst :*: Tag . Construct x . resolve (Both % rst) (Right rst)  instance Substructure Right (Construction Wye) where 	type Substructural Right (Construction Wye) a = Maybe :. Construction Wye := a 	substructure emtpy_tree@(extract -> Construct _ End) = Store $ Nothing :*: (!) emtpy_tree-	substructure (extract -> Construct x (Left lst)) = Store $ Nothing :*: Tag . Construct x . maybe (Left lst) (Both lst)-	substructure (extract -> Construct x (Right rst)) = Store $ Just rst :*: Tag . Construct x . maybe End Right-	substructure (extract -> Construct x (Both lst rst)) = Store $ Just rst :*: Tag . Construct x . maybe (Left lst) (Both lst)+	substructure (extract -> Construct x (Left lst)) = Store $ Nothing :*: Tag . Construct x . resolve (Both lst) (Left lst)+	substructure (extract -> Construct x (Right rst)) = Store $ Just rst :*: Tag . Construct x . resolve (Right) End+	substructure (extract -> Construct x (Both lst rst)) = Store $ Just rst :*: Tag . Construct x . resolve (Both lst) (Left lst)++data Biforked a = Top | Leftward a | Rightward a++type instance Zipper (Construction Wye) = Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))++data Direction a = Up a | Down a++instance Rotatable Up (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) where+	type Rotational Up (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) a+		= Maybe :. (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) := a+	rotation (run . extract -> focused :*: TU (TU (Leftward (Construct (T_ (parent :*: TU (Just rst))) next)))) =+		Just . T_U $ Construct parent (Both focused rst) :*: TU (TU next)+	rotation (run . extract -> focused :*: TU (TU (Leftward (Construct (T_ (parent :*: TU Nothing)) next)))) =+		Just . T_U $ Construct parent (Left focused) :*: TU (TU next)+	rotation (run . extract -> focused :*: TU (TU (Rightward (Construct (T_ (parent :*: TU (Just lst))) next)))) =+		Just . T_U $ Construct parent (Both lst focused) :*: TU (TU next)+	rotation (run . extract -> focused :*: TU (TU (Rightward (Construct (T_ (parent :*: TU Nothing)) next)))) =+		Just . T_U $ Construct parent (Right focused) :*: TU (TU next)+	rotation (extract -> T_U (_ :*: TU (TU Top))) = Nothing++instance Rotatable (Down Left) (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) where+	type Rotational (Down Left) (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) a+		= Maybe :. (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) := a+	rotation (run . extract -> Construct x (Left lst) :*: TU (TU next)) = Just . T_U . (:*:) lst . TU . TU . Leftward . Construct (T_ $ x :*: TU Nothing) $ next+	rotation (run . extract -> Construct x (Both lst rst) :*: TU (TU next)) = Just . T_U . (:*:) lst . TU . TU . Leftward . Construct (T_ $ x :*: TU (Just rst)) $ next+	rotation (run . extract -> Construct _ (Right _) :*: _) = Nothing+	rotation (run . extract -> Construct _ End :*: _) = Nothing++instance Rotatable (Down Right) (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) where+	type Rotational (Down Right) (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) a+		= Maybe :. (Construction Wye <:.:> ((Biforked <:.> Construction Biforked) <:.> T_ Covariant (Maybe <:.> Construction Wye))) := a+	rotation (run . extract -> Construct x (Right rst) :*: TU (TU next)) = Just . T_U . (:*:) rst . TU . TU . Rightward . Construct (T_ $ x :*: TU Nothing) $ next+	rotation (run . extract -> Construct x (Both lst rst) :*: TU (TU next)) = Just . T_U . (:*:) rst . TU . TU . Rightward . Construct (T_ $ x :*: TU (Just lst)) $ next+	rotation (run . extract -> Construct _ (Left _) :*: _) = Nothing+	rotation (run . extract -> Construct _ End :*: _) = Nothing
Pandora/Paradigm/Structure/Interface/Set.hs view
@@ -1,16 +1,25 @@ module Pandora.Paradigm.Structure.Interface.Set where  import Pandora.Core.Morphism ((!), (%))-import Pandora.Pattern.Category ((.))+import Pandora.Pattern.Category ((.), ($)) import Pandora.Pattern.Functor.Traversable (Traversable ((->>))) import Pandora.Pattern.Object.Setoid (Setoid ((/=)))-import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Nothing), maybe)+import Pandora.Pattern.Object.Semigroup ((+))+import Pandora.Pattern.Object.Quasiring (one)+import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Nothing)) import Pandora.Paradigm.Primary.Functor.Predicate (equate)+import Pandora.Paradigm.Primary.Functor.Product (attached) import Pandora.Paradigm.Primary.Object.Boolean (Boolean (True, False))-import Pandora.Paradigm.Structure.Ability.Monotonic (Monotonic, find)+import Pandora.Paradigm.Primary.Object.Natural (Natural (Zero))+import Pandora.Paradigm.Structure.Ability.Monotonic (Monotonic (reduce), find)+import Pandora.Paradigm.Inventory.State (State, modify)+import Pandora.Paradigm.Controlflow.Effect (run) -member :: (Setoid a, Monotonic e a) => a -> e -> Boolean-member x = maybe False (True !) . find (equate x)+member :: forall e a . (Setoid a, Monotonic e a) => a -> e -> Boolean+member x = reduce @(Maybe a) @a (\_ _ -> True) False . find (equate x)  subset :: (Monotonic (t a) a, Traversable t, Setoid a, Setoid (t a)) => t a -> t a -> Boolean subset ss s = Nothing /= (ss ->> find % s . equate)++cardinality :: Traversable t => t a -> Natural+cardinality s = attached . run @(State _) % Zero $ s ->> (!) (modify @Natural (+ one))
Pandora/Paradigm/Structure/Rose.hs view
@@ -9,15 +9,16 @@ import Pandora.Pattern.Functor.Extractable (extract) import Pandora.Pattern.Functor.Avoidable (Avoidable (empty)) import Pandora.Pattern.Transformer.Liftable (lift)-import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Just, Nothing), maybe)+import Pandora.Paradigm.Primary.Functor.Maybe (Maybe (Just, Nothing)) import Pandora.Paradigm.Primary.Functor.Product (Product ((:*:))) import Pandora.Paradigm.Primary.Functor.Tagged (Tagged (Tag)) import Pandora.Paradigm.Primary.Transformer.Construction (Construction (Construct), deconstruct) import Pandora.Paradigm.Schemes.TU (TU (TU), type (<:.>)) import Pandora.Paradigm.Controlflow.Effect.Interpreted (run) import Pandora.Paradigm.Inventory.Store (Store (Store))-import Pandora.Paradigm.Structure.Ability.Nonempty (Nonempty) import Pandora.Paradigm.Structure.Ability.Focusable (Focusable (Focusing, focusing), Location (Root))+import Pandora.Paradigm.Structure.Ability.Monotonic (resolve)+import Pandora.Paradigm.Structure.Ability.Nonempty (Nonempty) import Pandora.Paradigm.Structure.Ability.Substructure (Substructure (Substructural, substructure)) import Pandora.Paradigm.Structure.Stack (Stack) @@ -27,7 +28,7 @@ 	type Focusing Root Rose a = Maybe a 	focusing (run . extract -> Nothing) = Store $ Nothing :*: Tag . TU . comap (Construct % empty) 	focusing (run . extract -> Just rose) = Store $ Just (extract rose)-		:*: Tag . maybe (TU Nothing) (lift . Construct % deconstruct rose)+		:*: Tag . resolve (lift . Construct % deconstruct rose) (TU Nothing)  instance Substructure Just Rose where 	type Substructural Just Rose a = Stack :. Construction Stack := a
Pandora/Paradigm/Structure/Stack.hs view
@@ -22,6 +22,7 @@ import Pandora.Paradigm.Primary.Functor.Predicate (Predicate (Predicate)) import Pandora.Paradigm.Primary.Functor.Product (Product ((:*:))) import Pandora.Paradigm.Primary.Functor.Tagged (Tagged (Tag))+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.Inventory.State (State, fold)@@ -33,7 +34,8 @@ import Pandora.Paradigm.Structure.Ability.Zipper (Zipper) import Pandora.Paradigm.Structure.Ability.Focusable (Focusable (Focusing, focusing), Location (Head), focus) import Pandora.Paradigm.Structure.Ability.Insertable (Insertable (insert))-import Pandora.Paradigm.Structure.Ability.Monotonic (Monotonic (bypass))+import Pandora.Paradigm.Structure.Ability.Monotonic (Monotonic (reduce))+import Pandora.Paradigm.Structure.Ability.Rotatable (Rotatable (Rotational, rotation))  -- | Linear data structure that serves as a collection of elements type Stack = Maybe <:.> Construction Maybe@@ -85,23 +87,27 @@ 	insert x = Construct x . Just  instance Monotonic (Construction Maybe a) a where-	bypass f r ~(Construct x xs) = f x $ bypass f r xs+	reduce f r ~(Construct x xs) = f x $ reduce f r xs  type instance Zipper Stack = Tap (Delta <:.> Stack) -forward, backward :: Zipper Stack a -> Maybe (Zipper Stack a)-forward (Tap x (TU (bs :^: fs))) = Tap % (TU $ insert x bs :^: pop fs) <$> focus @Head ^. fs-backward (Tap x (TU (bs :^: fs))) = Tap % (TU $ pop bs :^: insert x fs) <$> focus @Head ^. bs+instance Rotatable Left (Tap (Delta <:.> Stack)) where+	type Rotational Left (Tap (Delta <:.> Stack)) a = Maybe :. Zipper Stack := a+	rotation (extract -> Tap x (TU (bs :^: fs))) = Tap % (TU $ pop bs :^: insert x fs) <$> focus @Head ^. bs +instance Rotatable Right (Tap (Delta <:.> Stack)) where+	type Rotational Right (Tap (Delta <:.> Stack)) a = Maybe :. Zipper Stack := a+	rotation (extract -> Tap x (TU (bs :^: fs))) = Tap % (TU $ insert x bs :^: pop fs) <$> focus @Head ^. fs+ type instance Zipper (Construction Maybe) = Tap (Delta <:.> Construction Maybe) -forward', backward' :: Zipper (Nonempty Stack) a -> Maybe (Zipper (Nonempty Stack) a)-forward' (Tap x (TU (bs :^: fs))) = Tap (extract fs) . TU . (insert x bs :^:) <$> deconstruct fs-backward' (Tap x (TU (bs :^: fs))) = Tap (extract bs) . TU . (:^: insert x fs) <$> deconstruct bs+instance Rotatable Left (Tap (Delta <:.> Construction Maybe)) where+	type Rotational Left (Tap (Delta <:.> Construction Maybe)) a = Maybe :. Zipper (Construction Maybe) := a+	rotation (extract -> Tap x (TU (bs :^: fs))) = Tap (extract bs) . TU . (:^: insert x fs) <$> deconstruct bs -instance Monotonic (Maybe :. Construction Maybe := a) a where-	bypass f r (Just x) = bypass f r x-	bypass _ r Nothing = r+instance Rotatable Right (Tap (Delta <:.> Construction Maybe)) where+	type Rotational Right (Tap (Delta <:.> Construction Maybe)) a = Maybe :. Zipper (Construction Maybe) := a+	rotation (extract -> Tap x (TU (bs :^: fs))) = Tap (extract fs) . TU . (insert x bs :^:) <$> deconstruct fs  instance Monotonic (Maybe <:.> Construction Maybe := a) a where-	bypass f r ~(TU x) = bypass f r x+	reduce f r ~(TU x) = reduce f r x
Pandora/Paradigm/Structure/Stream.hs view
@@ -3,14 +3,16 @@ module Pandora.Paradigm.Structure.Stream where  import Pandora.Pattern.Category ((.), ($))+import Pandora.Pattern.Functor.Covariant ((<$>)) import Pandora.Pattern.Functor.Pointable (point) import Pandora.Pattern.Functor.Extractable (extract)+import Pandora.Pattern.Functor.Extendable (Extendable ((=>>))) import Pandora.Paradigm.Primary.Functor.Delta (Delta ((:^:))) import Pandora.Paradigm.Primary.Functor.Identity (Identity (Identity)) import Pandora.Paradigm.Primary.Functor.Wye (Wye (Left, Right))-import Pandora.Paradigm.Primary.Transformer.Construction (Construction (Construct), deconstruct)+import Pandora.Paradigm.Primary.Transformer.Construction (Construction (Construct), deconstruct, (.-+)) import Pandora.Paradigm.Primary.Transformer.Tap (Tap (Tap))-import Pandora.Paradigm.Structure.Ability.Rotatable (Rotatable (Rotational, rotation))+import Pandora.Paradigm.Structure.Ability.Rotatable (Rotatable (Rotational, rotation), rotate) import Pandora.Paradigm.Structure.Ability.Zipper (Zipper) import Pandora.Paradigm.Schemes.TU (TU (TU), type (<:.>)) @@ -27,6 +29,11 @@ 	type Rotational Right (Tap (Delta <:.> Stream)) a = Tap (Delta <:.> Stream) a 	rotation (extract -> Tap x (TU (bs :^: fs))) = Tap (extract fs) . TU 		$ Construct x (point bs) :^: extract (deconstruct fs)++instance {-# OVERLAPS #-} Extendable (Tap (Delta <:.> Stream)) where+	-- z =>> f = let move rtt = extract . deconstruct $ iterate (point . rtt) z+	z =>> f = let move rtt = extract . deconstruct $ point . rtt .-+ z+		in f <$> Tap z (TU $ move (rotate @Left) :^: move (rotate @Right))  repeat :: a -> Stream a repeat x = Construct x . Identity $ repeat x
Pandora/Pattern/Functor/Invariant.hs view
@@ -1,5 +1,7 @@ module Pandora.Pattern.Functor.Invariant where +import Pandora.Pattern.Category (($))+ {- | > When providing a new instance, you should ensure it satisfies the two laws: > Identity morphisms: invmap identity identity = identity@@ -7,5 +9,8 @@ -}  class Invariant (t :: * -> *) where-	{-# MINIMAL invmap #-}+	{-# MINIMAL (>-<) #-}+	(>-<) :: (a -> b) -> (b -> a) -> t a -> t b+	-- | Prefix version of '>-<' 	invmap :: (a -> b) -> (b -> a) -> t a -> t b+	invmap f g x = f >-< g $ x
pandora.cabal view
@@ -1,5 +1,5 @@ name:                pandora-version:             0.3.2+version:             0.3.3 synopsis:            A box of patterns and paradigms description:         Humble attempt to define a library for problem solving based on math abstractions. homepage:            https://github.com/iokasimov/pandora@@ -30,6 +30,7 @@     Pandora.Paradigm.Primary.Object     Pandora.Paradigm.Primary.Object.Boolean     Pandora.Paradigm.Primary.Object.Ordering+    Pandora.Paradigm.Primary.Object.Natural     Pandora.Paradigm.Primary.Functor     Pandora.Paradigm.Primary.Functor.Conclusion     Pandora.Paradigm.Primary.Functor.Constant@@ -68,6 +69,9 @@     Pandora.Paradigm.Schemes.TUVW     Pandora.Paradigm.Schemes.UT     Pandora.Paradigm.Schemes.UTU+    Pandora.Paradigm.Schemes.T_U+    Pandora.Paradigm.Schemes.T_+    Pandora.Paradigm.Schemes.U_T     -- Control flow primitives     Pandora.Paradigm.Controlflow     -- Typeclassess about functor junctions