Hello community,

here is the log from the commit of package ghc-unliftio for openSUSE:Factory 
checked in at 2018-10-25 08:19:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-unliftio (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-unliftio.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-unliftio"

Thu Oct 25 08:19:10 2018 rev:4 rq:642901 version:0.2.8.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-unliftio/ghc-unliftio.changes        
2018-09-03 10:35:04.384664841 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-unliftio.new/ghc-unliftio.changes   
2018-10-25 08:19:10.887996020 +0200
@@ -1,0 +2,12 @@
+Thu Oct  4 15:40:13 UTC 2018 - [email protected]
+
+- Update unliftio to version 0.2.8.1.
+  ## 0.2.8.1
+
+  * Support for `stm-2.5.0.0`
+
+  ## 0.2.8.0
+
+  * Add 'UnliftIO.Memoize'
+
+-------------------------------------------------------------------

Old:
----
  unliftio-0.2.7.1.tar.gz

New:
----
  unliftio-0.2.8.1.tar.gz
  unliftio.cabal

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-unliftio.spec ++++++
--- /var/tmp/diff_new_pack.STDbfx/_old  2018-10-25 08:19:11.715995654 +0200
+++ /var/tmp/diff_new_pack.STDbfx/_new  2018-10-25 08:19:11.715995654 +0200
@@ -12,20 +12,21 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 %global pkg_name unliftio
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.2.7.1
+Version:        0.2.8.1
 Release:        0
 Summary:        The MonadUnliftIO typeclass for unlifting monads to IO 
(batteries included)
 License:        MIT
 Group:          Development/Libraries/Haskell
 URL:            https://hackage.haskell.org/package/%{pkg_name}
 Source0:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
+Source1:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/revision/1.cabal#/%{pkg_name}.cabal
 BuildRequires:  ghc-Cabal-devel
 BuildRequires:  ghc-async-devel
 BuildRequires:  ghc-deepseq-devel
@@ -59,6 +60,7 @@
 
 %prep
 %setup -q -n %{pkg_name}-%{version}
+cp -p %{SOURCE1} %{pkg_name}.cabal
 
 %build
 %ghc_lib_build

++++++ unliftio-0.2.7.1.tar.gz -> unliftio-0.2.8.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/unliftio-0.2.7.1/ChangeLog.md 
new/unliftio-0.2.8.1/ChangeLog.md
--- old/unliftio-0.2.7.1/ChangeLog.md   2018-08-28 09:17:05.000000000 +0200
+++ new/unliftio-0.2.8.1/ChangeLog.md   2018-09-22 20:08:12.000000000 +0200
@@ -1,5 +1,13 @@
 # Changelog for unliftio
 
+## 0.2.8.1
+
+* Support for `stm-2.5.0.0`
+
+## 0.2.8.0
+
+* Add 'UnliftIO.Memoize'
+
 ## 0.2.7.1
 
 * Minor doc improvements
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/unliftio-0.2.7.1/src/UnliftIO/Memoize.hs 
new/unliftio-0.2.8.1/src/UnliftIO/Memoize.hs
--- old/unliftio-0.2.7.1/src/UnliftIO/Memoize.hs        1970-01-01 
01:00:00.000000000 +0100
+++ new/unliftio-0.2.8.1/src/UnliftIO/Memoize.hs        2018-09-04 
11:00:51.000000000 +0200
@@ -0,0 +1,75 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+-- | Memoize the results of actions. In other words: actions
+-- will be run once, on demand, and their results saved.
+--
+-- Exceptions semantics: if a synchronous exception is thrown while performing
+-- the computation, that result will be saved and rethrown each time
+-- 'runMemoized' is called subsequently.'
+--
+-- @since 0.2.8.0
+module UnliftIO.Memoize
+  ( Memoized
+  , runMemoized
+  , memoizeRef
+  , memoizeMVar
+  ) where
+
+import Control.Applicative as A
+import Control.Monad (join)
+import Control.Monad.IO.Unlift
+import UnliftIO.Exception
+import UnliftIO.IORef
+import UnliftIO.MVar
+
+-- | A \"run once\" value, with results saved. Extract the value with
+-- 'runMemoized'. For single-threaded usage, you can use 'memoizeRef' to
+-- create a value. If you need guarantees that only one thread will run the
+-- action at a time, use 'memoizeMVar'.
+--
+-- Note that this type provides a 'Show' instance for convenience, but not
+-- useful information can be provided.
+--
+-- @since 0.2.8.0
+newtype Memoized a = Memoized (IO a)
+  deriving (Functor, A.Applicative, Monad)
+instance Show (Memoized a) where
+  show _ = "<<Memoized>>"
+
+-- | Extract a value from a 'Memoized', running an action if no cached value is
+-- available.
+--
+-- @since 0.2.8.0
+runMemoized :: MonadIO m => Memoized a -> m a
+runMemoized (Memoized m) = liftIO m
+{-# INLINE runMemoized #-}
+
+-- | Create a new 'Memoized' value using an 'IORef' under the surface. Note 
that
+-- the action may be run in multiple threads simultaneously, so this may not be
+-- thread safe (depending on the underlying action). Consider using
+-- 'memoizeMVar'.
+--
+-- @since 0.2.8.0
+memoizeRef :: MonadUnliftIO m => m a -> m (Memoized a)
+memoizeRef action = withRunInIO $ \run -> do
+  ref <- newIORef Nothing
+  pure $ Memoized $ do
+    mres <- readIORef ref
+    res <-
+      case mres of
+        Just res -> pure res
+        Nothing -> do
+          res <- tryAny $ run action
+          writeIORef ref $ Just res
+          pure res
+    either throwIO pure res
+
+-- | Same as 'memoizeRef', but uses an 'MVar' to ensure that an action is
+-- only run once, even in a multithreaded application.
+--
+-- @since 0.2.8.0
+memoizeMVar :: MonadUnliftIO m => m a -> m (Memoized a)
+memoizeMVar action = withRunInIO $ \run -> do
+  var <- newMVar Nothing
+  pure $ Memoized $ join $ modifyMVar var $ \mres -> do
+    res <- maybe (tryAny $ run action) pure mres
+    pure (Just res, either throwIO pure res)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/unliftio-0.2.7.1/src/UnliftIO/STM.hs 
new/unliftio-0.2.8.1/src/UnliftIO/STM.hs
--- old/unliftio-0.2.7.1/src/UnliftIO/STM.hs    2018-04-22 11:27:01.000000000 
+0200
+++ new/unliftio-0.2.8.1/src/UnliftIO/STM.hs    2018-09-22 20:06:41.000000000 
+0200
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 -- | Lifted version of "Control.Concurrent.STM"
 --
 -- @since 0.2.1.0
@@ -84,6 +85,10 @@
 import Control.Monad.IO.Unlift
 import System.Mem.Weak (Weak)
 
+#if MIN_VERSION_stm(2, 5, 0)
+import GHC.Natural (Natural)
+#endif
+
 -- | Lifted version of 'STM.atomically'
 --
 -- @since 0.2.1.0
@@ -165,5 +170,9 @@
 -- | Lifted version of 'STM.newTBQueueIO'
 --
 -- @since 0.2.1.0
+#if MIN_VERSION_stm(2, 5, 0)
+newTBQueueIO :: MonadIO m => Natural -> m (TBQueue a)
+#else
 newTBQueueIO :: MonadIO m => Int -> m (TBQueue a)
+#endif
 newTBQueueIO = liftIO . STM.newTBQueueIO
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/unliftio-0.2.7.1/src/UnliftIO.hs 
new/unliftio-0.2.8.1/src/UnliftIO.hs
--- old/unliftio-0.2.7.1/src/UnliftIO.hs        2018-01-02 17:25:04.000000000 
+0100
+++ new/unliftio-0.2.8.1/src/UnliftIO.hs        2018-09-04 11:00:51.000000000 
+0200
@@ -7,6 +7,7 @@
   , module UnliftIO.Exception
   , module UnliftIO.IO
   , module UnliftIO.IORef
+  , module UnliftIO.Memoize
   , module UnliftIO.MVar
   , module UnliftIO.STM
   , module UnliftIO.Temporary
@@ -19,6 +20,7 @@
 import UnliftIO.Exception
 import UnliftIO.IO
 import UnliftIO.IORef
+import UnliftIO.Memoize
 import UnliftIO.MVar
 import UnliftIO.STM
 import UnliftIO.Temporary
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/unliftio-0.2.7.1/test/UnliftIO/MemoizeSpec.hs 
new/unliftio-0.2.8.1/test/UnliftIO/MemoizeSpec.hs
--- old/unliftio-0.2.7.1/test/UnliftIO/MemoizeSpec.hs   1970-01-01 
01:00:00.000000000 +0100
+++ new/unliftio-0.2.8.1/test/UnliftIO/MemoizeSpec.hs   2018-09-04 
11:00:51.000000000 +0200
@@ -0,0 +1,45 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+module UnliftIO.MemoizeSpec (spec) where
+
+import Control.Concurrent (threadDelay)
+import Control.Monad (replicateM_)
+import Test.Hspec
+import Test.Hspec.QuickCheck
+import UnliftIO
+import Data.Typeable
+
+data Dummy = Dummy
+  deriving (Show, Typeable)
+instance Exception Dummy
+
+spec :: Spec
+spec = do
+  let basics maker = do
+        prop "sanity" $ \i -> do
+          x <- maker $ return (i :: Int)
+          runMemoized x `shouldReturn` i
+        prop "runs once" $ \i -> do
+          count <- newIORef (0 :: Int)
+          x <- maker $ do
+            modifyIORef' count (+ 1)
+            return (i :: Int)
+          replicateM_ 10 $ runMemoized x `shouldReturn` i
+          readIORef count `shouldReturn` 1
+        it "runs once with exception" $ do
+          count <- newIORef (0 :: Int)
+          x <- maker $ do
+            modifyIORef' count (+ 1)
+            throwIO Dummy
+          replicateM_ 10 $ runMemoized x `shouldThrow` (\Dummy -> True)
+          readIORef count `shouldReturn` 1
+  describe "memoizeRef" $ basics memoizeRef
+  describe "memoizeMVar" $ do
+    basics memoizeMVar
+    prop "runs once in multiple threads" $ \i -> do
+      count <- newIORef (0 :: Int)
+      x <- memoizeMVar $ do
+        threadDelay 10000
+        atomicModifyIORef' count $ \cnt -> (cnt + 1, ())
+        return (i :: Int)
+      replicateConcurrently_ 10 $ runMemoized x `shouldReturn` i
+      readIORef count `shouldReturn` 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/unliftio-0.2.7.1/unliftio.cabal 
new/unliftio-0.2.8.1/unliftio.cabal
--- old/unliftio-0.2.7.1/unliftio.cabal 2018-08-28 09:17:17.000000000 +0200
+++ new/unliftio-0.2.8.1/unliftio.cabal 2018-09-22 20:30:24.000000000 +0200
@@ -1,13 +1,13 @@
-cabal-version: >= 1.10
+cabal-version: 1.12
 
--- This file has been generated from package.yaml by hpack version 0.29.6.
+-- This file has been generated from package.yaml by hpack version 0.30.0.
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: 80f98ec8618eddf5cd9e60732404c2af04ec9c97f9edefb9aa7b236b776e10ea
+-- hash: b929fccb27c59fc9bc0f46c3f81f101436a852090cd8bc99591e2a71d53e65f1
 
 name:           unliftio
-version:        0.2.7.1
+version:        0.2.8.1
 synopsis:       The MonadUnliftIO typeclass for unlifting monads to IO 
(batteries included)
 description:    Please see the documentation and README at 
<https://www.stackage.org/package/unliftio>
 category:       Control
@@ -19,8 +19,8 @@
 license-file:   LICENSE
 build-type:     Simple
 extra-source-files:
-    ChangeLog.md
     README.md
+    ChangeLog.md
 
 library
   hs-source-dirs:
@@ -60,6 +60,7 @@
       UnliftIO.Foreign
       UnliftIO.IO
       UnliftIO.IORef
+      UnliftIO.Memoize
       UnliftIO.MVar
       UnliftIO.Process
       UnliftIO.STM
@@ -93,5 +94,6 @@
   other-modules:
       UnliftIO.ExceptionSpec
       UnliftIO.IOSpec
+      UnliftIO.MemoizeSpec
       Paths_unliftio
   default-language: Haskell2010

++++++ unliftio.cabal ++++++
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.30.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: b929fccb27c59fc9bc0f46c3f81f101436a852090cd8bc99591e2a71d53e65f1

name:           unliftio
version:        0.2.8.1
x-revision: 1
synopsis:       The MonadUnliftIO typeclass for unlifting monads to IO 
(batteries included)
description:    Please see the documentation and README at 
<https://www.stackage.org/package/unliftio>
category:       Control
homepage:       https://github.com/fpco/unliftio/tree/master/unliftio#readme
author:         Michael Snoyman, Francesco Mazzoli
maintainer:     [email protected]
copyright:      2017 FP Complete
license:        MIT
license-file:   LICENSE
build-type:     Simple
extra-source-files:
    README.md
    ChangeLog.md

library
  hs-source-dirs:
      src
  build-depends:
      async >2.1.1
    , base >=4.8 && <5
    , deepseq >= 1.1.0.0
    , directory
    , filepath
    , process >=1.2.0.0
    , stm >=2.4.3 && <2.6
    , time
    , transformers
    , unliftio-core >=0.1.1.0
  if !os(Windows)
    build-depends:
        unix
  if os(darwin)
    c-sources:
        cbits/time-osx.c
  else
    if os(windows)
      c-sources:
          cbits/time-windows.c
    else
      c-sources:
          cbits/time-posix.c
  exposed-modules:
      UnliftIO
      UnliftIO.Async
      UnliftIO.Chan
      UnliftIO.Concurrent
      UnliftIO.Directory
      UnliftIO.Environment
      UnliftIO.Exception
      UnliftIO.Foreign
      UnliftIO.IO
      UnliftIO.IORef
      UnliftIO.Memoize
      UnliftIO.MVar
      UnliftIO.Process
      UnliftIO.STM
      UnliftIO.Temporary
      UnliftIO.Timeout
  other-modules:
      Paths_unliftio
  default-language: Haskell2010

test-suite unliftio-spec
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  hs-source-dirs:
      test
  build-depends:
      async >2.1.1
    , base >=4.7 && <5
    , deepseq >= 1.1.0.0
    , directory
    , filepath
    , hspec
    , process >=1.2.0.0
    , stm >=2.4.3 && <2.6
    , time
    , transformers
    , unliftio
    , unliftio-core >=0.1.1.0
  if !os(Windows)
    build-depends:
        unix
  other-modules:
      UnliftIO.ExceptionSpec
      UnliftIO.IOSpec
      UnliftIO.MemoizeSpec
      Paths_unliftio
  default-language: Haskell2010

Reply via email to