disposable 0.2.0.3 → 0.2.0.4
raw patch · 2 files changed
+20/−4 lines, 2 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Control.Disposable: instance Control.Disposable.Disposing Control.Disposable.SomeDisposable
+ Control.Disposable: instance Control.Disposable.Disposing Data.JSString.Internal.Type.JSString
+ Control.Disposable: instance Control.Disposable.Disposing GHC.Types.Int
+ Control.Disposable: instance Control.Disposable.Disposing GHCJS.Prim.JSVal
+ Control.Disposable: instance Control.Disposable.Disposing a => Control.Disposable.Disposing (Data.DList.DList a)
Files
- disposable.cabal +2/−2
- src/Control/Disposable.hs +18/−2
disposable.cabal view
@@ -1,7 +1,7 @@ name: disposable-version: 0.2.0.3+version: 0.2.0.4 synopsis: Allows storing different resource-releasing actions together.-description: SomeDisposable aloows storing different resource releasing actions togther in a container.+description: SomeDisposable allows storing different resource releasing actions togther in a container. This library is useful for queueing up GHCJS.Foreign.Callback together to be released after a new rendering frame. homepage: https://github.com/louispan/disposable#readme
src/Control/Disposable.hs view
@@ -13,11 +13,15 @@ import Data.Semigroup import qualified GHC.Generics as G import qualified GHCJS.Foreign.Callback as J+import qualified GHCJS.Types as J -- | A 'Disposable' is something with some resources to release class Disposable a where dispose :: a -> IO () +instance Disposable (J.Callback a) where+ dispose = J.releaseCallback+ -- | Allows storing 'Disposable's in a heterogenous container data SomeDisposable where DisposeNone :: SomeDisposable@@ -50,11 +54,23 @@ default disposing :: (G.Generic a, GDisposing (G.Rep a)) => a -> SomeDisposable disposing x = DisposeList . D.toList . gDisposing $ G.from x -instance Disposable (J.Callback a) where- dispose = J.releaseCallback+instance Disposing SomeDisposable where+ disposing = id instance Disposing (J.Callback a) where disposing = Dispose++instance Disposing Int where+ disposing _ = DisposeNone++instance Disposing J.JSString where+ disposing _ = DisposeNone++instance Disposing J.JSVal where+ disposing _ = DisposeNone++instance Disposing a => Disposing (D.DList a) where+ disposing xs = DisposeList $ disposing <$> D.toList xs -- | Generic instance basically traverses the data type structure -- and expects the values to be all instances of 'Disposing'