packages feed

stable-memo 0.2.4 → 0.3.0

raw patch · 4 files changed

+13/−20 lines, 4 filesdep ~hashtables

Dependency ranges changed: hashtables

Files

Data/StableMemo.hs view
@@ -60,18 +60,16 @@ >         map' (x:xs) = f x : go xs -} -module Data.StableMemo (memo, memo2, memo3, (-->) (), memoPoly) where+module Data.StableMemo (memo, memo2, memo3, memoPoly) where  import Control.Applicative import Data.Proxy  import qualified Data.StableMemo.Internal as Internal -import Data.StableMemo.Internal ((-->) ())- -- | Memoize a function with support for a certain form of polymorphic -- recursion.-memoPoly :: (f --> g) -> (f --> g)+memoPoly :: (forall a. f a -> g a) -> f b -> g b {-# NOINLINE memoPoly #-} memoPoly = Internal.memo (Proxy :: Proxy Internal.Strong) 
Data/StableMemo/Internal.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE TypeOperators #-}-module Data.StableMemo.Internal (Ref (..), Strong (..), (-->) (), memo) where+module Data.StableMemo.Internal (Ref (..), Strong (..), memo) where  import Data.Proxy import System.Mem.StableName@@ -57,12 +57,9 @@ unsafeFromAny :: f Any -> f a unsafeFromAny = unsafeCoerce --- | Polymorphic memoizable function-type f --> g = forall a. f a -> g a- memo' :: Ref ref =>-         Proxy ref -> (f --> g) -> MemoTable ref f g ->-         Weak (MemoTable ref f g) -> (f --> g)+         Proxy ref -> (forall a. f a -> g a) -> MemoTable ref f g ->+         Weak (MemoTable ref f g) -> f b -> g b memo' _ f tbl weakTbl !x = unsafePerformIO $ do   sn <- makeStableName $ unsafeToAny x   lkp <- HashTable.lookup tbl sn@@ -82,7 +79,7 @@ tableFinalizer :: Ref ref => MemoTable ref f g -> IO () tableFinalizer = HashTable.mapM_ $ finalize . unO . snd -memo :: Ref ref => Proxy (ref :: * -> *) -> (f --> g) -> (f --> g)+memo :: Ref ref => Proxy (ref :: * -> *) -> (forall a. f a -> g a) -> f b -> g b memo p f =   let (tbl, weak) = unsafePerformIO $ do         tbl' <- HashTable.new
Data/StableMemo/Weak.hs view
@@ -20,7 +20,7 @@ been computed and happens to still be in the heap, it will be reused, otherwise it will be recomputed. -}-module Data.StableMemo.Weak (memo, memo2, memo3, (-->) (), memoPoly) where+module Data.StableMemo.Weak (memo, memo2, memo3, memoPoly) where  import Control.Applicative import Data.Proxy@@ -29,11 +29,9 @@  import qualified Data.StableMemo.Internal as Internal -import Data.StableMemo.Internal ((-->) ())- -- | Memoize a function with support for a certain form of polymorphic -- recursion.-memoPoly :: (f --> g) -> (f --> g)+memoPoly :: (forall a. f a -> g a) -> f b -> g b {-# NOINLINE memoPoly #-} memoPoly = Internal.memo (Proxy :: Proxy Weak) 
stable-memo.cabal view
@@ -1,5 +1,5 @@ name:                stable-memo-version:             0.2.4+version:             0.3.0 synopsis:            Memoization based on argument identity license:             MIT license-file:        LICENSE@@ -7,7 +7,7 @@ maintainer:          Jake McArthur <Jake.McArthur@gmail.com> category:            Data build-type:          Simple-cabal-version:       >=1.10+cabal-version:       >=1.18 description:    Whereas most memo combinators memoize based on equality, stable-memo@@ -65,7 +65,7 @@  library   build-depends:       base >=4.6 && <5,-                       hashtables >=1.0 && <1.2,+                       hashtables >=1.0 && <1.3,                        tagged >=0.4 && <0.8,                        ghc-prim >=0.3 && < 0.4   default-language:    Haskell2010@@ -80,9 +80,9 @@  source-repository head   type:     darcs-  location: http://patch-tag.com/r/jmcarthur/stable-memo+  location: http://hub.darcs.net/jmcarthur/stable-memo  source-repository this   type:     darcs   location: http://patch-tag.com/r/jmcarthur/stable-memo-  tag:      v0.2.4+  tag:      v0.3.0