|Maintainer||Bas van Dijk <email@example.com>|
WARNING: This module should not be used by end-users directly because it
allows access to the internalHandle of a resource which enables them to
close the resource manually, which will defeat the safety-guarantees that
this package provides!
This module should only be used by library authors wishing to allow their
end-users to open their resources in a region.
To create a module or library that allows your users to open your resources
in a region, the only thing you have to do is to define an instance for
Resource for your type of resource.
Make sure not to re-export anything from this module. Either re-export things
from Control.Monad.Trans.Region or tell your users to import that module
|class Resource resource where||Source|
Class of scarce resources. A scarce resource is a resource that only one
user can use at a time. (like a file, memory pointer or USB device for
Because of the scarcity, these resources need to be opened to grant temporary
sole access to the resource. When the resource is no longer needed it should be
closed a.s.a.p to grant others access to the resource.
|data Handle resource :: *||Source|
Get the internal handle from the given regional handle.
Warning: This function should not be exported to or used by end-users
because it allows them to close the handle manually, which will defeat the
safety-guarantees that this package provides!
Tip: If you enable the ViewPatterns language extension you can use
internalHandle as a view-pattern as in the following example from the
resetDevice :: (pr `ParentOf` cr, MonadIO cr)
-> RegionalHandle USB.Device pr -> cr ()
resetDevice (internalHandle -> (DeviceHandle ...)) = ...
|Modify the internal handle from the given regional handle.
|Produced by Haddock version 2.6.0|