HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelinear-base-0.4.0Haskell2010

System.IO.Resource.Linear.Internal

  • 5 types
  • 19 values
newtypenewtype ReleaseMap
#

Constructors

newtypenewtype RIO a
#

The resource-aware I/O monad. This monad guarantees that acquired resources are always released.

Constructors

Instances7Monad, Functor, Applicative, Monoid, Semigroup, …
  • Applicative RIODefined in linear-base-0.4.0 · System.IO.Resource.Linear.Internal
  • Functor RIODefined in linear-base-0.4.0 · System.IO.Resource.Linear.Internal
  • Monad RIODefined in linear-base-0.4.0 · System.IO.Resource.Linear.Internal
  • Functor RIODefined in linear-base-0.4.0 · System.IO.Resource.Linear.Internal
  • Applicative RIODefined in linear-base-0.4.0 · System.IO.Resource.Linear.Internal
  • Monoid a => Monoid (RIO a)Defined in linear-base-0.4.0 · System.IO.Resource.Linear.Internal
  • Semigroup a => Semigroup (RIO a)Defined in linear-base-0.4.0 · System.IO.Resource.Linear.Internal
valueunRIO :: RIO a %1 -> IORef ReleaseMap -> IO a
#
valuerun :: RIO (Ur a) -> IO a
#

Take a RIO computation with a value a that is not linearly bound and make it a System.IO computation.

valueunsafeFromSystemIO :: IO a %1 -> RIO a
#

Should not be applied to a function that acquires or releases resources.

datadata Resource a where
#

The type of system resources. To create and use resources, you need to use the API since the constructor is not released.

Constructors

valueunsafeAcquire :: IO (Ur a) -> (a -> IO ()) -> RIO (Resource a)
#

Given a resource in the System.IO.Linear.IO monad, and given a function to release that resource, provides that resource in the RIO monad. For example, releasing a Handle from System.IO would be done with fromSystemIO hClose. Because this release function is an input, and could be wrong, this function is unsafe.

valueunsafeFromSystemIOResource
  1. :: a -> IO b
  2. -> Resource a
  3. -> RIO (Ur b, Resource a)
#

Given a System.IO computation on an unsafe resource, lift it to RIO computaton on the acquired resource. That is function of type a -> IO b turns into a function of type Resource a %1-> RIO (Ur b) along with threading the Resource a.

unsafeFromSystemIOResource is only safe to use on actions which do not release the resource.

Note that the result b can be used non-linearly.