packages feed

MHask 0.2.0.0 → 0.3.0.0

raw patch · 14 files changed

+121/−96 lines, 14 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- MHask.Util: (~<~) :: (Monad a, Monad b, Monad c) => (c <~ b) -> (b <~ a) -> (c <~ a)
- MHask.Util: (~>~) :: (Monad a, Monad b, Monad c) => (a ~> b) -> (b ~> c) -> (a ~> c)
- MHask.Util: type (<~) m n = n ~> m
+ MHask.Arrow: (~<~) :: (Monad a, Monad b, Monad c) => (c <~ b) -> (b <~ a) -> (c <~ a)
+ MHask.Arrow: (~>~) :: (Monad a, Monad b, Monad c) => (a ~> b) -> (b ~> c) -> (a ~> c)
+ MHask.Arrow: type (<~) m n = n ~> m
+ MHask.Comonad: fmapComonad :: (Monad m, Monad n, Monad (t n), Comonad t) => (m <~ n) -> (t m <~ t n)
+ MHask.Indexed.Comonad: imapComonad :: (Monad m, Monad n, Monad (t j j n), IxComonad t) => (m <~ n) -> (t i j m <~ t i j n)
+ MHask.Indexed.Monad: imapMonad :: (Monad m, Monad n, Monad (t j j n), IxMonad t) => (m ~> n) -> (t i j m ~> t i j n)
+ MHask.Monad: fmapMonad :: (Monad m, Monad n, Monad (t n), Monad t) => (m ~> n) -> (t m ~> t n)

Files

MHask.cabal view
@@ -1,5 +1,5 @@ name:                MHask-version:             0.2.0.0+version:             0.3.0.0 synopsis:            The category of monads description:            MHask is the category where@@ -40,9 +40,12 @@ source-repository this   type:     git   location: git://github.com/DanBurton/MHask.git-  tag:      MHask-0.2.0.0+  tag:      MHask-0.3.0.0  library-  exposed-modules:     MHask, MHask.Comonad, MHask.Monad, MHask.Copointed, MHask.Pointed, MHask.Util, MHask.Functor, MHask.Indexed.Comonad, MHask.Indexed.Monad, MHask.Indexed.Copointed, MHask.Indexed.Pointed, MHask.Indexed.Functor+  exposed-modules:     MHask, MHask.Comonad, MHask.Monad, MHask.Copointed, MHask.Pointed, MHask.Arrow, MHask.Functor, MHask.Indexed.Comonad, MHask.Indexed.Monad, MHask.Indexed.Copointed, MHask.Indexed.Pointed, MHask.Indexed.Functor    build-depends:       base >= 2 && < 4.7, transformers >= 0.3++  ghc-options:         -Wall+
MHask.hs view
@@ -6,8 +6,8 @@ --  -- > import qualified MHask module MHask (-  -- * Prelimiaries-  module MHask.Util,+  -- * Prelimiary+  module MHask.Arrow,    -- * Classes   module MHask.Functor,@@ -24,7 +24,7 @@   module MHask.Indexed.Comonad,   ) where -import MHask.Util+import MHask.Arrow  import MHask.Functor import MHask.Pointed
+ MHask/Arrow.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}++-- | This module sets the stage for the rest of the package.+-- It defines a type synonym @~>@ which cleans up the+-- type signatures,+-- and  @~>~@ which is used in the default implementation+-- of bind. These represent the type of arrows and arrow composition+-- in MHask, respectively.+-- +-- By using @~>@, type signatures for the MHask class operations+-- can be easily compared to their Hask counterparts. However,+-- as a reminder that you are dealing with Monads, where+-- typically you would see @a@ and @b@ in the Hask counterpart,+-- you will instead see @m@ and @n@, and where you would+-- typically see @m@ or @w@, you will instead see @t@,+-- as a mnemonic for Monad transformer.+-- +-- For illustrative purposes, this module also provides+-- @<~@ and @~<~@, to clearly illustrate how duals are+-- nothing more than just \"flipping the arrows\".+-- You are encouraged to compare docs or even source files+-- to see just how similar they are, all the way down+-- to default implementations.+module MHask.Arrow where++-- | The @~>@ type represents arrows in the+-- category of MHask. +type m ~> n = forall x. m x -> n x++-- | It's just @~>@ flipped.+-- +-- > type m <~ n = n ~> m+type m <~ n = n ~> m++-- | Left-to-right composition of arrows in MHask.+(~>~) :: (Monad a, Monad b, Monad c) => (a ~> b) -> (b ~> c) -> (a ~> c)+f1 ~>~ f2 = f2 . f1++-- | It's just @~>~@ flipped.+-- +-- > (~<~) = flip (~>~)+(~<~) :: (Monad a, Monad b, Monad c) => (c <~ b) -> (b <~ a) -> (c <~ a)+(~<~) = flip (~>~)
MHask/Comonad.hs view
@@ -1,13 +1,11 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to comonad.Control.Comonad (Comonad) module MHask.Comonad where   -import MHask.Util+import MHask.Arrow  import qualified MHask.Functor as MHask import qualified MHask.Copointed as MHask@@ -30,3 +28,10 @@     => (m <~ t n) -> (t m <~ t n)   extend f = MHask.fmap f ~<~ duplicate ++-- | If you define your Comonad in terms of extend and extract,+-- then you get a free implementation of fmap which can+-- be used for Functor.+fmapComonad :: (Monad m, Monad n, Monad (t n), Comonad t)+  => (m <~ n) -> (t m <~ t n)+fmapComonad f = extend (f ~<~ MHask.extract)
MHask/Copointed.hs view
@@ -1,12 +1,10 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to comonad.Control.Comonad (Copointed) module MHask.Copointed where  -import MHask.Util+import MHask.Arrow  import Data.Monoid import Control.Monad (liftM)@@ -14,14 +12,18 @@ import Control.Monad.Trans.Reader import Control.Monad.Trans.Writer -import qualified MHask.Functor as MHask +import qualified MHask.Functor as MHask   -- | The dual of "MHask.Pointed" class (MHask.Functor t) => Copointed t where   extract :: (Monad m)     => m <~ t m++++   instance (Monoid s) => Copointed (StateT s) where
MHask/Functor.hs view
@@ -1,12 +1,10 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to base.Prelude.Functor (Functor) module MHask.Functor where  import Prelude hiding (Functor, fmap)-import MHask.Util+import MHask.Arrow  import Control.Monad.Trans.State import Control.Monad.Trans.Reader@@ -14,6 +12,7 @@   + -- | Functor is its own dual. class Functor t where   -- | Flipping the arrows on fmap's type signature@@ -22,6 +21,10 @@   -- > (m <~ n) -> (t m <~ t n)   fmap :: (Monad m, Monad n)     => (m ~> n) -> (t m ~> t n)++++   instance Functor (StateT s) where
MHask/Indexed/Comonad.hs view
@@ -1,13 +1,11 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to indexed.Control.Comonad.Indexed (IxComonad) module MHask.Indexed.Comonad where   -import MHask.Util+import MHask.Arrow  import qualified MHask.Indexed.Functor as MHask import qualified MHask.Indexed.Copointed as MHask@@ -30,3 +28,10 @@     => (m <~ t j k n) -> (t i j m <~ t i k n)   iextend f = MHask.imap f ~<~ iduplicate ++-- | If you define your IxComonad in terms of iextend and iextract,+-- then you get a free implementation of imap which can+-- be used for IxFunctor.+imapComonad :: (Monad m, Monad n, Monad (t j j n), IxComonad t)+  => (m <~ n) -> (t i j m <~ t i j n)+imapComonad f = iextend (f ~<~ MHask.iextract)
MHask/Indexed/Copointed.hs view
@@ -1,12 +1,10 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to indexed.Data.Functor.Indexed (IxCopointed) module MHask.Indexed.Copointed where  -import MHask.Util+import MHask.Arrow   
MHask/Indexed/Functor.hs view
@@ -1,15 +1,14 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to indexed.Data.Functor.Indexed (IxFunctor) module MHask.Indexed.Functor where -import MHask.Util -import Control.Monad.Trans.State-import Control.Monad.Trans.Reader-import Control.Monad.Trans.Writer+import MHask.Arrow++++  import qualified MHask.Functor as MHask 
MHask/Indexed/Monad.hs view
@@ -1,13 +1,11 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to indexed.Control.Monad.Indexed (IxMonad) module MHask.Indexed.Monad where   -import MHask.Util+import MHask.Arrow  import qualified MHask.Indexed.Pointed as MHask import qualified MHask.Indexed.Functor as MHask@@ -30,3 +28,10 @@     => (m ~> t j k n) -> (t i j m ~> t i k n)   ibind f = MHask.imap f ~>~ ijoin ++-- | If you define your IxMonad in terms of ibind and ireturn,+-- then you get a free implementation of imap which can+-- be used for IxFunctor.+imapMonad :: (Monad m, Monad n, Monad (t j j n), IxMonad t)+  => (m ~> n) -> (t i j m ~> t i j n)+imapMonad f = ibind (f ~>~ MHask.ireturn)
MHask/Indexed/Pointed.hs view
@@ -1,12 +1,10 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to indexed.Data.Functor.Indexed (IxPointed) module MHask.Indexed.Pointed where  -import MHask.Util+import MHask.Arrow   
MHask/Monad.hs view
@@ -1,13 +1,11 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Compare to base.Prelude (Monad) module MHask.Monad where -import Prelude hiding (Monad, join)+import Prelude hiding (Monad) import qualified Prelude as P-import MHask.Util+import MHask.Arrow  import qualified MHask.Functor as MHask import qualified MHask.Pointed as MHask@@ -29,3 +27,11 @@      P.Monad (t (t n)))     => (m ~> t n) -> (t m ~> t n)   bind f = MHask.fmap f ~>~ join+++-- | If you define your Monad in terms of bind and return,+-- then you get a free implementation of fmap which can+-- be used for Functor.+fmapMonad :: (P.Monad m, P.Monad n, P.Monad (t n), Monad t)+  => (m ~> n) -> (t m ~> t n)+fmapMonad f = bind (f ~>~ MHask.return)
MHask/Pointed.hs view
@@ -1,12 +1,10 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}-+{-# LANGUAGE RankNTypes, TypeOperators, DefaultSignatures #-}  -- | Equivalent to transformers.Control.Monad.Trans.Class (MonadTrans) module MHask.Pointed where  import Prelude hiding (return)-import MHask.Util+import MHask.Arrow  import Data.Monoid import Control.Monad (liftM)@@ -14,14 +12,18 @@ import Control.Monad.Trans.Reader import Control.Monad.Trans.Writer -import qualified MHask.Functor as MHask +import qualified MHask.Functor as MHask   -- | The dual of "MHask.Copointed" class (MHask.Functor t) => Pointed t where   return :: (Monad m)     => m ~> t m++++   instance Pointed (StateT s) where
− MHask/Util.hs
@@ -1,44 +0,0 @@-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE Rank2Types #-}---- | This module sets the stage for the rest of the package.--- It defines a type synonym @~>@ which cleans up the--- type signatures,--- and  @~>~@ which is used in the default implementation--- of bind. These represent the type of arrows and arrow composition--- in MHask, respectively.--- --- By using @~>@, type signatures for the MHask class operations--- can be easily compared to their Hask counterparts. However,--- as a reminder that you are dealing with Monads, where--- typically you would see @a@ and @b@ in the Hask counterpart,--- you will instead see @m@ and @n@, and where you would--- typically see @m@ or @w@, you will instead see @t@,--- as a mnemonic for Monad transformer.--- --- For illustrative purposes, this module also provides--- @<~@ and @~<~@, to clearly illustrate how duals are--- nothing more than just \"flipping the arrows\".--- You are encouraged to compare docs or even source files--- to see just how similar they are, all the way down--- to default implementations.-module MHask.Util where---- | The @~>@ type represents arrows in the--- category of MHask. -type m ~> n = forall x. m x -> n x---- | It's just @~>@ flipped.--- --- > type m <~ n = n ~> m-type m <~ n = n ~> m---- | Left-to-right composition of arrows in MHask.-(~>~) :: (Monad a, Monad b, Monad c) => (a ~> b) -> (b ~> c) -> (a ~> c)-f1 ~>~ f2 = f2 . f1---- | It's just @~>~@ flipped.--- --- > (~<~) = flip (~>~)-(~<~) :: (Monad a, Monad b, Monad c) => (c <~ b) -> (b <~ a) -> (c <~ a)-(~<~) = flip (~>~)