packages feed

pandora 0.1.3 → 0.1.4

raw patch · 21 files changed

+181/−76 lines, 21 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Pandora.Paradigm.Basis.Product: (:*) :: a -> b -> Product a b
+ Pandora.Paradigm.Basis.Conclusion: fail :: (e -> r) -> Conclusion e a -> Conclusion r a
+ Pandora.Paradigm.Basis.Jet: (:-) :: a -> Jet t (t a) -> Jet t a
+ Pandora.Paradigm.Basis.Jet: data Jet t a
+ Pandora.Paradigm.Basis.Jet: instance (forall (t1 :: * -> *). Pandora.Pattern.Functor.Exclusive.Exclusive t1) => Pandora.Pattern.Functor.Pointable.Pointable (Pandora.Paradigm.Basis.Jet.Jet t)
+ Pandora.Paradigm.Basis.Jet: instance Pandora.Pattern.Functor.Covariant.Covariant t => Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Basis.Jet.Jet t)
+ Pandora.Paradigm.Basis.Jet: instance Pandora.Pattern.Functor.Covariant.Covariant t => Pandora.Pattern.Functor.Extractable.Extractable (Pandora.Paradigm.Basis.Jet.Jet t)
+ Pandora.Paradigm.Basis.Jet: instance Pandora.Pattern.Functor.Traversable.Traversable t => Pandora.Pattern.Functor.Traversable.Traversable (Pandora.Paradigm.Basis.Jet.Jet t)
+ Pandora.Paradigm.Basis.Product: (:*:) :: a -> b -> Product a b
+ Pandora.Paradigm.Basis.Product: type family Injective xs ys
+ Pandora.Paradigm.Basis.Variation: That :: e -> Variation e a
+ Pandora.Paradigm.Basis.Variation: These :: e -> a -> Variation e a
+ Pandora.Paradigm.Basis.Variation: This :: a -> Variation e a
+ Pandora.Paradigm.Basis.Variation: data Variation e a
+ Pandora.Paradigm.Basis.Variation: instance Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Basis.Variation.Variation e)
+ Pandora.Paradigm.Basis.Variation: instance Pandora.Pattern.Functor.Pointable.Pointable (Pandora.Paradigm.Basis.Variation.Variation e)
+ Pandora.Paradigm.Basis.Variation: instance Pandora.Pattern.Functor.Traversable.Traversable (Pandora.Paradigm.Basis.Variation.Variation e)
+ Pandora.Paradigm.Basis.Variation: variation :: (a -> r) -> (e -> r) -> (e -> a -> r) -> Variation e a -> r
+ Pandora.Paradigm.Inventory.Stateful: find :: (Pointable u, Exclusive u, Alternative u, Traversable t) => Predicate a -> t a -> u a
+ Pandora.Paradigm.Structure.Stack: filter :: Predicate a -> Stack a -> Stack a
+ Pandora.Pattern.Functor.Contravariant: (>$$$<) :: (Contravariant t, Contravariant u, Contravariant v) => (a -> b) -> t (u (v b)) -> t (u (v a))
+ Pandora.Pattern.Functor.Covariant: (<$$$$>) :: (Covariant t, Covariant u, Covariant v, Covariant w) => (a -> b) -> t (u (v (w a))) -> t (u (v (w b)))
+ Pandora.Pattern.Functor.Covariant: (<$$$>) :: (Covariant t, Covariant u, Covariant v) => (a -> b) -> t (u (v a)) -> t (u (v b))
+ Pandora.Pattern.Functor.Covariant: (<$$>) :: (Covariant t, Covariant u) => (a -> b) -> t (u a) -> t (u b)
+ Pandora.Pattern.Functor.Covariant: loeb :: Covariant t => t (t a -> a) -> t a
- Pandora.Paradigm.Basis.Product: attached :: (a :* b) -> a
+ Pandora.Paradigm.Basis.Product: attached :: (a :*: b) -> a
- Pandora.Paradigm.Basis.Product: delta :: a -> a :* a
+ Pandora.Paradigm.Basis.Product: delta :: a -> a :*: a
- Pandora.Paradigm.Basis.Product: infixr 1 :*
+ Pandora.Paradigm.Basis.Product: infixr 1 :*:
- Pandora.Paradigm.Basis.Product: swap :: (a :* b) -> b :* a
+ Pandora.Paradigm.Basis.Product: swap :: (a :*: b) -> b :*: a
- Pandora.Paradigm.Basis.Product: type (:*) = Product
+ Pandora.Paradigm.Basis.Product: type (:*:) = Product
- Pandora.Paradigm.Inventory.Stateful: Stateful :: ((->) s :.: (t :.: (:*) s)) a -> Stateful s t a
+ Pandora.Paradigm.Inventory.Stateful: Stateful :: ((->) s :.: (t :.: (:*:) s)) a -> Stateful s t a
- Pandora.Paradigm.Inventory.Stateful: [statefully] :: Stateful s t a -> ((->) s :.: (t :.: (:*) s)) a
+ Pandora.Paradigm.Inventory.Stateful: [statefully] :: Stateful s t a -> ((->) s :.: (t :.: (:*:) s)) a
- Pandora.Paradigm.Inventory.Storage: Storage :: ((:*) p :.: (t :.: (->) p)) a -> Storage p t a
+ Pandora.Paradigm.Inventory.Storage: Storage :: ((:*:) p :.: (t :.: (->) p)) a -> Storage p t a
- Pandora.Paradigm.Inventory.Storage: [stored] :: Storage p t a -> ((:*) p :.: (t :.: (->) p)) a
+ Pandora.Paradigm.Inventory.Storage: [stored] :: Storage p t a -> ((:*:) p :.: (t :.: (->) p)) a

Files

CHANGELOG.md view
@@ -14,7 +14,7 @@ * Define `Hollow` type class for handling empty structures * Extract `Nonempty` into a separated module * Define `Graph` concrete structure-* Define infix `:-.` type operator for Lens+* Define infix `:-.` type operator for `Lens` * Define `Object` instances for `Product` datatype  # 0.1.3@@ -27,3 +27,15 @@ * Define some `Object` instances for `Jack` datatype * Remove `Hollow` ad-hoc typeclass * Merge `Property` and `Concrete` modules back++# 0.1.4+* Define `Jet` datatype in `Basis` module+* Add `fail` method for `Conclusion` datatype+* Define `find` method in terms of stateful traversing+* Define `filter` method for `Stack` datastructure+* Define `loeb` method for `Covariant` type class+* Define `Variation` datatype in `Basis` module+* Define infix versions of `comap` with various nesting levels+* Define infix versions of `contramap` with various nesting levels+* Rename `Product` constructor from `:*` to `:*:`+* Define `Has` and `Injective` type families for `Product` proofs
Pandora/Paradigm/Basis.hs view
@@ -6,18 +6,20 @@ import Pandora.Paradigm.Basis.Yoneda as Exports import Pandora.Paradigm.Basis.Continuation as Exports import Pandora.Paradigm.Basis.Predicate as Exports+import Pandora.Paradigm.Basis.Variation as Exports import Pandora.Paradigm.Basis.Wye as Exports 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.Jet as Exports import Pandora.Paradigm.Basis.Jack as Exports import Pandora.Paradigm.Basis.Product as Exports import Pandora.Paradigm.Basis.Constant as Exports import Pandora.Paradigm.Basis.Identity as Exports  import Pandora.Core.Functor (type (~>))-import Pandora.Core.Morphism ((.), (!))+import Pandora.Core.Morphism ((!))  note :: e -> Maybe ~> Conclusion e note x = maybe (Failure x) Success
Pandora/Paradigm/Basis/Conclusion.hs view
@@ -1,6 +1,6 @@-module Pandora.Paradigm.Basis.Conclusion (Conclusion (..), conclusion) where+module Pandora.Paradigm.Basis.Conclusion (Conclusion (..), conclusion, fail) where -import Pandora.Core.Morphism ((.), ($), (!))+import Pandora.Core.Morphism ((.), ($)) import Pandora.Paradigm.Junction.Transformer (T (T, t), type (:!:)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Pointable (Pointable (point))@@ -24,11 +24,11 @@  instance Applicative (Conclusion e) where 	Success f <*> x = f <$> x-	Failure y <*> x = Failure y+	Failure y <*> _ = Failure y  instance Alternative (Conclusion e) where-	Failure y <+> x = x-	Success x <+> y = Success x+	Failure _ <+> x = x+	Success x <+> _ = Success x  instance Traversable (Conclusion e) where 	Failure y ->> _ = point $ Failure y@@ -59,9 +59,13 @@ instance (Semigroup e, Semigroup a) => Semigroup (Conclusion e a) where 	Success x <> Success y = Success $ x <> y 	Failure x <> Failure y = Failure $ x <> y-	Failure x <> Success y = Success y-	Success x <> Failure y = Success x+	Failure _ <> Success y = Success y+	Success x <> Failure _ = Success x  conclusion :: (e -> r) -> (a -> r) -> Conclusion e a -> r conclusion f _ (Failure x) = f x conclusion _ s (Success x) = s x++fail :: (e -> r) -> Conclusion e a -> Conclusion r a+fail f (Failure x) = Failure $ f x+fail _ (Success y) = Success y
Pandora/Paradigm/Basis/Edges.hs view
@@ -8,16 +8,16 @@ data Edges a = Empty | Connect a | Overlay a  instance Covariant Edges where-	f <$> Empty = Empty+	_ <$> Empty = Empty 	f <$> Connect x = Connect $ f x 	f <$> Overlay x = Overlay $ f x  instance Traversable Edges where-	Empty ->> f = point Empty+	Empty ->> _ = point Empty 	Connect x ->> f = Connect <$> f x 	Overlay x ->> f = Overlay <$> f x  edges :: r -> (a -> r) -> (a -> r) -> Edges a -> r edges r _ _ Empty = r-edges _ f g (Connect x) = f x-edges _ f g (Overlay y) = g y+edges _ f _ (Connect x) = f x+edges _ _ g (Overlay y) = g y
+ Pandora/Paradigm/Basis/Jet.hs view
@@ -0,0 +1,23 @@+module Pandora.Paradigm.Basis.Jet (Jet (..)) where++import Pandora.Core.Morphism ((.))+import Pandora.Pattern.Functor.Covariant (Covariant ((<$>)), comap)+import Pandora.Pattern.Functor.Exclusive (Exclusive (exclusive))+import Pandora.Pattern.Functor.Pointable (Pointable (point))+import Pandora.Pattern.Functor.Extractable (Extractable (extract))+import Pandora.Pattern.Functor.Applicative (Applicative ((<*>)))+import Pandora.Pattern.Functor.Traversable (Traversable ((->>), traverse))++data Jet t a = a :- Jet t (t a)++instance Covariant t => Covariant (Jet t) where+	f <$> a :- as = f a :- (comap . comap) f as++instance Traversable t => Traversable (Jet t) where+	a :- as ->> f = (:-) <$> f a <*> (traverse . traverse) f as++instance (forall t . Exclusive t) => Pointable (Jet t) where+	point x = x :- exclusive++instance Covariant t => Extractable (Jet t) where+	extract (x :- _) = x
Pandora/Paradigm/Basis/Maybe.hs view
@@ -1,8 +1,6 @@ module Pandora.Paradigm.Basis.Maybe (Maybe (..), maybe) where -import Pandora.Core.Functor (Variant (Co)) import Pandora.Core.Morphism ((.), ($))-import Pandora.Paradigm.Basis.Identity (Identity (Identity)) import Pandora.Paradigm.Junction.Transformer (T (T, t), type (:!:)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Exclusive (Exclusive (exclusive))@@ -12,7 +10,6 @@ import Pandora.Pattern.Functor.Traversable (Traversable ((->>))) import Pandora.Pattern.Functor.Bindable (Bindable ((>>=))) import Pandora.Pattern.Functor.Monad (Monad)-import Pandora.Pattern.Functor.Liftable (Liftable (lift)) import Pandora.Pattern.Object.Setoid (Setoid ((==)), Boolean (True, False)) import Pandora.Pattern.Object.Chain (Chain ((<=>)), Ordering (Less, Equal, Greater)) import Pandora.Pattern.Object.Semigroup (Semigroup ((<>)))@@ -24,7 +21,7 @@  instance Covariant Maybe where 	f <$> Just x = Just $ f x-	f <$> Nothing = Nothing+	_ <$> Nothing = Nothing  instance Pointable Maybe where 	point = Just@@ -34,11 +31,11 @@  instance Applicative Maybe where 	Just f <*> x = f <$> x-	Nothing <*> x = Nothing+	Nothing <*> _ = Nothing  instance Alternative Maybe where 	Nothing <+> y = y-	Just x <+> y = Just x+	Just x <+> _ = Just x  instance Traversable Maybe where 	Nothing ->> _ = point Nothing@@ -63,8 +60,8 @@ instance Chain a => Chain (Maybe a) where 	Just x <=> Just y = x <=> y 	Nothing <=> Nothing = Equal-	Nothing <=> Just x = Less-	Just x <=> Nothing = Greater+	Nothing <=> Just _ = Less+	Just _ <=> Nothing = Greater  instance Semigroup a => Semigroup (Maybe a) where 	Just x <> Just y = Just $ x <> y
Pandora/Paradigm/Basis/Product.hs view
@@ -1,4 +1,5 @@-module Pandora.Paradigm.Basis.Product (Product (..), type (:*), delta, swap, attached) where+module Pandora.Paradigm.Basis.Product+	(Product (..), type (:*:), Has, Injective, delta, swap, attached) where  import Pandora.Core.Morphism (($)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>)))@@ -14,55 +15,68 @@ import Pandora.Pattern.Object.Lattice (Lattice) import Pandora.Pattern.Object.Group (Group (inverse)) -infixr 1 :*+infixr 1 :*: -data Product a b = a :* b+data Product a b = a :*: b -type (:*) = Product+type (:*:) = Product  instance Covariant (Product a) where-	f <$> (x :* y) = x :* f y+	f <$> (x :*: y) = x :*: f y  instance Extractable (Product a) where-	extract (x :* y) = y+	extract (_ :*: y) = y  instance Extendable (Product a) where-	(x :* y) =>> f = (:*) x $ f (x :* y)+	(x :*: y) =>> f = (:*:) x $ f (x :*: y)  instance Comonad (Product a) where  instance Adjoint (Product a) ((->) a) where-	phi f x y = f $ y :* x-	psi f (y :* x) = f x y+	phi f x y = f $ y :*: x+	psi f (y :*: x) = f x y  instance (Setoid a, Setoid b) => Setoid (Product a b) where-	(x :* y) == (x' :* y') = x == x' && y == y'+	(x :*: y) == (x' :*: y') = x == x' && y == y'  instance (Semigroup a, Semigroup b) => Semigroup (Product a b) where-	(x :* y) <> (x' :* y') = x <> x' :* y <> y'+	(x :*: y) <> (x' :*: y') = x <> x' :*: y <> y'  instance (Monoid a, Monoid b) => Monoid (Product a b) where-	unit = unit :* unit+	unit = unit :*: unit  instance (Ringoid a, Ringoid b) => Ringoid (Product a b) where-	(x :* y) >< (x' :* y') = x >< x' :* y >< y'+	(x :*: y) >< (x' :*: y') = x >< x' :*: y >< y'  instance (Infimum a, Infimum b) => Infimum (Product a b) where-	(x :* y) /\ (x' :* y') = x /\ x' :* y /\ y'+	(x :*: y) /\ (x' :*: y') = x /\ x' :*: y /\ y'  instance (Supremum a, Supremum b) => Supremum (Product a b) where-	(x :* y) \/ (x' :* y') = x \/ x' :* y \/ y'+	(x :*: y) \/ (x' :*: y') = x \/ x' :*: y \/ y'  instance (Lattice a, Lattice b) => Lattice (Product a b) where  instance (Group a, Group b) => Group (Product a b) where-	inverse (x :* y) = inverse x :* inverse y+	inverse (x :*: y) = inverse x :*: inverse y -delta :: a -> a :* a-delta x = x :* x+delta :: a -> a :*: a+delta x = x :*: x -swap :: a :* b -> b :* a-swap (x :* y) = y :* x+swap :: a :*: b -> b :*: a+swap (x :*: y) = y :*: x -attached :: a :* b -> a-attached (x :* y) = x+attached :: a :*: b -> a+attached (x :*: _) = x++-- Constraint on the content of some type+type family Has x xs where+	Has x (x :*: xs) = ()+	Has x (y :*: xs) = Has x xs+	Has x x = ()++-- All elements of the left product are in the right product+type family Injective xs ys where+	Injective (x :*: xs) ys = (Has x ys, Injective xs ys)+	Injective x (x :*: ys) = ()+	Injective x (y :*: ys) = Has x ys+	Injective x x = ()
+ Pandora/Paradigm/Basis/Variation.hs view
@@ -0,0 +1,26 @@+module Pandora.Paradigm.Basis.Variation (Variation (..), variation) where++import Pandora.Core.Morphism (($))+import Pandora.Pattern.Functor.Covariant (Covariant ((<$>)))+import Pandora.Pattern.Functor.Pointable (Pointable (point))+import Pandora.Pattern.Functor.Traversable (Traversable ((->>)))++data Variation e a = This a | That e | These e a++instance Covariant (Variation e) where+	f <$> This x = This $ f x+	_ <$> That y = That y+	f <$> These y x = These y (f x)++instance Pointable (Variation e) where+	point = This++instance Traversable (Variation e) where+	This x ->> f = This <$> f x+	That y ->> _ = point $ That y+	These y x ->> f = These y <$> f x++variation :: (a -> r) -> (e -> r) -> (e -> a -> r) -> Variation e a -> r+variation f _ _ (This x) = f x+variation _ g _ (That y) = g y+variation _ _ h (These y x) = h y x
Pandora/Paradigm/Basis/Wye.hs view
@@ -9,13 +9,13 @@ data Wye a = End | Left a | Right a | Both a a  instance Covariant Wye where-	f <$> End = End+	_ <$> End = End 	f <$> Left x = Left $ f x 	f <$> Right y = Right $ f y 	f <$> Both x y = Both (f x) (f y)  instance Traversable Wye where-	End ->> f = point End+	End ->> _ = point End 	Left x ->> f = Left <$> f x 	Right y ->> f = Right <$> f y 	Both x y ->> f = Both <$> f x <*> f y
Pandora/Paradigm/Inventory/Optics.hs view
@@ -2,7 +2,7 @@  import Pandora.Core.Morphism ((.), ($)) import Pandora.Paradigm.Basis.Identity (Identity)-import Pandora.Paradigm.Inventory.Storage (Storage (Storage), access, position, retrofit)+import Pandora.Paradigm.Inventory.Storage (Storage, access, position, retrofit) import Pandora.Pattern.Functor.Covariant (Covariant ((<$))) import Pandora.Pattern.Functor.Extractable (Extractable (extract)) 
Pandora/Paradigm/Inventory/Stateful.hs view
@@ -1,19 +1,23 @@-module Pandora.Paradigm.Inventory.Stateful (Stateful (..), State, get, modify, put, fold) where+module Pandora.Paradigm.Inventory.Stateful (Stateful (..), State, get, modify, put, fold, find) where  import Pandora.Core.Functor (type (:.:)) import Pandora.Core.Morphism ((.), ($)) import Pandora.Paradigm.Basis.Identity (Identity)-import Pandora.Paradigm.Basis.Product (Product ((:*)), type (:*), delta)+import Pandora.Paradigm.Basis.Predicate (Predicate (predicate))+import Pandora.Paradigm.Basis.Product (Product ((:*:)), type (:*:), delta) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>), ($>), comap)) import Pandora.Pattern.Functor.Extractable (Extractable (extract))+import Pandora.Pattern.Functor.Exclusive (Exclusive (exclusive)) import Pandora.Pattern.Functor.Pointable (Pointable (point)) import Pandora.Pattern.Functor.Applicative (Applicative ((<*>), (*>)))+import Pandora.Pattern.Functor.Alternative (Alternative ((<+>))) import Pandora.Pattern.Functor.Traversable (Traversable ((->>))) import Pandora.Pattern.Functor.Bindable (Bindable ((>>=))) import Pandora.Pattern.Functor.Monad (Monad) import Pandora.Pattern.Functor.Liftable (Liftable (lift))+import Pandora.Pattern.Object.Setoid (bool) -newtype Stateful s t a = Stateful { statefully :: ((->) s :.: t :.: (:*) s) a }+newtype Stateful s t a = Stateful { statefully :: ((->) s :.: t :.: (:*:) s) a }  type State s = Stateful s Identity @@ -22,29 +26,32 @@  instance Bindable t => Applicative (Stateful s t) where 	Stateful f <*> Stateful x = Stateful $ \old ->-		f old >>= \(new :* g) -> comap g <$> x new+		f old >>= \(new :*: g) -> comap g <$> x new  instance Pointable t => Pointable (Stateful s t) where-	point x = Stateful $ \s -> point $ s :* x+	point x = Stateful $ \s -> point $ s :*: x  instance Bindable t => Bindable (Stateful s t) where 	Stateful x >>= f = Stateful $ \old ->-		x old >>= \(new :* y) -> statefully (f y) new+		x old >>= \(new :*: y) -> statefully (f y) new  instance Monad t => Monad (Stateful s t) where  instance Liftable (Stateful s) where-	lift x = Stateful $ \s -> ((:*) s) <$> x+	lift x = Stateful $ \s -> ((:*:) s) <$> x  get :: Pointable t => Stateful s t s get = Stateful $ point . delta  modify :: Pointable t => (s -> s) -> Stateful s t ()-modify f = Stateful $ \s -> point $ f s :* ()+modify f = Stateful $ \s -> point $ f s :*: ()  put :: Pointable t => s -> Stateful s t ()-put s = Stateful $ \_ -> point $ s :* ()+put s = Stateful $ \_ -> point $ s :*: ()  fold :: Traversable t => s -> (a -> s -> s) -> t a -> s fold start op struct = extract . extract @Identity $ 	statefully (struct ->> (modify . op) $> () *> get) start++find :: (Pointable u, Exclusive u, Alternative u, Traversable t) => Predicate a -> t a -> u a+find p struct = fold exclusive (\x s -> (<+>) s . bool exclusive (point x) . predicate p $ x) struct
Pandora/Paradigm/Inventory/Storage.hs view
@@ -3,38 +3,38 @@ import Pandora.Core.Functor (type (:.:)) import Pandora.Core.Morphism ((.), ($), (?)) import Pandora.Paradigm.Basis.Identity (Identity)-import Pandora.Paradigm.Basis.Product (Product ((:*)), type (:*))-import Pandora.Pattern.Functor.Covariant (Covariant ((<$>), comap))+import Pandora.Paradigm.Basis.Product (Product ((:*:)), type (:*:))+import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Extractable (Extractable (extract)) import Pandora.Pattern.Functor.Extendable (Extendable ((=>>))) import Pandora.Pattern.Functor.Applicative (Applicative ((<*>))) import Pandora.Pattern.Functor.Comonad (Comonad) -newtype Storage p t a = Storage { stored :: ((:*) p :.: t :.: (->) p) a }+newtype Storage p t a = Storage { stored :: ((:*:) p :.: t :.: (->) p) a }  instance Covariant t => Covariant (Storage p t) where-	f <$> Storage (p :* x) = Storage . (:*) p $ (f .) <$> x+	f <$> Storage (p :*: x) = Storage . (:*:) p $ (f .) <$> x  instance Extractable t => Extractable (Storage p t) where-	extract (Storage (p :* x)) = extract x p+	extract (Storage (p :*: x)) = extract x p  instance Extendable t => Extendable (Storage p t) where-	Storage (old :* x) =>> f = Storage . (:*) old . (=>>) x $-		\y -> \new -> f . Storage $ new :* y+	Storage (old :*: x) =>> f = Storage . (:*:) old . (=>>) x $+		\y -> \new -> f . Storage $ new :*: y  instance Applicative t => Applicative (Storage p t) where-	Storage (p :* x) <*> Storage (q :* y) = Storage . (:*) q $-		(\f g x -> f x (g x)) <$> x <*> y+	Storage (_ :*: x) <*> Storage (q :*: y) = Storage . (:*:) q $+		(\f g x' -> f x' (g x')) <$> x <*> y  instance Comonad g => Comonad (Storage p g) where  type Store p = Storage p Identity  position :: Storage p t a -> p-position (Storage (p :* _)) = p+position (Storage (p :*: _)) = p  access :: Extractable t => p -> Storage p t a -> a access p = extract ? p . extract . stored  retrofit :: Extractable t => (p -> p) -> Storage p t a -> Storage p t a-retrofit f (Storage (p :* x)) = Storage $ (f p) :* x+retrofit f (Storage (p :*: x)) = Storage $ (f p) :*: x
Pandora/Paradigm/Junction/Transformer.hs view
@@ -10,7 +10,6 @@ import Pandora.Pattern.Functor.Applicative (Applicative ((<*>), apply)) import Pandora.Pattern.Functor.Traversable (Traversable ((->>), traverse)) import Pandora.Pattern.Functor.Distributive (Distributive ((>>-), distribute))-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 ((==)))
Pandora/Paradigm/Structure/Binary.hs view
@@ -3,7 +3,6 @@ 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
Pandora/Paradigm/Structure/Graph.hs view
@@ -1,7 +1,7 @@ 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.Edges (Edges (Empty, Overlay)) import Pandora.Paradigm.Basis.Cofree (Cofree ((:<))) import Pandora.Paradigm.Junction.Transformer (Y (Y), type (:>:)) import Pandora.Paradigm.Inventory.Stateful (fold)
Pandora/Paradigm/Structure/Stack.hs view
@@ -1,9 +1,10 @@-module Pandora.Paradigm.Structure.Stack (Stack, push, top, pop, linearize) where+module Pandora.Paradigm.Structure.Stack (Stack, push, top, pop, filter, 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.Basis.Predicate (Predicate (Predicate))+import Pandora.Paradigm.Junction.Transformer (Y (Y), type (:>:)) import Pandora.Paradigm.Inventory.Stateful (fold) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Pointable (Pointable (point))@@ -11,6 +12,7 @@ import Pandora.Pattern.Functor.Alternative (Alternative ((<+>))) import Pandora.Pattern.Functor.Traversable (Traversable) import Pandora.Pattern.Functor.Bindable (Bindable ((>>=)))+import Pandora.Pattern.Object.Setoid (bool)  -- | Linear data structure that serves as a collection of elements type Stack = (Cofree :>: Maybe)@@ -23,6 +25,10 @@  pop :: Stack a -> Stack a pop (Y struct) = Y $ struct >>= unwrap++filter :: Predicate a -> Stack a -> Stack a+filter (Predicate p) = Y . fold Nothing+	(\x s -> bool s (Just $ x :< s) $ p x)  -- | Transform any traversable structure into a stack linearize :: Traversable t => t a -> Stack a
Pandora/Pattern/Functor/Contravariant.hs view
@@ -27,3 +27,6 @@ 	-- | Fill the input of evaluation 	full :: t () -> t a 	full x = () >$ x+	-- | Infix versions of `contramap` with various nesting levels+	(>$$$<) :: (Contravariant u, Contravariant v) => (a -> b) -> t (u (v b)) -> t (u (v a))+	(>$$$<) = (>$<) . (>$<) . (>$<)
Pandora/Pattern/Functor/Covariant.hs view
@@ -1,6 +1,6 @@ module Pandora.Pattern.Functor.Covariant (Covariant (..)) where -import Pandora.Core.Morphism ((.), (!), (?))+import Pandora.Core.Morphism (fix, (.), ($), (!), (?))  infixl 4 <$>, <$, $> @@ -27,6 +27,16 @@ 	-- | Discards the result of evaluation 	void :: t a -> t () 	void x = () <$ x+	-- | Computing a value from a structure of values+	loeb :: t (t a -> a) -> t a+	loeb tt = fix $ \f -> ($ f) <$> tt+	-- | Infix versions of `comap` with various nesting levels+	(<$$>) :: Covariant u => (a -> b) -> t (u a) -> t (u b)+	(<$$>) = (<$>) . (<$>)+	(<$$$>) :: (Covariant u, Covariant v) => (a -> b) -> t (u (v a)) -> t (u (v b))+	(<$$$>) = (<$>) . (<$>) . (<$>)+	(<$$$$>) :: (Covariant u, Covariant v, Covariant w) => (a -> b) -> t (u (v ( w a))) -> t (u (v (w b)))+	(<$$$$>) = (<$>) . (<$>) . (<$>) . (<$>)  instance Covariant ((->) a) where 	(<$>) = (.)
Pandora/Pattern/Object/Lattice.hs view
@@ -1,4 +1,4 @@-module Pandora.Pattern.Object.Lattice (Lattice (..)) where+module Pandora.Pattern.Object.Lattice (Lattice) where  import Pandora.Pattern.Object.Semilattice (Infimum, Supremum) 
README.md view
@@ -5,6 +5,7 @@ Used materials:  * Paper: `Fast Coroutine Pipelines`+* Paper: `Getting a Quick Fix on Comonads` * Twit: https://twitter.com/xgrommx/status/964307440517963776 * Library: http://hackage.haskell.org/package/base * Library: http://hackage.haskell.org/package/adjunctions
pandora.cabal view
@@ -1,5 +1,5 @@ name:                pandora-version:             0.1.3+version:             0.1.4 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@@ -34,9 +34,11 @@     Pandora.Paradigm.Basis.Free     Pandora.Paradigm.Basis.Identity     Pandora.Paradigm.Basis.Jack+    Pandora.Paradigm.Basis.Jet     Pandora.Paradigm.Basis.Maybe     Pandora.Paradigm.Basis.Predicate     Pandora.Paradigm.Basis.Product+    Pandora.Paradigm.Basis.Variation     Pandora.Paradigm.Basis.Wye     Pandora.Paradigm.Basis.Yoneda     -- Universal functors constructions@@ -92,6 +94,6 @@     DataKinds, ConstraintKinds, ExistentialQuantification, QuantifiedConstraints     FlexibleContexts, FlexibleInstances, KindSignatures, LiberalTypeSynonyms     MultiParamTypeClasses, NoImplicitPrelude, PackageImports, PolyKinds, RankNTypes-    ScopedTypeVariables, TypeApplications, TypeFamilies, TypeOperators+    ScopedTypeVariables, TypeApplications, TypeFamilies, TypeFamilyDependencies, TypeOperators   default-language: Haskell2010-  ghc-options: -fno-warn-tabs+  ghc-options: -Wall -fno-warn-tabs