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

Data.Unrestricted.Linear.Internal.UrT

UrT creates non-linear monads from linear monads. The effect of UrT m is the same as the effect of m with the same linearity. It's just that the a in m a must be used linearly, but the a in UrT m a can be used unrestricted. Since UrT is a regular monad it can be used with the regular do-notation.

A good use case is when you have a linear resource, then you can use UrT (State s) a to manipulate the resource linearly with regular do-notation.

  • 1 type
  • 3 values
newtypenewtype UrT (m :: Type -> Type) a
#

UrT transforms linear control monads to non-linear monads.

  • UrT (State s) a is a non-linear monad with linear state.

Constructors

Instances3Monad, Functor, Applicative
  • Monad m => Monad (UrT m)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.UrT
  • Functor m => Functor (UrT m)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.UrT
  • Applicative m => Applicative (UrT m)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.UrT
valuerunUrT :: UrT m a %1 -> m (Ur a)
#

Linearly unwrap the UrT newtype wrapper.

valueliftUrT :: (Movable a, Functor m) => m a %1 -> UrT m a
#

Lift a computation to the UrT monad, provided that the type a can be used unrestricted.

valueevalUrT :: Functor m => UrT m a %1 -> m a
#

Extract the inner computation linearly, the inverse of liftUrT.

evalUrT (liftUrT m) = m