[GHC] #8088: Disposable types language extension

#8088: Disposable types language extension ----------------------------------------------+---------------------------- Reporter: schyler | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Moderate (less than a day) | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: ----------------------------------------------+---------------------------- The disposable types language extension would serve as a way of allowing the garbage collector to clean up things which require destroying handles, closing resources, etc to prevent resource exhaustion in code (even if exceptions occur) without adding transformer overhead like ResourceT. Consider the following example: {{{ {-# LANGUAGE DisposableTypes #-} class Dispose t where dispose :: t -> IO () instance Dispose SockHandle where dispose = disconnect }}} When the `SockHandle` is collected, the garbage collector runs its `dispose` method (and it's automatically disconnected and cleaned up). Similar principles could be applied to a file handle, shared memory etc. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8088 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8088: Disposable types language extension ----------------------------+---------------------------------------------- Reporter: schyler | Owner: Type: feature | Status: closed request | Milestone: Priority: normal | Version: Component: | Keywords: Compiler | Architecture: Unknown/Multiple Resolution: invalid | Difficulty: Moderate (less than a day) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | ----------------------------+---------------------------------------------- Changes (by carter): * status: new => closed * resolution: => invalid Comment: We have those by use of finalizers and related tools. see http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Mem- Weak.html for one such tool. closing ticket -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8088#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8088: Disposable types language extension ----------------------------+---------------------------------------------- Reporter: schyler | Owner: Type: feature | Status: closed request | Milestone: Priority: normal | Version: Component: | Keywords: Compiler | Architecture: Unknown/Multiple Resolution: invalid | Difficulty: Moderate (less than a day) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | ----------------------------+---------------------------------------------- Comment (by carter): Just to explain more, while in principal thats a great idea, that has a lot of implications for the garbage collector, and it doesn't address the fact that there might be more than one valid handle! (how does the GC understand equality among handles?! ). Theres a lot of subtleties, though there are probably some good experiments that could be done with the garbage collector to explore this. Basically: this is a research project, not a feature :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8088#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC