summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConalElliott <>2013-01-17 02:11:38 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2013-01-17 02:11:38 (GMT)
commit689418bb16570ae7d769a131a4a734af044ace9e (patch)
treecc0cd1c251f71a2b4c2d7c3ba28895b2f9f9ec01
parentef45e3422802e2cddccf05176f891b37e886cbd7 (diff)
version 0.9.90.9.9
-rw-r--r--TypeCompose.cabal2
-rw-r--r--src/Control/Compose.hs20
2 files changed, 15 insertions, 7 deletions
diff --git a/TypeCompose.cabal b/TypeCompose.cabal
index c6693ad..1e5d02c 100644
--- a/TypeCompose.cabal
+++ b/TypeCompose.cabal
@@ -1,5 +1,5 @@
Name: TypeCompose
-Version: 0.9.8
+Version: 0.9.9
Synopsis: Type composition classes & instances
Category: Composition, Control
Cabal-Version: >= 1.6
diff --git a/src/Control/Compose.hs b/src/Control/Compose.hs
index 828da48..bf60db1 100644
--- a/src/Control/Compose.hs
+++ b/src/Control/Compose.hs
@@ -36,7 +36,7 @@ module Control.Compose
, (:.)(..), O, unO, biO, convO, coconvO, inO, inO2, inO3
, oPure, oFmap, oLiftA2, oLiftA3
, fmapFF, fmapCC, contraFmapFC, contraFmapCF
- , DistribM(..), joinDistribM
+ , DistribM(..), joinDistribM, bindDistribM, returnDistribM
, joinMMT, joinComposeT
-- * Type composition
-- ** Unary\/binary
@@ -364,7 +364,7 @@ instance (Applicative g, Applicative f) => Applicative (g :. f) where
class DistribM m n where
distribM :: n (m a) -> m (n a)
--- | 'join' for @(m :. n)@
+-- | A candidate 'join' for @(m :. n)@
joinDistribM :: (Monad m, Monad n, DistribM m n) =>
(m :. n) ((m :. n) a) -> (m :. n) a
joinDistribM = O . liftM join . join . liftM distribM . (liftM.liftM) unO . unO
@@ -379,12 +379,20 @@ joinDistribM = O . liftM join . join . liftM distribM . (liftM.liftM) unO . unO
-- --> m (n a) -- liftM join
-- --> (m :. n) a -- O
+-- | A candidate '(>>=)' for @(m :. n)@
+bindDistribM :: (Functor m, Functor n, Monad m, Monad n, DistribM m n) =>
+ (m :. n) a -> (a -> (m :. n) b) -> (m :. n) b
+mn `bindDistribM` f = joinDistribM (fmap f mn)
+
+returnDistribM :: (Monad m, Monad n) => a -> (m :. n) a
+returnDistribM = O . return . return
+
-- Template for specialization:
--
--- instance (Monad m, Monad n, DistribM m n) => Monad (m :. n) where
--- return = O . return . return
--- e >>= f = joinDistribM (liftM f e)
-
+-- instance (Functor m, Functor n, Monad m, Monad n, DistribM m n)
+-- => Monad (m :. n) where
+-- return = returnDistribM
+-- (>>=) = bindDistribM
-- | 'join'-like function for implicitly composed monads
joinMMT :: (Monad m, Monad n, Traversable n, Applicative m) =>