packages feed

resource-effect 0.1.0 → 0.1.1

raw patch · 2 files changed

+8/−6 lines, 2 files

Files

resource-effect.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                resource-effect-version:             0.1.0+version:             0.1.1 synopsis:            A port of the package 'resourcet' for extensible effects. description:          homepage:            https://github.com/wowus/resource-effect/
src/Control/Eff/Resource.hs view
@@ -28,9 +28,11 @@ -- | A resource's state. Type parameter @m@ is the Monad the resource --   deallocation will run in. data ResourceState m =+        -- | ResourceState takes the 'next' int to insert and a map of+        -- cleanup handlers         ResourceState-          {-# UNPACK #-} !Int  -- ^ The 'next' int to insert.-          !(IntMap m) -- ^ A map of cleanup handlers.+          {-# UNPACK #-} !Int+          !(IntMap m)   deriving Typeable  -- | The Resource effect. This effect keeps track of all registered actions,@@ -41,7 +43,7 @@ --   Releasing may be performed before exit via the release function. This --   is a highly recommended optimization, as it will ensure that scarce --   resources are freed early. Note that calling release will deregister---   the action, so that a release action will only ever be called once. +--   the action, so that a release action will only ever be called once. type Resource m = State (ResourceState m)  -- | A lookup key for a specific release action. This value@@ -97,7 +99,7 @@ --   resource into another resourcet process and reregister it there. -- --   It returns an release action that should be run in order to clean---   resource or Nothing in case if resource is already freed. +--   resource or Nothing in case if resource is already freed. unprotect :: (Typeable1 m, Member (Resource (m ())) r)           => ReleaseKey           -> Eff r (Maybe (m ()))@@ -108,7 +110,7 @@       v@(Just _) -> return (ResourceState cnt (M.delete k oldMap), v) {-# INLINE unprotect #-} --- | Unwrap a 'Resource' effect, and call all registered release actions. +-- | Unwrap a 'Resource' effect, and call all registered release actions. runResource :: (Typeable1 m, Monad m, SetMember Lift (Lift m) r)             => Eff (Resource (m ()) :> r) a             -> Eff r a