packages feed

pandora 0.1.6 → 0.1.7

raw patch · 18 files changed

+151/−119 lines, 18 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Pandora.Paradigm.Inventory.Environmental: [environmentally] :: Environmental e t a -> ((->) e :.: t) a
- Pandora.Paradigm.Inventory.Environmental: ask :: Pointable t => Environmental e t e
- Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Alternative.Alternative t => Pandora.Pattern.Functor.Alternative.Alternative (Pandora.Paradigm.Inventory.Environmental.Environmental e t)
- Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Applicative.Applicative t => Pandora.Pattern.Functor.Applicative.Applicative (Pandora.Paradigm.Inventory.Environmental.Environmental e t)
- Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Bindable.Bindable t => Pandora.Pattern.Functor.Bindable.Bindable (Pandora.Paradigm.Inventory.Environmental.Environmental e t)
- Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Covariant.Covariant t => Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Inventory.Environmental.Environmental e t)
- Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Liftable.Liftable (Pandora.Paradigm.Inventory.Environmental.Environmental e)
- Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Monad.Monad t => Pandora.Pattern.Functor.Monad.Monad (Pandora.Paradigm.Inventory.Environmental.Environmental e t)
- Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Pointable.Pointable t => Pandora.Pattern.Functor.Pointable.Pointable (Pandora.Paradigm.Inventory.Environmental.Environmental e t)
- Pandora.Paradigm.Inventory.Environmental: type Environ e = Environmental e Identity
- Pandora.Paradigm.Inventory.Stateful: [statefully] :: Stateful s t a -> ((->) s :.: (t :.: (:*:) s)) a
- Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Bindable.Bindable t => Pandora.Pattern.Functor.Applicative.Applicative (Pandora.Paradigm.Inventory.Stateful.Stateful s t)
- Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Bindable.Bindable t => Pandora.Pattern.Functor.Bindable.Bindable (Pandora.Paradigm.Inventory.Stateful.Stateful s t)
- Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Covariant.Covariant t => Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Inventory.Stateful.Stateful s t)
- Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Liftable.Liftable (Pandora.Paradigm.Inventory.Stateful.Stateful s)
- Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Monad.Monad t => Pandora.Pattern.Functor.Monad.Monad (Pandora.Paradigm.Inventory.Stateful.Stateful s t)
- Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Pointable.Pointable t => Pandora.Pattern.Functor.Pointable.Pointable (Pandora.Paradigm.Inventory.Stateful.Stateful s t)
- Pandora.Paradigm.Inventory.Stateful: type State s = Stateful s Identity
- Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Applicative.Applicative t => Pandora.Pattern.Functor.Applicative.Applicative (Pandora.Paradigm.Inventory.Storage.Storage p t)
- Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Comonad.Comonad g => Pandora.Pattern.Functor.Comonad.Comonad (Pandora.Paradigm.Inventory.Storage.Storage p g)
- Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Covariant.Covariant t => Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Inventory.Storage.Storage p t)
- Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Extendable.Extendable t => Pandora.Pattern.Functor.Extendable.Extendable (Pandora.Paradigm.Inventory.Storage.Storage p t)
- Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Extractable.Extractable t => Pandora.Pattern.Functor.Extractable.Extractable (Pandora.Paradigm.Inventory.Storage.Storage p t)
- Pandora.Paradigm.Inventory.Storage: type Store p = Storage p Identity
- Pandora.Paradigm.Structure.Stack: filter :: Predicate a -> Stack a -> Stack a
+ Pandora.Core.Functor: infixr 1 :.:
+ Pandora.Paradigm.Basis.Predicate: instance Pandora.Pattern.Functor.Determinable.Determinable Pandora.Paradigm.Basis.Predicate.Predicate
+ Pandora.Paradigm.Basis.Product: curry :: ((a :*: b) -> c) -> a -> b -> c
+ Pandora.Paradigm.Basis.Product: uncurry :: (a -> b -> c) -> (a :*: b) -> c
+ Pandora.Paradigm.Inventory.Environmental: env :: Environmental e e
+ Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Applicative.Applicative (Pandora.Paradigm.Inventory.Environmental.Environmental e)
+ Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Bindable.Bindable (Pandora.Paradigm.Inventory.Environmental.Environmental e)
+ Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Inventory.Environmental.Environmental e)
+ Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Monad.Monad (Pandora.Paradigm.Inventory.Environmental.Environmental e)
+ Pandora.Paradigm.Inventory.Environmental: instance Pandora.Pattern.Functor.Pointable.Pointable (Pandora.Paradigm.Inventory.Environmental.Environmental e)
+ Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Applicative.Applicative (Pandora.Paradigm.Inventory.Stateful.Stateful s)
+ Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Bindable.Bindable (Pandora.Paradigm.Inventory.Stateful.Stateful s)
+ Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Inventory.Stateful.Stateful s)
+ Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Monad.Monad (Pandora.Paradigm.Inventory.Stateful.Stateful s)
+ Pandora.Paradigm.Inventory.Stateful: instance Pandora.Pattern.Functor.Pointable.Pointable (Pandora.Paradigm.Inventory.Stateful.Stateful s)
+ Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Comonad.Comonad (Pandora.Paradigm.Inventory.Storage.Storage p)
+ Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Covariant.Covariant (Pandora.Paradigm.Inventory.Storage.Storage p)
+ Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Extendable.Extendable (Pandora.Paradigm.Inventory.Storage.Storage p)
+ Pandora.Paradigm.Inventory.Storage: instance Pandora.Pattern.Functor.Extractable.Extractable (Pandora.Paradigm.Inventory.Storage.Storage p)
+ Pandora.Pattern.Functor.Applicative: (<****>) :: (Applicative t, Applicative u, Applicative v, Applicative w) => (t :.: (u :.: (v :.: w))) (a -> b) -> (t :.: (u :.: (v :.: w))) a -> (t :.: (u :.: (v :.: w))) b
+ Pandora.Pattern.Functor.Applicative: (<***>) :: (Applicative t, Applicative u, Applicative v) => (t :.: (u :.: v)) (a -> b) -> (t :.: (u :.: v)) a -> (t :.: (u :.: v)) b
+ Pandora.Pattern.Functor.Applicative: (<**>) :: (Applicative t, Applicative u) => (t :.: u) (a -> b) -> (t :.: u) a -> (t :.: u) b
+ Pandora.Pattern.Functor.Determinable: class Contravariant t => Determinable t
+ Pandora.Pattern.Functor.Determinable: determine :: Determinable t => t a
+ Pandora.Pattern.Object.Setoid: ifelse :: a -> a -> Boolean -> a
- Pandora.Core.Functor: infixr 0 :.:
+ Pandora.Core.Functor: infixr 0 ><
- Pandora.Core.Functor: type (:.:) t u a = t (u a)
+ Pandora.Core.Functor: type (><) t a = t a
- Pandora.Paradigm.Inventory.Environmental: Environmental :: ((->) e :.: t) a -> Environmental e t a
+ Pandora.Paradigm.Inventory.Environmental: Environmental :: (e -> a) -> Environmental e a
- Pandora.Paradigm.Inventory.Environmental: local :: (e -> e) -> Environmental e t a -> Environmental e t a
+ Pandora.Paradigm.Inventory.Environmental: local :: (e -> e) -> Environmental e a -> Environmental e a
- Pandora.Paradigm.Inventory.Environmental: newtype Environmental e t a
+ Pandora.Paradigm.Inventory.Environmental: newtype Environmental e a
- Pandora.Paradigm.Inventory.Optics: type Lens src tgt = src -> Storage tgt Identity src
+ Pandora.Paradigm.Inventory.Optics: type Lens src tgt = src -> Storage tgt src
- Pandora.Paradigm.Inventory.Stateful: Stateful :: ((->) s :.: (t :.: (:*:) s)) a -> Stateful s t a
+ Pandora.Paradigm.Inventory.Stateful: Stateful :: (((->) s :.: (:*:) s) >< a) -> Stateful s a
- Pandora.Paradigm.Inventory.Stateful: get :: Pointable t => Stateful s t s
+ Pandora.Paradigm.Inventory.Stateful: get :: Stateful s s
- Pandora.Paradigm.Inventory.Stateful: modify :: Pointable t => (s -> s) -> Stateful s t ()
+ Pandora.Paradigm.Inventory.Stateful: modify :: (s -> s) -> Stateful s ()
- Pandora.Paradigm.Inventory.Stateful: newtype Stateful s t a
+ Pandora.Paradigm.Inventory.Stateful: newtype Stateful s a
- Pandora.Paradigm.Inventory.Stateful: put :: Pointable t => s -> Stateful s t ()
+ Pandora.Paradigm.Inventory.Stateful: put :: s -> Stateful s ()
- Pandora.Paradigm.Inventory.Storage: Storage :: ((:*:) p :.: (t :.: (->) p)) a -> Storage p t a
+ Pandora.Paradigm.Inventory.Storage: Storage :: (((:*:) p :.: (->) p) >< a) -> Storage p a
- Pandora.Paradigm.Inventory.Storage: [stored] :: Storage p t a -> ((:*:) p :.: (t :.: (->) p)) a
+ Pandora.Paradigm.Inventory.Storage: [stored] :: Storage p a -> ((:*:) p :.: (->) p) >< a
- Pandora.Paradigm.Inventory.Storage: access :: Extractable t => p -> Storage p t a -> a
+ Pandora.Paradigm.Inventory.Storage: access :: p -> Storage p a -> a
- Pandora.Paradigm.Inventory.Storage: newtype Storage p t a
+ Pandora.Paradigm.Inventory.Storage: newtype Storage p a
- Pandora.Paradigm.Inventory.Storage: position :: Storage p t a -> p
+ Pandora.Paradigm.Inventory.Storage: position :: Storage p a -> p
- Pandora.Paradigm.Inventory.Storage: retrofit :: Extractable t => (p -> p) -> Storage p t a -> Storage p t a
+ Pandora.Paradigm.Inventory.Storage: retrofit :: (p -> p) -> Storage p a -> Storage p a
- Pandora.Paradigm.Structure: type family Nonempty structure a :: *
+ Pandora.Paradigm.Structure: type family Nonempty structure :: *
- Pandora.Paradigm.Structure.Graph: type Graph a = (Twister :>: Edges) a
+ Pandora.Paradigm.Structure.Graph: type Graph a = (Edges :.: Twister Edges) a
- Pandora.Paradigm.Structure.Stack: type Stack = (Twister :>: Maybe)
+ Pandora.Paradigm.Structure.Stack: type Stack a = (Maybe :.: Twister Maybe) a
- Pandora.Pattern.Functor.Contravariant: (>$$$$<) :: (Contravariant t, Contravariant u, Contravariant v, Contravariant w) => (a -> b) -> (t :.: (u :.: (v :.: w))) a -> (t :.: (u :.: (v :.: w))) b
+ Pandora.Pattern.Functor.Contravariant: (>$$$$<) :: (Contravariant t, Contravariant u, Contravariant v, Contravariant w) => (a -> b) -> ((t :.: (u :.: (v :.: w))) >< a) -> (t :.: (u :.: (v :.: w))) >< b
- Pandora.Pattern.Functor.Contravariant: (>$$$<) :: (Contravariant t, Contravariant u, Contravariant v) => (a -> b) -> (t :.: (u :.: v)) b -> (t :.: (u :.: v)) a
+ Pandora.Pattern.Functor.Contravariant: (>$$$<) :: (Contravariant t, Contravariant u, Contravariant v) => (a -> b) -> ((t :.: (u :.: v)) >< b) -> (t :.: (u :.: v)) >< a
- Pandora.Pattern.Functor.Contravariant: (>$$<) :: (Contravariant t, Contravariant u) => (a -> b) -> (t :.: u) a -> (t :.: u) b
+ Pandora.Pattern.Functor.Contravariant: (>$$<) :: (Contravariant t, Contravariant u) => (a -> b) -> ((t :.: u) >< a) -> (t :.: u) >< b
- Pandora.Pattern.Functor.Contravariant: (>&&&&<) :: (Contravariant t, Contravariant u, Contravariant v, Contravariant w) => (t :.: (u :.: (v :.: w))) a -> (a -> b) -> (t :.: (u :.: (v :.: w))) b
+ Pandora.Pattern.Functor.Contravariant: (>&&&&<) :: (Contravariant t, Contravariant u, Contravariant v, Contravariant w) => ((t :.: (u :.: (v :.: w))) >< a) -> (a -> b) -> (t :.: (u :.: (v :.: w))) >< b
- Pandora.Pattern.Functor.Contravariant: (>&&&<) :: (Contravariant t, Contravariant u, Contravariant v) => (t :.: (u :.: v)) b -> (a -> b) -> (t :.: (u :.: v)) a
+ Pandora.Pattern.Functor.Contravariant: (>&&&<) :: (Contravariant t, Contravariant u, Contravariant v) => ((t :.: (u :.: v)) >< b) -> (a -> b) -> (t :.: (u :.: v)) >< a
- Pandora.Pattern.Functor.Contravariant: (>&&<) :: (Contravariant t, Contravariant u) => (t :.: u) a -> (a -> b) -> (t :.: u) b
+ Pandora.Pattern.Functor.Contravariant: (>&&<) :: (Contravariant t, Contravariant u) => ((t :.: u) >< a) -> (a -> b) -> (t :.: u) >< b
- 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, 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, 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: (<$$>) :: (Covariant t, Covariant u) => (a -> b) -> ((t :.: u) >< a) -> (t :.: u) >< b
- Pandora.Pattern.Functor.Covariant: (<&&&&>) :: (Covariant t, Covariant u, Covariant v, Covariant w) => (t :.: (u :.: (v :.: w))) a -> (a -> b) -> (t :.: (u :.: (v :.: w))) b
+ Pandora.Pattern.Functor.Covariant: (<&&&&>) :: (Covariant t, Covariant u, Covariant v, Covariant w) => ((t :.: (u :.: (v :.: w))) >< a) -> (a -> b) -> (t :.: (u :.: (v :.: w))) >< b
- Pandora.Pattern.Functor.Covariant: (<&&&>) :: (Covariant t, Covariant u, Covariant v) => (t :.: (u :.: v)) a -> (a -> b) -> (t :.: (u :.: v)) b
+ Pandora.Pattern.Functor.Covariant: (<&&&>) :: (Covariant t, Covariant u, Covariant v) => ((t :.: (u :.: v)) >< a) -> (a -> b) -> (t :.: (u :.: v)) >< b
- Pandora.Pattern.Functor.Covariant: (<&&>) :: (Covariant t, Covariant u) => (t :.: u) a -> (a -> b) -> (t :.: u) b
+ Pandora.Pattern.Functor.Covariant: (<&&>) :: (Covariant t, Covariant u) => ((t :.: u) >< a) -> (a -> b) -> (t :.: u) >< b

Files

CHANGELOG.md view
@@ -59,3 +59,15 @@ * Rename `><` method of `Ringoid` typeclass to `*` * Rename `unit` to `zero` method of `Monoid` typeclass * Define `Quasiring` typeclass++# 0.1.7+* Define `ifelse` function for `Boolean` values+* Change `Stack` and `Nonempty` definitions, temporarily remove `filter`+* Define `<**>`, `<***>`, `<****>` methods for `Applicative` to compact expressions+* Change `Graph` definition+* Rename `ask` to `env` method of `Environmental` datatype+* Introduce `><` type operator to separate functors from its arguments+* Define `Determinable` typeclass and define its instance for `Predicate`+* Define `curry` and `uncurry` for `Product` datatype+* Flip arguments of `statefully` method of `Stateful` datatype+* Exclude inner effects from `Environmental`, `Storage` and `Stateful` datatypes
Pandora/Core/Functor.hs view
@@ -1,6 +1,9 @@-module Pandora.Core.Functor (Variant (..), type (:.:)) where+module Pandora.Core.Functor (Variant (..), type (:.:), type (><)) where  data Variant = Co | Contra -infixr 0 :.:+infixr 1 :.: type (:.:) t u a = t (u a)++infixr 0 ><+type (><) t a = t a
Pandora/Paradigm/Basis/Predicate.hs view
@@ -1,10 +1,14 @@ module Pandora.Paradigm.Basis.Predicate (Predicate (..)) where -import Pandora.Core.Morphism ((.), ($))+import Pandora.Core.Morphism ((.), ($), (!)) import Pandora.Pattern.Functor.Contravariant (Contravariant ((>$<)))-import Pandora.Pattern.Object.Setoid (Boolean)+import Pandora.Pattern.Functor.Determinable (Determinable (determine))+import Pandora.Pattern.Object.Setoid (Boolean (True))  newtype Predicate a = Predicate { predicate :: a -> Boolean }  instance Contravariant Predicate where 	f >$< g = Predicate $ predicate g . f++instance Determinable Predicate where+	determine = Predicate (True !)
Pandora/Paradigm/Basis/Product.hs view
@@ -1,5 +1,5 @@-module Pandora.Paradigm.Basis.Product-	(Product (..), type (:*:), Has, Injective, delta, swap, attached) where+module Pandora.Paradigm.Basis.Product (Product (..), type (:*:), Has, Injective+	, delta, swap, attached, curry, uncurry) where  import Pandora.Core.Morphism (($)) import Pandora.Pattern.Functor.Covariant (Covariant ((<$>)))@@ -71,6 +71,12 @@  attached :: a :*: b -> a attached (x :*: _) = x++curry :: (a :*: b -> c) -> a -> b -> c+curry f x y = f $ x :*: y++uncurry :: (a -> b -> c) -> (a :*: b -> c)+uncurry f (x :*: y) = f x y  -- Constraint on the content of some type type family Has x xs where
Pandora/Paradigm/Inventory/Environmental.hs view
@@ -1,42 +1,33 @@-module Pandora.Paradigm.Inventory.Environmental (Environmental (..), Environ, ask, local) where+module Pandora.Paradigm.Inventory.Environmental (Environmental (..), env, local) where -import Pandora.Core.Functor (type (:.:))-import Pandora.Core.Morphism ((.), ($), (!), (?))-import Pandora.Paradigm.Basis.Identity (Identity)-import Pandora.Pattern.Functor.Covariant (Covariant ((<$>), comap))+import Pandora.Core.Morphism (identity, (.), ($), (!))+import Pandora.Pattern.Functor.Covariant (Covariant ((<$>))) import Pandora.Pattern.Functor.Pointable (Pointable (point))-import Pandora.Pattern.Functor.Alternative (Alternative ((<+>))) import Pandora.Pattern.Functor.Applicative (Applicative ((<*>))) import Pandora.Pattern.Functor.Bindable (Bindable ((>>=))) import Pandora.Pattern.Functor.Monad (Monad)-import Pandora.Pattern.Functor.Liftable (Liftable (lift)) -newtype Environmental e t a = Environmental { environmentally :: ((->) e :.: t) a }--type Environ e = Environmental e Identity--instance Covariant t => Covariant (Environmental e t) where-	f <$> Environmental x = Environmental $ comap f . x+newtype Environmental e a = Environmental (e -> a) -instance Pointable t => Pointable (Environmental e t) where-	point x = Environmental $ (!) (point x)+environmentally :: e -> Environmental e a -> a+environmentally e (Environmental f) = f e -instance Applicative t => Applicative (Environmental e t) where-	f <*> x = Environmental $ \e -> environmentally f e <*> environmentally x e+instance Covariant (Environmental e) where+	f <$> Environmental x = Environmental $ f . x -instance Alternative t => Alternative (Environmental e t) where-	x <+> y = Environmental $ \e -> environmentally x e <+> environmentally y e+instance Pointable (Environmental e) where+	point x = Environmental $ (x !) -instance Bindable t => Bindable (Environmental e t) where-	Environmental x >>= f = Environmental $ \e -> x e >>= environmentally ? e . f+instance Applicative (Environmental e) where+	f <*> x = Environmental $ \e -> environmentally e f $ environmentally e x -instance Monad t => Monad (Environmental e t) where+instance Bindable (Environmental e) where+	Environmental x >>= f = Environmental $ \e -> environmentally e . f . x $ e -instance Liftable (Environmental e) where-	lift = Environmental . (!)+instance Monad (Environmental e) where -ask :: Pointable t => Environmental e t e-ask = Environmental point+env :: Environmental e e+env = Environmental identity -local :: (e -> e) -> Environmental e t a -> Environmental e t a+local :: (e -> e) -> Environmental e a -> Environmental e a local f (Environmental x) = Environmental $ x . f
Pandora/Paradigm/Inventory/Optics.hs view
@@ -1,7 +1,7 @@-module Pandora.Paradigm.Inventory.Optics (Lens, type (:-.), (|>), view, set, over, (^.), (.~), (%~)) where+module Pandora.Paradigm.Inventory.Optics+	(Lens, type (:-.), (|>), view, set, over, (^.), (.~), (%~)) where  import Pandora.Core.Morphism ((.), ($))-import Pandora.Paradigm.Basis.Identity (Identity) import Pandora.Paradigm.Inventory.Storage (Storage, access, position, retrofit) import Pandora.Pattern.Functor.Covariant (Covariant ((<$))) import Pandora.Pattern.Functor.Extractable (Extractable (extract))@@ -9,7 +9,7 @@ infixr 0 :-. type (:-.) src tgt = Lens src tgt -type Lens src tgt = src -> Storage tgt Identity src+type Lens src tgt = src -> Storage tgt src  -- | Lens composition infix operator (|>) :: Lens src btw -> Lens btw tgt -> Lens src tgt
Pandora/Paradigm/Inventory/Stateful.hs view
@@ -1,11 +1,12 @@-module Pandora.Paradigm.Inventory.Stateful (Stateful (..), State, get, modify, put, fold, find) where+module Pandora.Paradigm.Inventory.Stateful+	(Stateful (..), get, modify, put, fold, find) where -import Pandora.Core.Functor (type (:.:))+import Pandora.Core.Functor (type (:.:), type (><)) import Pandora.Core.Morphism ((.), ($)) import Pandora.Paradigm.Basis.Identity (Identity) import Pandora.Paradigm.Basis.Predicate (Predicate (predicate))-import Pandora.Paradigm.Basis.Product (Product ((:*:)), type (:*:), delta)-import Pandora.Pattern.Functor.Covariant (Covariant ((<$>), ($>), comap))+import Pandora.Paradigm.Basis.Product (Product ((:*:)), type (:*:), attached, delta, uncurry)+import Pandora.Pattern.Functor.Covariant (Covariant ((<$>), ($>), (<$$>))) import Pandora.Pattern.Functor.Extractable (Extractable (extract)) import Pandora.Pattern.Functor.Avoidable (Avoidable (idle)) import Pandora.Pattern.Functor.Pointable (Pointable (point))@@ -17,41 +18,40 @@ 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 a = Stateful ((->) s :.: (:*:) s >< a) -type State s = Stateful s Identity+statefully :: s -> Stateful s a -> (s :*: a)+statefully initial (Stateful state) = state initial -instance Covariant t => Covariant (Stateful s t) where-	f <$> Stateful x = Stateful $ \old -> (comap . comap) f $ x old+instance Covariant (Stateful s) where+	f <$> Stateful x = Stateful $ \old -> f <$> x old -instance Bindable t => Applicative (Stateful s t) where+instance Applicative (Stateful s) where 	Stateful f <*> Stateful x = Stateful $ \old ->-		f old >>= \(new :*: g) -> comap g <$> x new+		let latest = attached . x $ old in+			latest :*: (extract (f old) . extract . x $ old) -instance Pointable t => Pointable (Stateful s t) where-	point x = Stateful $ \s -> point $ s :*: x+instance Pointable (Stateful s) where+	point x = Stateful $ \s -> s :*: x -instance Bindable t => Bindable (Stateful s t) where+instance Bindable (Stateful s) where 	Stateful x >>= f = Stateful $ \old ->-		x old >>= \(new :*: y) -> statefully (f y) new--instance Monad t => Monad (Stateful s t) where+		uncurry statefully $ f <$> x old -instance Liftable (Stateful s) where-	lift x = Stateful $ \s -> ((:*:) s) <$> x+instance Monad (Stateful s) where -get :: Pointable t => Stateful s t s-get = Stateful $ point . delta+get :: Stateful s s+get = Stateful delta -modify :: Pointable t => (s -> s) -> Stateful s t ()-modify f = Stateful $ \s -> point $ f s :*: ()+modify :: (s -> s) -> Stateful s ()+modify f = Stateful $ \s -> f s :*: () -put :: Pointable t => s -> Stateful s t ()-put s = Stateful $ \_ -> point $ s :*: ()+put :: s -> Stateful s ()+put s = Stateful $ \_ -> s :*: ()  fold :: Traversable t => s -> (a -> s -> s) -> t a -> s-fold start op struct = extract . extract @Identity $-	statefully (struct ->> (modify . op) $> () *> get) start+fold start op struct = extract . statefully start $+	struct ->> modify . op $> () *> get  find :: (Pointable u, Avoidable u, Alternative u, Traversable t) => Predicate a -> t a -> u a find p struct = fold idle (\x s -> (<+>) s . bool idle (point x) . predicate p $ x) struct
Pandora/Paradigm/Inventory/Storage.hs view
@@ -1,6 +1,6 @@-module Pandora.Paradigm.Inventory.Storage (Storage (..), Store, position, access, retrofit) where+module Pandora.Paradigm.Inventory.Storage (Storage (..), position, access, retrofit) where -import Pandora.Core.Functor (type (:.:))+import Pandora.Core.Functor (type (:.:), type (><)) import Pandora.Core.Morphism ((.), ($), (?)) import Pandora.Paradigm.Basis.Identity (Identity) import Pandora.Paradigm.Basis.Product (Product ((:*:)), type (:*:))@@ -10,31 +10,25 @@ import Pandora.Pattern.Functor.Applicative (Applicative ((<*>))) import Pandora.Pattern.Functor.Comonad (Comonad) -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--instance Extractable t => Extractable (Storage p t) where-	extract (Storage (p :*: x)) = extract x p+newtype Storage p a = Storage { stored :: (:*:) p :.: (->) p >< a } -instance Extendable t => Extendable (Storage p t) where-	Storage (old :*: x) =>> f = Storage . (:*:) old . (=>>) x $-		\y -> \new -> f . Storage $ new :*: y+instance Covariant (Storage p) where+	g <$> Storage (p :*: f) = Storage . (:*:) p $ (g .) f -instance Applicative t => Applicative (Storage p t) where-	Storage (_ :*: x) <*> Storage (q :*: y) = Storage . (:*:) q $-		(\f g x' -> f x' (g x')) <$> x <*> y+instance Extractable (Storage p) where+	extract (Storage (p :*: x)) = x p -instance Comonad g => Comonad (Storage p g) where+instance Extendable (Storage p) where+	Storage (old :*: f) =>> g = Storage . (:*:) old+		$ \new -> g . Storage $ new :*: f -type Store p = Storage p Identity+instance Comonad (Storage p) where -position :: Storage p t a -> p+position :: Storage p a -> p position (Storage (p :*: _)) = p -access :: Extractable t => p -> Storage p t a -> a-access p = extract ? p . extract . stored+access :: p -> Storage p a -> a+access p = extract ? p . stored -retrofit :: Extractable t => (p -> p) -> Storage p t a -> Storage p t a-retrofit f (Storage (p :*: x)) = Storage $ (f p) :*: x+retrofit :: (p -> p) -> Storage p a -> Storage p a+retrofit g (Storage (p :*: f)) = Storage $ g p :*: f
Pandora/Paradigm/Structure.hs view
@@ -4,9 +4,9 @@ import Pandora.Paradigm.Structure.Graph as Exports import Pandora.Paradigm.Structure.Stack as Exports +import Pandora.Core.Functor (type (:.:)) import Pandora.Paradigm.Basis.Twister (Twister)-import Pandora.Paradigm.Junction.Transformer (type (:>:))  -- | Type synonymous for at least one element data structure-type family Nonempty structure a :: * where-	Nonempty (Twister :>: t) a = Twister t a+type family Nonempty structure :: * where+	Nonempty ((t :.: Twister t) a) = Twister t a
Pandora/Paradigm/Structure/Graph.hs view
@@ -1,15 +1,15 @@ module Pandora.Paradigm.Structure.Graph (Graph, loose) where +import Pandora.Core.Functor (type (:.:)) import Pandora.Core.Morphism ((.)) import Pandora.Paradigm.Basis.Edges (Edges (Empty, Overlay)) import Pandora.Paradigm.Basis.Twister (Twister ((:<)))-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 = (Twister :>: Edges) a+type Graph a = (Edges :.: Twister 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)+loose = fold Empty (\x -> Overlay . (:<) x)
Pandora/Paradigm/Structure/Stack.hs view
@@ -1,5 +1,6 @@-module Pandora.Paradigm.Structure.Stack (Stack, push, top, pop, filter, linearize) where+module Pandora.Paradigm.Structure.Stack (Stack, push, top, pop, linearize) where +import Pandora.Core.Functor (type (:.:)) import Pandora.Core.Morphism ((.), ($)) import Pandora.Paradigm.Basis.Twister (Twister ((:<)), unwrap) import Pandora.Paradigm.Basis.Maybe (Maybe (Just, Nothing))@@ -15,21 +16,17 @@ import Pandora.Pattern.Object.Setoid (bool)  -- | Linear data structure that serves as a collection of elements-type Stack = (Twister :>: Maybe)+type Stack a = (Maybe :.: Twister Maybe) a  push :: a -> Stack a -> Stack a-push x (Y struct) = (Y $ (:<) x . Just <$> struct) <+> point x+push x stack = ((:<) x . Just <$> stack) <+> (point . point) x  top :: Stack a -> Maybe a-top (Y struct) = extract <$> struct+top stack = extract <$> stack  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)+pop stack = stack >>= unwrap  -- | Transform any traversable structure into a stack linearize :: Traversable t => t a -> Stack a-linearize = Y . fold Nothing (\x -> Just . (:<) x)+linearize = fold Nothing (\x -> Just . (:<) x)
Pandora/Pattern/Functor.hs view
@@ -9,6 +9,7 @@ import Pandora.Pattern.Functor.Bindable as Exports import Pandora.Pattern.Functor.Distributive as Exports import Pandora.Pattern.Functor.Traversable as Exports+import Pandora.Pattern.Functor.Determinable as Exports import Pandora.Pattern.Functor.Extractable as Exports import Pandora.Pattern.Functor.Pointable as Exports import Pandora.Pattern.Functor.Avoidable as Exports
Pandora/Pattern/Functor/Applicative.hs view
@@ -1,7 +1,8 @@ module Pandora.Pattern.Functor.Applicative (Applicative (..)) where +import Pandora.Core.Functor (type (:.:)) import Pandora.Core.Morphism (identity)-import Pandora.Pattern.Functor.Covariant (Covariant ((<$)))+import Pandora.Pattern.Functor.Covariant (Covariant ((<$>), (<$)))  infixl 4 <*>, <*, *> @@ -29,3 +30,15 @@ 	-- | Repeat an action indefinitely 	forever :: t a -> t b 	forever x = x *> forever x++	-- | Infix versions of `apply` with various nesting levels+	(<**>) :: Applicative u => (t :.: u) (a -> b) -> (t :.: u) a -> (t :.: u) b+	f <**> x = (<*>) <$> f <*> x+	(<***>) :: (Applicative u, Applicative v) => (t :.: u :.: v) (a -> b)+		-> (t :.: u :.: v) a -> (t :.: u :.: v) b+	f <***> x = (<**>) <$> f <*> x+	(<****>) :: (Applicative u, Applicative v, Applicative w)+		=> (t :.: u :.: v :.: w) (a -> b)+		-> (t :.: u :.: v :.: w) a+		-> (t :.: u :.: v :.: w) b+	f <****> x = (<***>) <$> f <*> x
Pandora/Pattern/Functor/Contravariant.hs view
@@ -1,6 +1,6 @@ module Pandora.Pattern.Functor.Contravariant (Contravariant (..)) where -import Pandora.Core.Functor (type (:.:))+import Pandora.Core.Functor (type (:.:), type (><)) import Pandora.Core.Morphism ((.), (!), (?))  infixl 4 >$<, $<, >$@@ -33,21 +33,21 @@ 	x >&< f = f >$< x  	-- | Infix versions of `contramap` with various nesting levels-	(>$$<) :: Contravariant u => (a -> b) -> (t :.: u) a -> (t :.: u) b+	(>$$<) :: Contravariant u => (a -> b) -> t :.: u >< a -> t :.: u >< b 	(>$$<) = (>$<) . (>$<) 	(>$$$<) :: (Contravariant u, Contravariant v)-		=> (a -> b) -> (t :.: u :.: v) b -> (t :.: u :.: v) a+		=> (a -> b) -> t :.: u :.: v >< b -> t :.: u :.: v >< a 	(>$$$<) = (>$<) . (>$<) . (>$<) 	(>$$$$<) :: (Contravariant u, Contravariant v, Contravariant w)-		=> (a -> b) -> (t :.: u :.: v :.: w) a -> (t :.: u :.: v :.: w) b+		=> (a -> b) -> t :.: u :.: v :.: w >< a -> t :.: u :.: v :.: w >< b 	(>$$$$<) = (>$<) . (>$<) . (>$<) . (>$<)  	-- | Infix flipped versions of `contramap` with various nesting levels-	(>&&<) :: Contravariant u => (t :.: u) a -> (a -> b) -> (t :.: u) b+	(>&&<) :: Contravariant u => t :.: u >< a -> (a -> b) -> t :.: u >< b 	x >&&< f = f >$$< x 	(>&&&<) :: (Contravariant u, Contravariant v)-		=> (t :.: u :.: v) b -> (a -> b) -> (t :.: u :.: v) a+		=> t :.: u :.: v >< b -> (a -> b) -> t :.: u :.: v >< a 	x >&&&< f = f >$$$< x 	(>&&&&<) :: (Contravariant u, Contravariant v, Contravariant w)-		=> (t :.: u :.: v :.: w) a -> (a -> b) -> (t :.: u :.: v :.: w) b+		=> t :.: u :.: v :.: w >< a -> (a -> b) -> t :.: u :.: v :.: w >< b 	x >&&&&< f = f >$$$$< x
Pandora/Pattern/Functor/Covariant.hs view
@@ -1,6 +1,6 @@ module Pandora.Pattern.Functor.Covariant (Covariant (..)) where -import Pandora.Core.Functor (type (:.:))+import Pandora.Core.Functor (type (:.:), type (><)) import Pandora.Core.Morphism (fix, (.), ($), (!), (?))  infixl 4 <$>, <$, $>@@ -36,23 +36,23 @@ 	x <&> f = f <$> x  	-- | Infix versions of `comap` with various nesting levels-	(<$$>) :: Covariant u => (a -> b) -> (t :.: u) a -> (t :.: u) b+	(<$$>) :: Covariant u => (a -> b) -> t :.: u >< a -> t :.: u >< b 	(<$$>) = (<$>) . (<$>) 	(<$$$>) :: (Covariant u, Covariant v)-		=> (a -> b) -> (t :.: u :.: v) a -> (t :.: u :.: v) b+		=> (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+		=> (a -> b) -> t :.: u :.: v :.: w >< a -> t :.: u :.: v :.: w >< b 	(<$$$$>) = (<$>) . (<$>) . (<$>) . (<$>)  	-- | Infix flipped versions of `comap` with various nesting levels-	(<&&>) :: Covariant u => (t :.: u) a -> (a -> b) -> (t :.: u) b+	(<&&>) :: Covariant u => t :.: u >< a -> (a -> b) -> t :.: u >< b 	x <&&> f = f <$$> x 	(<&&&>) :: (Covariant u, Covariant v)-		=> (t :.: u :.: v) a -> (a -> b) -> (t :.: u :.: v) b-	x <&&&> f = f <$$$> x+		=> t :.: u :.: v >< a -> (a -> b) -> t :.: u :.: v >< b+ 	(<&&&&>) :: (Covariant u, Covariant v, Covariant w)-		=> (t :.: u :.: v :.: w) a -> (a -> b) -> (t :.: u :.: v :.: w) b+		=> t :.: u :.: v :.: w >< a -> (a -> b) -> t :.: u :.: v :.: w >< b 	x <&&&&> f = f <$$$$> x  instance Covariant ((->) a) where
+ Pandora/Pattern/Functor/Determinable.hs view
@@ -0,0 +1,6 @@+module Pandora.Pattern.Functor.Determinable (Determinable (..)) where++import Pandora.Pattern.Functor.Contravariant (Contravariant)++class Contravariant t => Determinable t where+	determine :: t a
Pandora/Pattern/Object/Setoid.hs view
@@ -1,4 +1,4 @@-module Pandora.Pattern.Object.Setoid (Boolean (..), (&&), (||), not, bool, Setoid (..)) where+module Pandora.Pattern.Object.Setoid (Boolean (..), (&&), (||), not, bool, ifelse, Setoid (..)) where  import Pandora.Core.Morphism (($)) @@ -24,6 +24,10 @@ bool :: a -> a -> Boolean -> a bool x _ False = x bool _ y True = y++ifelse :: a -> a -> Boolean -> a+ifelse x _ True = x+ifelse _ y False = y  {- | > When providing a new instance, you should ensure it satisfies the four laws:
pandora.cabal view
@@ -1,5 +1,5 @@ name:                pandora-version:             0.1.6+version:             0.1.7 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@@ -74,6 +74,7 @@     Pandora.Pattern.Functor.Comonad     Pandora.Pattern.Functor.Contravariant     Pandora.Pattern.Functor.Covariant+    Pandora.Pattern.Functor.Determinable     Pandora.Pattern.Functor.Distributive     Pandora.Pattern.Functor.Avoidable     Pandora.Pattern.Functor.Extendable@@ -96,7 +97,7 @@     Pandora.Pattern.Object.Semilattice     Pandora.Pattern.Object.Setoid   default-extensions:-    DataKinds, ConstraintKinds, ExistentialQuantification, QuantifiedConstraints+    DataKinds, ConstraintKinds, ExistentialQuantification, GADTs, QuantifiedConstraints     FlexibleContexts, FlexibleInstances, KindSignatures, LiberalTypeSynonyms     MultiParamTypeClasses, NoImplicitPrelude, PackageImports, PolyKinds, RankNTypes     ScopedTypeVariables, TypeApplications, TypeFamilies, TypeFamilyDependencies, TypeOperators