packages feed

joint 0.1.5 → 0.1.6

raw patch · 15 files changed

+70/−47 lines, 15 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Control.Joint.Abilities.Composition: class Composition t where {
- Control.Joint.Abilities.Composition: run :: Composition t => t a -> Primary t a
- Control.Joint.Abilities.Composition: type family Primary t a :: *;
- Control.Joint.Abilities.Composition: }
- Control.Joint.Abilities.Transformer: infixr 0 :>
- Control.Joint.Abilities.Transformer: instance (Control.Joint.Abilities.Composition.Composition (Control.Joint.Abilities.Transformer.Schema t u), Control.Joint.Abilities.Transformer.Transformer t) => Control.Joint.Abilities.Composition.Composition (t Control.Joint.Abilities.Transformer.:> u)
- Control.Joint.Effects.Either: instance Control.Joint.Abilities.Composition.Composition (Data.Either.Either e)
- Control.Joint.Effects.Maybe: instance Control.Joint.Abilities.Composition.Composition GHC.Maybe.Maybe
- Control.Joint.Effects.Reader: instance Control.Joint.Abilities.Composition.Composition (Control.Joint.Effects.Reader.Reader e)
- Control.Joint.Effects.State: instance Control.Joint.Abilities.Composition.Composition (Control.Joint.Effects.State.State s)
- Control.Joint.Effects.Writer: instance Control.Joint.Abilities.Composition.Composition (Control.Joint.Effects.Writer.Writer e)
- Control.Joint.Effects.Writer: put :: e -> Writer e ()
- Control.Joint.Schemes.TU: instance Control.Joint.Abilities.Composition.Composition (Control.Joint.Schemes.TU.TU t u)
- Control.Joint.Schemes.TUT: instance Control.Joint.Abilities.Composition.Composition (Control.Joint.Schemes.TUT.TUT t u t')
- Control.Joint.Schemes.UT: instance Control.Joint.Abilities.Composition.Composition (Control.Joint.Schemes.UT.UT t u)
+ Control.Joint.Abilities.Interpreted: class Interpreted t where {
+ Control.Joint.Abilities.Interpreted: run :: Interpreted t => t a -> Primary t a
+ Control.Joint.Abilities.Interpreted: type family Primary t a :: *;
+ Control.Joint.Abilities.Interpreted: }
+ Control.Joint.Abilities.Liftable: instance Control.Joint.Abilities.Liftable.Liftable t t
+ Control.Joint.Abilities.Transformer: infixr 3 :>
+ Control.Joint.Abilities.Transformer: instance (Control.Joint.Abilities.Interpreted.Interpreted (Control.Joint.Abilities.Transformer.Schema t u), Control.Joint.Abilities.Transformer.Transformer t) => Control.Joint.Abilities.Interpreted.Interpreted (t Control.Joint.Abilities.Transformer.:> u)
+ Control.Joint.Effects.Either: instance Control.Joint.Abilities.Interpreted.Interpreted (Data.Either.Either e)
+ Control.Joint.Effects.Maybe: instance Control.Joint.Abilities.Interpreted.Interpreted GHC.Maybe.Maybe
+ Control.Joint.Effects.Maybe: nothing :: Optional t => t a
+ Control.Joint.Effects.Reader: instance Control.Joint.Abilities.Interpreted.Interpreted (Control.Joint.Effects.Reader.Reader e)
+ Control.Joint.Effects.State: current :: Stateful s t => t s
+ Control.Joint.Effects.State: instance Control.Joint.Abilities.Interpreted.Interpreted (Control.Joint.Effects.State.State s)
+ Control.Joint.Effects.Writer: add :: Accumulated e t => e -> t ()
+ Control.Joint.Effects.Writer: instance Control.Joint.Abilities.Interpreted.Interpreted (Control.Joint.Effects.Writer.Writer e)
+ Control.Joint.Schemes.TU: instance Control.Joint.Abilities.Interpreted.Interpreted (Control.Joint.Schemes.TU.TU t u)
+ Control.Joint.Schemes.TUT: instance Control.Joint.Abilities.Interpreted.Interpreted (Control.Joint.Schemes.TUT.TUT t u t')
+ Control.Joint.Schemes.UT: instance Control.Joint.Abilities.Interpreted.Interpreted (Control.Joint.Schemes.UT.UT t u)
- Control.Joint.Abilities.Transformer: class Composition t => Transformer t where {
+ Control.Joint.Abilities.Transformer: class Interpreted t => Transformer t where {
- Control.Joint.Effects.Either: failure :: e -> Either e a
+ Control.Joint.Effects.Either: failure :: Failable e t => e -> t a
- Control.Joint.Effects.Reader: get :: Reader e e
+ Control.Joint.Effects.Reader: get :: Configured e t => t e
- Control.Joint.Effects.State: modify :: (s -> s) -> State s ()
+ Control.Joint.Effects.State: modify :: Stateful s t => (s -> s) -> t ()

Files

+ Control/Joint.hs view
@@ -0,0 +1,6 @@+module Control.Joint (module Exports) where++import Control.Joint.Schemes as Exports+import Control.Joint.Effects as Exports+import Control.Joint.Abilities as Exports+import Control.Joint.Core as Exports
Control/Joint/Abilities.hs view
@@ -3,4 +3,4 @@ import Control.Joint.Abilities.Liftable as Exports import Control.Joint.Abilities.Adaptable as Exports import Control.Joint.Abilities.Transformer as Exports-import Control.Joint.Abilities.Composition as Exports+import Control.Joint.Abilities.Interpreted as Exports
− Control/Joint/Abilities/Composition.hs
@@ -1,6 +0,0 @@-module Control.Joint.Abilities.Composition (Composition (..)) where--class Composition t where-	{-# MINIMAL run #-}-	type Primary t a :: *-	run :: t a -> Primary t a
+ Control/Joint/Abilities/Interpreted.hs view
@@ -0,0 +1,6 @@+module Control.Joint.Abilities.Interpreted (Interpreted (..)) where++class Interpreted t where+	{-# MINIMAL run #-}+	type Primary t a :: *+	run :: t a -> Primary t a
Control/Joint/Abilities/Liftable.hs view
@@ -1,7 +1,7 @@ module Control.Joint.Abilities.Liftable where  import Control.Joint.Core (type (~>))-import Control.Joint.Abilities.Composition (Composition (run))+import Control.Joint.Abilities.Interpreted (Interpreted (run)) import Control.Joint.Abilities.Transformer (Transformer (Schema, build, embed), (:>) (T, trans))  class Liftable (eff :: * -> *) (schema :: * -> *) where@@ -10,6 +10,9 @@  type Embedding t u = (Transformer t, Functor u) type Building t u = (Transformer t, Applicative u)++instance Liftable t t where+	lift = id  instance Embedding t u => Liftable u (t :> u) where 	lift = embed
Control/Joint/Abilities/Transformer.hs view
@@ -1,16 +1,16 @@ module Control.Joint.Abilities.Transformer (Transformer (..), (:>) (..)) where  import Control.Joint.Core (type (~>))-import Control.Joint.Abilities.Composition (Composition (Primary, run))+import Control.Joint.Abilities.Interpreted (Interpreted (Primary, run)) -class Composition t => Transformer t where+class Interpreted t => Transformer t where 	{-# MINIMAL embed, build, unite #-} 	type Schema (t :: * -> *) (u :: * -> *) = (r :: * -> *) | r -> t u 	embed :: Functor u => u ~> t :> u 	build :: Applicative u => t ~> t :> u 	unite :: Primary (Schema t u) a -> (t :> u) a -infixr 0 :>+infixr 3 :> newtype (:>) t u a = T { trans :: Transformer t => Schema t u a }  instance Functor (Schema t u) => Functor (t :> u) where@@ -23,6 +23,6 @@ instance (Transformer t, Monad (Schema t u)) => Monad (t :> u) where 	T x >>= f = T $ x >>= trans . f -instance (Composition (Schema t u), Transformer t) => Composition (t :> u) where+instance (Interpreted (Schema t u), Transformer t) => Interpreted (t :> u) where 	type Primary (t :> u) a = Primary (Schema t u) a 	run (T x) = run x
Control/Joint/Effects/Either.hs view
@@ -1,10 +1,11 @@ module Control.Joint.Effects.Either where -import Control.Joint.Abilities (Composition (Primary, run)-	, Transformer (Schema, embed, build, unite), (:>) (T), Liftable)+import Control.Joint.Abilities.Interpreted (Interpreted (Primary, run))+import Control.Joint.Abilities.Transformer (Transformer (Schema, embed, build, unite), (:>) (T))+import Control.Joint.Abilities.Liftable (Liftable (lift)) import Control.Joint.Schemes (UT (UT)) -instance Composition (Either e) where+instance Interpreted (Either e) where 	type Primary (Either e) a = Either e a 	run x = x @@ -24,7 +25,7 @@ instance (Applicative u, Monad u) => Monad (UT (Either e) u) where 	UT x >>= f = UT $ x >>= either (pure . Left) (run . f) -failure :: e -> Either e a-failure = Left- type Failable e = Liftable (Either e)++failure :: Failable e t => e -> t a+failure = lift . Left
Control/Joint/Effects/Maybe.hs view
@@ -1,10 +1,12 @@ module Control.Joint.Effects.Maybe where -import Control.Joint.Abilities (Composition (Primary, run)-	, Transformer (Schema, embed, build, unite), (:>) (T), Adaptable (adapt), Liftable)+import Control.Joint.Abilities.Adaptable (Adaptable (adapt))+import Control.Joint.Abilities.Interpreted (Interpreted (Primary, run))+import Control.Joint.Abilities.Transformer (Transformer (Schema, embed, build, unite), (:>) (T))+import Control.Joint.Abilities.Liftable (Liftable (lift)) import Control.Joint.Schemes (UT (UT)) -instance Composition Maybe where+instance Interpreted Maybe where 	type Primary Maybe a = Maybe a 	run x = x @@ -28,3 +30,6 @@ 	adapt = either (const Nothing) Just  type Optional = Liftable Maybe++nothing :: Optional t => t a+nothing = lift Nothing
Control/Joint/Effects/Reader.hs view
@@ -1,7 +1,8 @@ module Control.Joint.Effects.Reader where -import Control.Joint.Abilities (Composition (Primary, run)-	, Transformer (Schema, embed, build, unite), (:>) (T), Liftable)+import Control.Joint.Abilities.Interpreted (Interpreted (Primary, run))+import Control.Joint.Abilities.Transformer (Transformer (Schema, embed, build, unite), (:>) (T))+import Control.Joint.Abilities.Liftable (Liftable (lift)) import Control.Joint.Schemes (TU (TU))  newtype Reader e a = Reader (e -> a)@@ -16,7 +17,7 @@ instance Monad (Reader e) where 	Reader g >>= f = Reader $ \e -> run (f (g e)) e -instance Composition (Reader e) where+instance Interpreted (Reader e) where 	type Primary (Reader e) a = (->) e a 	run (Reader x) = x @@ -36,7 +37,7 @@ instance (Applicative u, Monad u) => Monad (TU ((->) e) u) where 	TU x >>= f = TU $ \e -> x e >>= ($ e) . run . f -get :: Reader e e-get = Reader $ \e -> e- type Configured e = Liftable (Reader e)++get :: Configured e t => t e+get = lift $ Reader $ \e -> e
Control/Joint/Effects/State.hs view
@@ -1,8 +1,10 @@ module Control.Joint.Effects.State where  import Control.Joint.Core (type (:.), type (:=))-import Control.Joint.Abilities (Composition (Primary, run)-	, Transformer (Schema, embed, build, unite), (:>) (T), Adaptable (adapt), Liftable)+import Control.Joint.Abilities.Adaptable (Adaptable (adapt))+import Control.Joint.Abilities.Interpreted (Interpreted (Primary, run))+import Control.Joint.Abilities.Transformer (Transformer (Schema, embed, build, unite), (:>) (T))+import Control.Joint.Abilities.Liftable (Liftable (lift)) import Control.Joint.Schemes (TUT (TUT)) import Control.Joint.Effects.Reader (Reader (Reader)) import Control.Joint.Effects.Writer (Writer (Writer))@@ -25,7 +27,7 @@ 	State x >>= f = State $ \old -> 		uncurry statefully $ f <$> x old -instance Composition (State s) where+instance Interpreted (State s) where 	type Primary (State s) a = (->) s :. (,) s := a 	run (State x) = x @@ -45,9 +47,6 @@ instance Monad u => Monad (TUT ((->) s) u ((,) s)) where 	TUT x >>= f = TUT $ \old -> x old >>= \(new, y) -> ($ new) . run . f $ y -modify :: (s -> s) -> State s ()-modify f = State $ \s -> (f s, ())- instance Adaptable (Reader e) (State e) where 	adapt (Reader f) = State (\e -> (e, f e)) @@ -55,3 +54,9 @@ 	adapt (Writer (e, x)) = State (\e -> (e, x))  type Stateful e = Liftable (State e)++modify :: Stateful s t => (s -> s) -> t ()+modify f = lift $ State $ \s -> (f s, ())++current :: Stateful s t => t s+current = lift $ State $ \s -> (s, s)
Control/Joint/Effects/Writer.hs view
@@ -1,7 +1,8 @@ module Control.Joint.Effects.Writer where -import Control.Joint.Abilities (Composition (Primary, run)-	, Transformer (Schema, embed, build, unite), (:>) (T), Liftable)+import Control.Joint.Abilities.Interpreted (Interpreted (Primary, run))+import Control.Joint.Abilities.Transformer (Transformer (Schema, embed, build, unite), (:>) (T))+import Control.Joint.Abilities.Liftable (Liftable (lift)) import Control.Joint.Schemes (UT (UT))  newtype Writer e a = Writer (e, a)@@ -18,7 +19,7 @@ 	Writer (e, x) >>= f = let (e', b) = run $ f x in 		Writer (e <> e', b) -instance Composition (Writer e) where+instance Interpreted (Writer e) where 	type Primary (Writer e) a = (e, a) 	run (Writer x) = x @@ -38,7 +39,7 @@ instance (Monoid e, Applicative u, Monad u) => Monad (UT ((,) e) u) where 	UT x >>= f = UT $ x >>= \(acc, v) -> (\(acc', y) -> (acc <> acc', y)) <$> run (f v) -put :: e -> Writer e ()-put s = Writer (s, ())- type Accumulated e t = Liftable (Writer e) t++add :: Accumulated e t => e -> t ()+add s = lift $ Writer (s, ())
Control/Joint/Schemes/TU.hs view
@@ -1,10 +1,10 @@ module Control.Joint.Schemes.TU (TU (..)) where  import Control.Joint.Core (type (:.), type (:=))-import Control.Joint.Abilities (Composition (Primary, run))+import Control.Joint.Abilities (Interpreted (Primary, run))  newtype TU t u a = TU (t :. u := a) -instance Composition (TU t u) where+instance Interpreted (TU t u) where 	type Primary (TU t u) a = t :. u := a 	run (TU x) = x
Control/Joint/Schemes/TUT.hs view
@@ -1,11 +1,11 @@ module Control.Joint.Schemes.TUT (TUT (..)) where  import Control.Joint.Core (type (:.), type (:=))-import Control.Joint.Abilities.Composition (Composition (Primary, run))+import Control.Joint.Abilities.Interpreted (Interpreted (Primary, run))  -- TODO: think about decomposing it on UT and TU newtype TUT t u t' a = TUT (t :. u :. t' := a) -instance Composition (TUT t u t') where+instance Interpreted (TUT t u t') where 	type Primary (TUT t u t') a = t :. u :. t' := a 	run (TUT x) = x
Control/Joint/Schemes/UT.hs view
@@ -1,10 +1,10 @@ module Control.Joint.Schemes.UT (UT (..)) where  import Control.Joint.Core (type (:.), type (:=))-import Control.Joint.Abilities.Composition (Composition (Primary, run))+import Control.Joint.Abilities.Interpreted (Interpreted (Primary, run))  newtype UT t u a = UT (u :. t := a) -instance Composition (UT t u) where+instance Interpreted (UT t u) where 	type Primary (UT t u) a = u :. t := a 	run (UT x) = x
joint.cabal view
@@ -1,5 +1,5 @@ name:                joint-version:             0.1.5+version:             0.1.6 synopsis:            Trying to compose non-composable homepage:            https://github.com/iokasimov/joint license:             BSD3@@ -17,9 +17,10 @@  library   exposed-modules:+    Control.Joint     Control.Joint.Core     Control.Joint.Abilities-    Control.Joint.Abilities.Composition+    Control.Joint.Abilities.Interpreted     Control.Joint.Abilities.Transformer     Control.Joint.Abilities.Adaptable     Control.Joint.Abilities.Liftable