packages feed

data-ref 0.0.1.2 → 0.0.2

raw patch · 2 files changed

+14/−3 lines, 2 filesdep +data-accessorPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: data-accessor

API changes (from Hackage documentation)

+ Data.Ref: focus :: C m => T a b -> T m a -> T m b
- Data.Ref: Cons :: a -> m () -> m a -> T m a
+ Data.Ref: Cons :: (a -> m ()) -> m a -> T m a
- Data.Ref: liftIO :: (MonadIO m) => T IO a -> T m a
+ Data.Ref: liftIO :: MonadIO m => T IO a -> T m a

Files

data-ref.cabal view
@@ -1,5 +1,5 @@ Name:             data-ref-Version:          0.0.1.2+Version:          0.0.2 License:          BSD3 License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -27,11 +27,12 @@ Source-Repository this   type:     darcs   location: http://hub.darcs.net/thielema/data-ref/-  tag:      0.0.1.2+  tag:      0.0.2  Library   Build-Depends:     transformers >=0.4 && <0.6,+    data-accessor >=0.2.2 && <0.3,     stm >=2.2 && <2.6,     base >=2 && <5 
src/Data/Ref.hs view
@@ -1,4 +1,4 @@-{-+{- | Following an idea by Dominique Devriese: <http://www.haskell.org/pipermail/libraries/2013-June/020185.html> -}@@ -34,6 +34,8 @@ import qualified Control.Monad.Trans.Maybe as MM import qualified Control.Monad.Trans.Reader as MR import qualified Control.Monad.Trans.Identity as MI++import qualified Data.Accessor.Basic as Accessor import Data.Monoid (Monoid)  import Prelude hiding (read)@@ -44,6 +46,12 @@ modify :: C m => T m a -> (a -> a) -> m () modify ref f = write ref . f =<< read ref +focus :: C m => Accessor.T a b -> T m a -> T m b+focus acc ref =+   Cons+      (modify ref . Accessor.set acc)+      (liftM (Accessor.get acc) $ read ref)+ newCons :: C m =>    (a -> m ref) -> (ref -> a -> m ()) -> (ref -> m a) ->    a -> m (T m a)@@ -92,3 +100,5 @@ instance (Monoid w, C m) => C (MWL.WriterT w m) where new = newLifted instance (Monoid w, C m) => C (MRWSS.RWST r w s m) where new = newLifted instance (Monoid w, C m) => C (MRWSL.RWST r w s m) where new = newLifted++-- ToDo: another interesting instance would be Wrapper (StateT Vault)