pandora 0.1.2 → 0.1.3
raw patch · 20 files changed
+218/−90 lines, 20 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Pandora.Paradigm.Structure.Concrete.Graph: instance Pandora.Paradigm.Structure.Property.Hollow.Hollow Pandora.Paradigm.Basis.Edges.Edges
- Pandora.Paradigm.Structure.Concrete.Graph: loose :: Traversable t => t a -> Graph a
- Pandora.Paradigm.Structure.Concrete.Graph: type Graph a = (Cofree :>: Edges) a
- Pandora.Paradigm.Structure.Concrete.Stack: instance Pandora.Paradigm.Structure.Property.Hollow.Hollow Pandora.Paradigm.Basis.Maybe.Maybe
- Pandora.Paradigm.Structure.Concrete.Stack: linearize :: Traversable t => t a -> Stack a
- Pandora.Paradigm.Structure.Concrete.Stack: pop :: Stack a -> Stack a
- Pandora.Paradigm.Structure.Concrete.Stack: push :: a -> Stack a -> Stack a
- Pandora.Paradigm.Structure.Concrete.Stack: top :: Stack a -> Maybe a
- Pandora.Paradigm.Structure.Concrete.Stack: type Stack = (Cofree :>: Maybe)
- Pandora.Paradigm.Structure.Property.Hollow: class Hollow t
- Pandora.Paradigm.Structure.Property.Hollow: hollow :: Hollow t => r -> (Cofree t a -> r) -> (Cofree :>: t) a -> r
- Pandora.Paradigm.Structure.Property.Nonempty: type family Nonempty structure a :: *
+ Pandora.Paradigm.Basis.Cofree: instance (Pandora.Pattern.Object.Monoid.Monoid a, forall b. Pandora.Pattern.Object.Semigroup.Semigroup b => Pandora.Pattern.Object.Monoid.Monoid (t b)) => Pandora.Pattern.Object.Monoid.Monoid (Pandora.Paradigm.Basis.Cofree.Cofree t a)
+ Pandora.Paradigm.Basis.Cofree: instance (Pandora.Pattern.Object.Semigroup.Semigroup a, forall b. Pandora.Pattern.Object.Semigroup.Semigroup b => Pandora.Pattern.Object.Semigroup.Semigroup (t b)) => Pandora.Pattern.Object.Semigroup.Semigroup (Pandora.Paradigm.Basis.Cofree.Cofree t a)
+ Pandora.Paradigm.Basis.Cofree: instance (Pandora.Pattern.Object.Setoid.Setoid a, forall b. Pandora.Pattern.Object.Setoid.Setoid b => Pandora.Pattern.Object.Setoid.Setoid (t b)) => Pandora.Pattern.Object.Setoid.Setoid (Pandora.Paradigm.Basis.Cofree.Cofree t a)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Chain.Chain a => Pandora.Pattern.Object.Chain.Chain (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Group.Group a => Pandora.Pattern.Object.Group.Group (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Lattice.Lattice a => Pandora.Pattern.Object.Lattice.Lattice (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Monoid.Monoid a => Pandora.Pattern.Object.Monoid.Monoid (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Ringoid.Ringoid a => Pandora.Pattern.Object.Ringoid.Ringoid (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Semigroup.Semigroup a => Pandora.Pattern.Object.Semigroup.Semigroup (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Semilattice.Infimum a => Pandora.Pattern.Object.Semilattice.Infimum (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Semilattice.Supremum a => Pandora.Pattern.Object.Semilattice.Supremum (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Constant: instance forall k a (b :: k). Pandora.Pattern.Object.Setoid.Setoid a => Pandora.Pattern.Object.Setoid.Setoid (Pandora.Paradigm.Basis.Constant.Constant a b)
+ Pandora.Paradigm.Basis.Continuation: reset :: (Bindable t, Pointable t) => Continuation r t r -> Continuation s t r
+ Pandora.Paradigm.Basis.Continuation: shift :: Pointable t => ((a -> t r) -> Continuation r t r) -> Continuation r t a
+ Pandora.Paradigm.Basis.Endo: Endo :: (a -> a) -> Endo a
+ Pandora.Paradigm.Basis.Endo: [endo] :: Endo a -> a -> a
+ Pandora.Paradigm.Basis.Endo: instance Pandora.Pattern.Functor.Invariant.Invariant Pandora.Paradigm.Basis.Endo.Endo
+ Pandora.Paradigm.Basis.Endo: instance Pandora.Pattern.Object.Monoid.Monoid (Pandora.Paradigm.Basis.Endo.Endo a)
+ Pandora.Paradigm.Basis.Endo: instance Pandora.Pattern.Object.Semigroup.Semigroup (Pandora.Paradigm.Basis.Endo.Endo a)
+ Pandora.Paradigm.Basis.Endo: newtype Endo a
+ Pandora.Paradigm.Basis.Jack: instance (Pandora.Pattern.Object.Chain.Chain a, Pandora.Pattern.Object.Chain.Chain (t a)) => Pandora.Pattern.Object.Chain.Chain (Pandora.Paradigm.Basis.Jack.Jack t a)
+ Pandora.Paradigm.Basis.Jack: instance (Pandora.Pattern.Object.Setoid.Setoid a, Pandora.Pattern.Object.Setoid.Setoid (t a)) => Pandora.Pattern.Object.Setoid.Setoid (Pandora.Paradigm.Basis.Jack.Jack t a)
+ Pandora.Paradigm.Basis.Jack: instance Pandora.Pattern.Functor.Extractable.Extractable t => Pandora.Pattern.Functor.Extractable.Extractable (Pandora.Paradigm.Basis.Jack.Jack t)
+ Pandora.Paradigm.Junction.Transformer: instance forall k1 k2 (t :: (k2 -> *) -> k1 -> k2) (a :: k1) (u :: k2 -> *). (forall (u1 :: k2 -> *). Pandora.Pattern.Object.Chain.Chain ((Pandora.Core.Functor.:.:) u1 (t u1) a)) => Pandora.Pattern.Object.Chain.Chain (Pandora.Paradigm.Junction.Transformer.Y t u a)
+ Pandora.Paradigm.Junction.Transformer: instance forall k1 k2 (t :: (k2 -> *) -> k1 -> k2) (a :: k1) (u :: k2 -> *). (forall (u1 :: k2 -> *). Pandora.Pattern.Object.Monoid.Monoid ((Pandora.Core.Functor.:.:) u1 (t u1) a)) => Pandora.Pattern.Object.Monoid.Monoid (Pandora.Paradigm.Junction.Transformer.Y t u a)
+ Pandora.Paradigm.Junction.Transformer: instance forall k1 k2 (t :: (k2 -> *) -> k1 -> k2) (a :: k1) (u :: k2 -> *). (forall (u1 :: k2 -> *). Pandora.Pattern.Object.Semigroup.Semigroup ((Pandora.Core.Functor.:.:) u1 (t u1) a)) => Pandora.Pattern.Object.Semigroup.Semigroup (Pandora.Paradigm.Junction.Transformer.Y t u a)
+ Pandora.Paradigm.Junction.Transformer: instance forall k1 k2 (t :: (k2 -> *) -> k1 -> k2) (a :: k1) (u :: k2 -> *). (forall (u1 :: k2 -> *). Pandora.Pattern.Object.Setoid.Setoid ((Pandora.Core.Functor.:.:) u1 (t u1) a)) => Pandora.Pattern.Object.Setoid.Setoid (Pandora.Paradigm.Junction.Transformer.Y t u a)
+ Pandora.Paradigm.Junction.Transformer: instance forall k1 k2 (u :: k2 -> *) (t :: k1 -> k2) (a :: k1). Pandora.Pattern.Object.Chain.Chain ((Pandora.Core.Functor.:.:) u t a) => Pandora.Pattern.Object.Chain.Chain (Pandora.Paradigm.Junction.Transformer.T t u a)
+ Pandora.Paradigm.Junction.Transformer: instance forall k1 k2 (u :: k2 -> *) (t :: k1 -> k2) (a :: k1). Pandora.Pattern.Object.Monoid.Monoid ((Pandora.Core.Functor.:.:) u t a) => Pandora.Pattern.Object.Monoid.Monoid (Pandora.Paradigm.Junction.Transformer.T t u a)
+ Pandora.Paradigm.Junction.Transformer: instance forall k1 k2 (u :: k2 -> *) (t :: k1 -> k2) (a :: k1). Pandora.Pattern.Object.Semigroup.Semigroup ((Pandora.Core.Functor.:.:) u t a) => Pandora.Pattern.Object.Semigroup.Semigroup (Pandora.Paradigm.Junction.Transformer.T t u a)
+ Pandora.Paradigm.Junction.Transformer: instance forall k1 k2 (u :: k2 -> *) (t :: k1 -> k2) (a :: k1). Pandora.Pattern.Object.Setoid.Setoid ((Pandora.Core.Functor.:.:) u t a) => Pandora.Pattern.Object.Setoid.Setoid (Pandora.Paradigm.Junction.Transformer.T t u a)
+ Pandora.Paradigm.Structure: type family Nonempty structure a :: *
+ Pandora.Paradigm.Structure.Binary: insert :: Chain a => a -> Binary a -> Binary a
+ Pandora.Paradigm.Structure.Binary: type Binary = Cofree Wye
+ Pandora.Paradigm.Structure.Graph: loose :: Traversable t => t a -> Graph a
+ Pandora.Paradigm.Structure.Graph: type Graph a = (Cofree :>: Edges) a
+ Pandora.Paradigm.Structure.Stack: linearize :: Traversable t => t a -> Stack a
+ Pandora.Paradigm.Structure.Stack: pop :: Stack a -> Stack a
+ Pandora.Paradigm.Structure.Stack: push :: a -> Stack a -> Stack a
+ Pandora.Paradigm.Structure.Stack: top :: Stack a -> Maybe a
+ Pandora.Paradigm.Structure.Stack: type Stack = (Cofree :>: Maybe)
Files
- CHANGELOG.md +11/−0
- Pandora/Paradigm/Basis.hs +1/−0
- Pandora/Paradigm/Basis/Cofree.hs +12/−0
- Pandora/Paradigm/Basis/Constant.hs +34/−0
- Pandora/Paradigm/Basis/Continuation.hs +9/−1
- Pandora/Paradigm/Basis/Endo.hs +17/−0
- Pandora/Paradigm/Basis/Jack.hs +17/−0
- Pandora/Paradigm/Junction/Transformer.hs +28/−0
- Pandora/Paradigm/Structure.hs +11/−3
- Pandora/Paradigm/Structure/Binary.hs +15/−0
- Pandora/Paradigm/Structure/Concrete.hs +0/−4
- Pandora/Paradigm/Structure/Concrete/Graph.hs +0/−21
- Pandora/Paradigm/Structure/Concrete/Stack.hs +0/−34
- Pandora/Paradigm/Structure/Graph.hs +15/−0
- Pandora/Paradigm/Structure/Property.hs +0/−4
- Pandora/Paradigm/Structure/Property/Hollow.hs +0/−8
- Pandora/Paradigm/Structure/Property/Nonempty.hs +0/−8
- Pandora/Paradigm/Structure/Stack.hs +29/−0
- README.md +14/−0
- pandora.cabal +5/−7
CHANGELOG.md view
@@ -16,3 +16,14 @@ * Define `Graph` concrete structure * Define infix `:-.` type operator for Lens * Define `Object` instances for `Product` datatype++# 0.1.3+* Define `Object` instances for `Cofree` datatype+* Define all `Object` pattern instances for `Constant` datatype+* Define `reset` and `shift` methods for `Continuation` datatype+* Define `Endo` datatype in `Basis` module+* Define `Object` instances for transformer schemes+* Define `Binary` tree concrete structure+* Define some `Object` instances for `Jack` datatype+* Remove `Hollow` ad-hoc typeclass+* Merge `Property` and `Concrete` modules back
Pandora/Paradigm/Basis.hs view
@@ -10,6 +10,7 @@ import Pandora.Paradigm.Basis.Edges as Exports import Pandora.Paradigm.Basis.Conclusion as Exports import Pandora.Paradigm.Basis.Maybe as Exports+import Pandora.Paradigm.Basis.Endo as Exports import Pandora.Paradigm.Basis.Jack as Exports import Pandora.Paradigm.Basis.Product as Exports import Pandora.Paradigm.Basis.Constant as Exports
Pandora/Paradigm/Basis/Cofree.hs view
@@ -13,6 +13,9 @@ import Pandora.Pattern.Functor.Extendable (Extendable ((=>>), extend)) import Pandora.Pattern.Functor.Monad (Monad) import Pandora.Pattern.Functor.Comonad (Comonad)+import Pandora.Pattern.Object.Setoid (Setoid ((==)), (&&))+import Pandora.Pattern.Object.Semigroup (Semigroup ((<>)))+import Pandora.Pattern.Object.Monoid (Monoid (unit)) data Cofree t a = a :< (t :.: Cofree t) a @@ -41,6 +44,15 @@ instance (Exclusive t, Alternative t) => Monad (Cofree t) where instance Covariant t => Comonad (Cofree t) where++instance (Setoid a, forall b . Setoid b => Setoid (t b)) => Setoid (Cofree t a) where+ (x :< xs) == (y :< ys) = x == y && xs == ys++instance (Semigroup a, forall b . Semigroup b => Semigroup (t b)) => Semigroup (Cofree t a) where+ (x :< xs) <> (y :< ys) = (x <> y) :< (xs <> ys)++instance (Monoid a, forall b . Semigroup b => Monoid (t b)) => Monoid (Cofree t a) where+ unit = unit :< unit unwrap :: Cofree t a -> (t :.: Cofree t) a unwrap (_ :< xs) = xs
Pandora/Paradigm/Basis/Constant.hs view
@@ -6,6 +6,14 @@ import Pandora.Pattern.Functor.Invariant (Invariant (invmap)) import Pandora.Pattern.Functor.Pointable (Pointable (point)) import Pandora.Pattern.Functor.Traversable (Traversable ((->>)))+import Pandora.Pattern.Object.Setoid (Setoid ((==)))+import Pandora.Pattern.Object.Chain (Chain ((<=>)))+import Pandora.Pattern.Object.Semigroup (Semigroup ((<>)))+import Pandora.Pattern.Object.Monoid (Monoid (unit))+import Pandora.Pattern.Object.Ringoid (Ringoid ((><)))+import Pandora.Pattern.Object.Semilattice (Infimum ((/\)), Supremum ((\/)))+import Pandora.Pattern.Object.Lattice (Lattice)+import Pandora.Pattern.Object.Group (Group (inverse)) newtype Constant a b = Constant a @@ -20,3 +28,29 @@ instance Traversable (Constant a) where Constant x ->> _ = point (Constant x)++instance Setoid a => Setoid (Constant a b) where+ Constant x == Constant y = x == y++instance Chain a => Chain (Constant a b) where+ Constant x <=> Constant y = x <=> y++instance Semigroup a => Semigroup (Constant a b) where+ Constant x <> Constant y = Constant $ x <> y++instance Monoid a => Monoid (Constant a b) where+ unit = Constant unit++instance Ringoid a => Ringoid (Constant a b) where+ Constant x >< Constant y = Constant $ x >< y++instance Infimum a => Infimum (Constant a b) where+ Constant x /\ Constant y = Constant $ x /\ y++instance Supremum a => Supremum (Constant a b) where+ Constant x \/ Constant y = Constant $ x \/ y++instance Lattice a => Lattice (Constant a b) where++instance Group a => Group (Constant a b) where+ inverse (Constant x) = Constant $ inverse x
Pandora/Paradigm/Basis/Continuation.hs view
@@ -1,4 +1,4 @@-module Pandora.Paradigm.Basis.Continuation (Continuation (..), oblige, cwcc) where+module Pandora.Paradigm.Basis.Continuation (Continuation (..), oblige, cwcc, reset, shift) where import Pandora.Core.Morphism ((.), ($), (!), (?)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>)))@@ -30,3 +30,11 @@ -- | Call with current continuation cwcc :: ((a -> Continuation r t b) -> Continuation r t a) -> Continuation r t a cwcc f = Continuation $ \g -> continue ? g . f $ Continuation . (!) . g++-- | Delimit the continuation of any 'shift'+reset :: (Bindable t, Pointable t) => Continuation r t r -> Continuation s t r+reset = oblige . continue ? point++-- | Capture the continuation up to the nearest enclosing 'reset' and pass it+shift :: Pointable t => ((a -> t r) -> Continuation r t r) -> Continuation r t a+shift f = Continuation $ continue ? point . f
+ Pandora/Paradigm/Basis/Endo.hs view
@@ -0,0 +1,17 @@+module Pandora.Paradigm.Basis.Endo (Endo (..)) where++import Pandora.Core.Morphism ((.), identity)+import Pandora.Pattern.Functor.Invariant (Invariant (invmap))+import Pandora.Pattern.Object.Semigroup (Semigroup ((<>)))+import Pandora.Pattern.Object.Monoid (Monoid (unit))++newtype Endo a = Endo { endo :: a -> a }++instance Invariant Endo where+ invmap f g (Endo x) = Endo (f . x . g)++instance Semigroup (Endo a) where+ Endo f <> Endo g = Endo (g . f)++instance Monoid (Endo a) where+ unit = Endo identity
Pandora/Paradigm/Basis/Jack.hs view
@@ -10,6 +10,8 @@ import Pandora.Pattern.Functor.Traversable (Traversable ((->>), traverse)) import Pandora.Pattern.Functor.Distributive (Distributive ((>>-), distribute)) import Pandora.Pattern.Functor.Liftable (Liftable (lift))+import Pandora.Pattern.Object.Setoid (Setoid ((==)), Boolean (False))+import Pandora.Pattern.Object.Chain (Chain ((<=>)), Ordering (Less, Greater)) data Jack t a = It a | Other (t a) @@ -28,6 +30,10 @@ instance Exclusive t => Exclusive (Jack t) where exclusive = Other exclusive +instance Extractable t => Extractable (Jack t) where+ extract (It x) = x+ extract (Other y) = extract y+ instance Applicative t => Applicative (Jack t) where It f <*> It x = It $ f x It f <*> Other y = Other $ f <$> y@@ -43,6 +49,17 @@ instance Liftable Jack where lift = Other++instance (Setoid a, Setoid (t a)) => Setoid (Jack t a) where+ It x == It y = x == y+ Other x == Other y = x == y+ _ == _ = False++instance (Chain a, Chain (t a)) => Chain (Jack t a) where+ It _ <=> Other _ = Less+ Other _ <=> It _ = Greater+ It x <=> It y = x <=> y+ Other x <=> Other y = x <=> y jack :: (a -> r) -> (t a -> r) -> Jack t a -> r jack f _ (It x) = f x
Pandora/Paradigm/Junction/Transformer.hs view
@@ -13,6 +13,10 @@ import Pandora.Pattern.Functor.Bindable (Bindable ((>>=), bind)) import Pandora.Pattern.Functor.Liftable (Liftable (lift)) import Pandora.Pattern.Functor.Lowerable (Lowerable (lower))+import Pandora.Pattern.Object.Setoid (Setoid ((==)))+import Pandora.Pattern.Object.Chain (Chain ((<=>)))+import Pandora.Pattern.Object.Semigroup (Semigroup ((<>)))+import Pandora.Pattern.Object.Monoid (Monoid (unit)) infixr 0 :!:, :>: type (:!:) t u = T t u@@ -51,6 +55,18 @@ instance (Distributive t, Distributive u) => Distributive (T t u) where x >>- f = T . comap distribute . distribute $ t . f <$> x +instance Setoid ((u :.: t) a) => Setoid (T t u a) where+ T x == T y = x == y++instance Chain ((u :.: t) a) => Chain (T t u a) where+ T x <=> T y = x <=> y++instance Semigroup ((u :.: t) a) => Semigroup (T t u a) where+ T x <> T y = T $ x <> y++instance Monoid ((u :.: t) a) => Monoid (T t u a) where+ unit = T unit+ up :: Pointable u => t a -> T t u a up = T . point @@ -86,3 +102,15 @@ instance (forall u . Extractable u, Lowerable t) => Lowerable (Y t) where lower = lower . extract . y++instance (forall u . Setoid ((u :.: t u) a)) => Setoid (Y t u a) where+ Y x == Y y = x == y++instance (forall u . Chain ((u :.: t u) a)) => Chain (Y t u a) where+ Y x <=> Y y = x <=> y++instance (forall u . Semigroup ((u :.: t u) a)) => Semigroup (Y t u a) where+ Y x <> Y y = Y $ x <> y++instance (forall u . Monoid ((u :.: t u) a)) => Monoid (Y t u a) where+ unit = Y unit
Pandora/Paradigm/Structure.hs view
@@ -1,4 +1,12 @@-module Pandora.Paradigm.Structure (module Exports) where+module Pandora.Paradigm.Structure (module Exports, Nonempty) where -import Pandora.Paradigm.Structure.Concrete as Exports-import Pandora.Paradigm.Structure.Property as Exports+import Pandora.Paradigm.Structure.Binary as Exports+import Pandora.Paradigm.Structure.Graph as Exports+import Pandora.Paradigm.Structure.Stack as Exports++import Pandora.Paradigm.Basis.Cofree (Cofree)+import Pandora.Paradigm.Junction.Transformer (type (:>:))++-- | Type synonymous for at least one element data structure+type family Nonempty structure a :: * where+ Nonempty (Cofree :>: t) a = Cofree t a
+ Pandora/Paradigm/Structure/Binary.hs view
@@ -0,0 +1,15 @@+module Pandora.Paradigm.Structure.Binary (Binary, insert) where++import Pandora.Core.Morphism ((&))+import Pandora.Paradigm.Basis.Wye (Wye (End, Left, Right, Both))+import Pandora.Paradigm.Basis.Cofree (Cofree ((:<)))+import Pandora.Paradigm.Junction.Transformer (Y (Y), type (:>:))+import Pandora.Pattern.Object.Chain (Chain ((<=>)), order)++type Binary = Cofree Wye++insert :: Chain a => a -> Binary a -> Binary a+insert x (y :< End) = x <=> y & order (y :< Right (x :< End)) (y :< Right (x :< End)) (y :< Left (x :< End))+insert x (y :< Left ls) = x <=> y & order (y :< Both ls (x :< End)) (y :< Both ls (x :< End)) (y :< Left (insert x ls))+insert x (y :< Right rs) = x <=> y & order (y :< Right (insert x rs)) (y :< Right (insert x rs)) (y :< Both (x :< End) rs)+insert x (y :< Both ls rs) = x <=> y & order (y :< Both ls (insert x rs)) (y :< Both ls (insert x rs)) (y :< Both (insert x ls) rs)
− Pandora/Paradigm/Structure/Concrete.hs
@@ -1,4 +0,0 @@-module Pandora.Paradigm.Structure.Concrete (module Exports) where--import Pandora.Paradigm.Structure.Concrete.Graph as Exports-import Pandora.Paradigm.Structure.Concrete.Stack as Exports
− Pandora/Paradigm/Structure/Concrete/Graph.hs
@@ -1,21 +0,0 @@-module Pandora.Paradigm.Structure.Concrete.Graph (Graph, loose) where--import Pandora.Core.Morphism ((.))-import Pandora.Paradigm.Basis.Edges (Edges (Empty, Connect, Overlay))-import Pandora.Paradigm.Basis.Cofree (Cofree ((:<)))-import Pandora.Paradigm.Junction.Transformer (Y (Y), type (:>:))-import Pandora.Paradigm.Inventory.Stateful (fold)-import Pandora.Paradigm.Structure.Property.Hollow (Hollow (hollow))-import Pandora.Pattern.Functor.Traversable (Traversable)---- | Acyclic graph structure without loops-type Graph a = (Cofree :>: Edges) a--instance Hollow Edges where- hollow result _ (Y Empty) = result- hollow _ f (Y (Connect struct)) = f struct- hollow _ f (Y (Overlay struct)) = f struct---- | Transform any traversable structure into all loose edges graph-loose :: Traversable t => t a -> Graph a-loose = Y . fold Empty (\x -> Overlay . (:<) x)
− Pandora/Paradigm/Structure/Concrete/Stack.hs
@@ -1,34 +0,0 @@-module Pandora.Paradigm.Structure.Concrete.Stack (Stack, push, top, pop, linearize) where--import Pandora.Core.Morphism ((.), ($))-import Pandora.Paradigm.Basis.Cofree (Cofree ((:<)), unwrap)-import Pandora.Paradigm.Basis.Maybe (Maybe (Just, Nothing))-import Pandora.Paradigm.Junction.Transformer (Y (Y, y), type (:>:))-import Pandora.Paradigm.Inventory.Stateful (fold)-import Pandora.Paradigm.Structure.Property.Hollow (Hollow (hollow))-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.Traversable (Traversable)-import Pandora.Pattern.Functor.Bindable (Bindable ((>>=)))---- | Linear data structure that serves as a collection of elements-type Stack = (Cofree :>: Maybe)--instance Hollow Maybe where- hollow result _ (Y Nothing) = result- hollow _ f (Y (Just struct)) = f struct--push :: a -> Stack a -> Stack a-push x (Y struct) = (Y $ (:<) x . Just <$> struct) <+> point x--top :: Stack a -> Maybe a-top (Y struct) = extract <$> struct--pop :: Stack a -> Stack a-pop (Y struct) = Y $ struct >>= unwrap---- | Transform any traversable structure into a stack-linearize :: Traversable t => t a -> Stack a-linearize = Y . fold Nothing (\x -> Just . (:<) x)
+ Pandora/Paradigm/Structure/Graph.hs view
@@ -0,0 +1,15 @@+module Pandora.Paradigm.Structure.Graph (Graph, loose) where++import Pandora.Core.Morphism ((.))+import Pandora.Paradigm.Basis.Edges (Edges (Empty, Connect, Overlay))+import Pandora.Paradigm.Basis.Cofree (Cofree ((:<)))+import Pandora.Paradigm.Junction.Transformer (Y (Y), type (:>:))+import Pandora.Paradigm.Inventory.Stateful (fold)+import Pandora.Pattern.Functor.Traversable (Traversable)++-- | Acyclic graph structure without loops+type Graph a = (Cofree :>: Edges) a++-- | Transform any traversable structure into all loose edges graph+loose :: Traversable t => t a -> Graph a+loose = Y . fold Empty (\x -> Overlay . (:<) x)
− Pandora/Paradigm/Structure/Property.hs
@@ -1,4 +0,0 @@-module Pandora.Paradigm.Structure.Property (module Exports) where--import Pandora.Paradigm.Structure.Property.Nonempty as Exports-import Pandora.Paradigm.Structure.Property.Hollow as Exports
− Pandora/Paradigm/Structure/Property/Hollow.hs
@@ -1,8 +0,0 @@-module Pandora.Paradigm.Structure.Property.Hollow (Hollow (..)) where--import Pandora.Paradigm.Basis.Cofree (Cofree)-import Pandora.Paradigm.Junction.Transformer (type (:>:))--class Hollow t where- -- | Destructor based on emptiness check- hollow :: r -> (Cofree t a -> r ) -> (Cofree :>: t) a -> r
− Pandora/Paradigm/Structure/Property/Nonempty.hs
@@ -1,8 +0,0 @@-module Pandora.Paradigm.Structure.Property.Nonempty (Nonempty) where--import Pandora.Paradigm.Basis.Cofree (Cofree)-import Pandora.Paradigm.Junction.Transformer (type (:>:))---- | Type synonymous for at least one element data structure-type family Nonempty structure a :: * where- Nonempty (Cofree :>: t) a = Cofree t a
+ Pandora/Paradigm/Structure/Stack.hs view
@@ -0,0 +1,29 @@+module Pandora.Paradigm.Structure.Stack (Stack, push, top, pop, linearize) where++import Pandora.Core.Morphism ((.), ($))+import Pandora.Paradigm.Basis.Cofree (Cofree ((:<)), unwrap)+import Pandora.Paradigm.Basis.Maybe (Maybe (Just, Nothing))+import Pandora.Paradigm.Junction.Transformer (Y (Y, y), type (:>:))+import Pandora.Paradigm.Inventory.Stateful (fold)+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.Traversable (Traversable)+import Pandora.Pattern.Functor.Bindable (Bindable ((>>=)))++-- | Linear data structure that serves as a collection of elements+type Stack = (Cofree :>: Maybe)++push :: a -> Stack a -> Stack a+push x (Y struct) = (Y $ (:<) x . Just <$> struct) <+> point x++top :: Stack a -> Maybe a+top (Y struct) = extract <$> struct++pop :: Stack a -> Stack a+pop (Y struct) = Y $ struct >>= unwrap++-- | Transform any traversable structure into a stack+linearize :: Traversable t => t a -> Stack a+linearize = Y . fold Nothing (\x -> Just . (:<) x)
README.md view
@@ -1,5 +1,19 @@ # Pandora - the box of patterns and paradigms +This is humble attempt to define pure core library for problem solving.++Used materials:++* Paper: `Fast Coroutine Pipelines`+* Twit: https://twitter.com/xgrommx/status/964307440517963776+* Library: http://hackage.haskell.org/package/base+* Library: http://hackage.haskell.org/package/adjunctions+* Library: http://hackage.haskell.org/package/distributive+* Library: http://hackage.haskell.org/package/comonad+* Library: http://hackage.haskell.org/package/semigroupoids+* Library: http://hackage.haskell.org/package/transformers+* Library: http://hackage.haskell.org/package/invariant+ ## Diagram of functor patterns: 
pandora.cabal view
@@ -1,5 +1,5 @@ name: pandora-version: 0.1.2+version: 0.1.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@@ -29,6 +29,7 @@ Pandora.Paradigm.Basis.Constant Pandora.Paradigm.Basis.Continuation Pandora.Paradigm.Basis.Edges+ Pandora.Paradigm.Basis.Endo Pandora.Paradigm.Basis.Fix Pandora.Paradigm.Basis.Free Pandora.Paradigm.Basis.Identity@@ -55,12 +56,9 @@ Pandora.Paradigm.Inventory.Storage -- Tree-based datastructures Pandora.Paradigm.Structure- Pandora.Paradigm.Structure.Concrete- Pandora.Paradigm.Structure.Property- Pandora.Paradigm.Structure.Concrete.Stack- Pandora.Paradigm.Structure.Concrete.Graph- Pandora.Paradigm.Structure.Property.Hollow- Pandora.Paradigm.Structure.Property.Nonempty+ Pandora.Paradigm.Structure.Stack+ Pandora.Paradigm.Structure.Graph+ Pandora.Paradigm.Structure.Binary -- Functor typeclassess Pandora.Pattern.Functor Pandora.Pattern.Functor.Adjoint