explicit-sharing 0.3.1.2 → 0.3.1.3
raw patch · 4 files changed
+39/−3 lines, 4 filessetup-changedPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Control.Monad.Sharing: instance (Monad m) => Trans m [Bool] [Bool]
+ Control.Monad.Sharing: instance (Monad m) => Trans m [Char] [Char]
+ Control.Monad.Sharing: instance (Monad m) => Trans m [Double] [Double]
+ Control.Monad.Sharing: instance (Monad m) => Trans m [Float] [Float]
+ Control.Monad.Sharing: instance (Monad m) => Trans m [Int] [Int]
+ Control.Monad.Sharing: instance (Monad m, Trans m a b) => Trans m [a] (List m b)
+ Control.Monad.Sharing.Lazy: instance (MonadIO m) => MonadIO (Lazy m)
+ Control.Monad.Sharing.Lazy: instance MonadTrans Lazy
Files
- Control/Monad/Sharing.hs +25/−0
- Control/Monad/Sharing/Lazy.hs +11/−1
- Setup.hs +2/−1
- explicit-sharing.cabal +1/−1
Control/Monad/Sharing.hs view
@@ -84,6 +84,26 @@ where trans _ = return +instance Monad m => Trans m [Bool] [Bool]+ where+ trans _ = return++instance Monad m => Trans m [Int] [Int]+ where+ trans _ = return++instance Monad m => Trans m [Char] [Char]+ where+ trans _ = return++instance Monad m => Trans m [Float] [Float]+ where+ trans _ = return++instance Monad m => Trans m [Double] [Double]+ where+ trans _ = return+ -- | An instance for lists with monadic elements. instance (Monad m, Trans m a a) => Trans m [m a] [m a] where@@ -133,3 +153,8 @@ where trans _ Nil = return [] trans f (Cons x xs) = return (:) `ap` join (f x) `ap` join (f xs)++instance (Monad m, Trans m a b) => Trans m [a] (List m b)+ where+ trans _ [] = return Nil+ trans f (x:xs) = return Cons `ap` f (return x) `ap` f (return xs)
Control/Monad/Sharing/Lazy.hs view
@@ -25,6 +25,7 @@ ) where +import Control.Monad.Trans import Control.Monad.Sharing -- For fast and easy implementation of typed stores..@@ -71,6 +72,16 @@ mzero = Lazy (\_ _ -> mzero) a `mplus` b = Lazy (\c s -> fromLazy a c s `mplus` fromLazy b c s) +-- @Lazy@ is a monad transformer.+instance MonadTrans Lazy+ where+ lift a = Lazy (\c s -> a >>= \x -> c x s)++-- If the underlying monad supports IO we can lift this functionality.+instance MonadIO m => MonadIO (Lazy m)+ where+ liftIO = lift . liftIO+ -- The @Sharing@ instance memoizes nested monadic values recursively. instance Monad m => Sharing (Lazy m) where@@ -108,4 +119,3 @@ typed :: Untyped -> a typed (Untyped x) = unsafeCoerce x-
Setup.hs view
@@ -5,6 +5,7 @@ main = defaultMainWithHooks $ simpleUserHooks { runTests = runTestSuite } runTestSuite _ _ _ _ =- do pid <- runCommand "ghc -hide-package monads-fd -e main Test.hs"+ do pid <- runCommand $ "ghc -hide-package monads-fd "+ ++ "-hide-package transformers -e main Test.hs" waitForProcess pid >>= exitWith
explicit-sharing.cabal view
@@ -1,5 +1,5 @@ Name: explicit-sharing-Version: 0.3.1.2+Version: 0.3.1.3 Cabal-Version: >= 1.6 Synopsis: Explicit Sharing of Monadic Effects Description: