pure-borrow
Safe HaskellNone
LanguageGHC2021

Control.Monad.Borrow.Pure.BO.Unsafe

Description

This module provides unsafe internals of Control.Monad.Borrow.Pure. These are not meant to be used by end-users, so generally YOU SHOULD NOT import this module, and import Control.Monad.Borrow.Pure instead.

This module is meant for library authors who want to build a new API on top of Pure Borrow. This module provides internals of BO and Alias, which can break the soundness guarded by the role system. We STRONGLY recommend to you to import only the needed parts of the definitions, and not to import everything or qualified.

Synopsis

Internal definitions and utilities of core types.

newtype BO (α :: Lifetime) a Source #

Computation returning a that can be performed only during the lifetime α. Internally it is a linear ST monad.

Constructors

BO (State# (ForBO α) %1 -> (# State# (ForBO α), a #)) 

Instances

Instances details
(α >= β, a <: b) => (BO α a :: Type) <: (BO β b :: Type) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

subtype :: SubtypeWitness (BO α a) (BO β b) Source #

Applicative (BO α) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

pure :: a %1 -> BO α a #

(<*>) :: BO α (a %1 -> b) %1 -> BO α a %1 -> BO α b #

liftA2 :: (a %1 -> b %1 -> c) %1 -> BO α a %1 -> BO α b %1 -> BO α c #

Functor (BO α) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

fmap :: (a %1 -> b) %1 -> BO α a %1 -> BO α b #

Monad (BO α) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

(>>=) :: BO α a %1 -> (a %1 -> BO α b) %1 -> BO α b #

(>>) :: BO α () %1 -> BO α a %1 -> BO α a #

Applicative (BO α) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

pure :: a -> BO α a #

(<*>) :: BO α (a %1 -> b) %1 -> BO α a %1 -> BO α b #

liftA2 :: (a %1 -> b %1 -> c) -> BO α a %1 -> BO α b %1 -> BO α c #

Functor (BO α) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

fmap :: (a %1 -> b) -> BO α a %1 -> BO α b #

Monoid w => Monoid (BO α w) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

mempty :: BO α w #

Semigroup w => Semigroup (BO α w) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

(<>) :: BO α w %1 -> BO α w %1 -> BO α w #

newtype Alias (ak :: AliasKind) (α :: Lifetime) a Source #

Alias of kind ak to a resource of type a.

Constructors

UnsafeAlias a 

Instances

Instances details
Reborrowable Mut Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.Experimental.Reborrowable

Methods

locally' :: forall (α :: Lifetime) a (α' :: Lifetime) r. Mut α a %1 -> (forall (β :: Lifetime). Mut/\ α) a %1 -> BO/\ α') (After β r)) %1 -> BO α' (r, Mut α a) Source #

Reborrowable Share Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.Experimental.Reborrowable

Methods

locally' :: forall (α :: Lifetime) a (α' :: Lifetime) r. Share α a %1 -> (forall (β :: Lifetime). Share/\ α) a %1 -> BO/\ α') (After β r)) %1 -> BO α' (r, Share α a) Source #

(α <= β, a <: b) => (Lend α a :: Type) <: (Lend β b :: Type) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

subtype :: SubtypeWitness (Lend α a) (Lend β b) Source #

(α >= β, a <: b, b <: a) => (Mut α a :: Type) <: (Mut β b :: Type) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

subtype :: SubtypeWitness (Mut α a) (Mut β b) Source #

(α >= β, a <: b) => (Share α a :: Type) <: (Share β b :: Type) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

subtype :: SubtypeWitness (Share α a) (Share β b) Source #

bk ~ 'Mut => LinearOnly (Borrow bk α a :: Type) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Consumable (Borrow bk α a) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

consume :: Borrow bk α a %1 -> () #

k ~ 'Borrow 'Share => Dupable (Alias k α a) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

dupR :: Alias k α a %1 -> Replicator (Alias k α a) #

dup2 :: Alias k α a %1 -> (Alias k α a, Alias k α a) #

k ~ 'Borrow 'Share => Movable (Alias k α a) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

move :: Alias k α a %1 -> Ur (Alias k α a) #

Affine (Borrow bk α a) Source # 
Instance details

Defined in Control.Monad.Borrow.Pure.BO.Internal

Methods

aff :: Borrow bk α a %1 -> Aff (Borrow bk α a) Source #

unsafeUnalias :: forall (ak :: AliasKind) (α :: Lifetime) a. Alias ak α a %1 -> a Source #

unsafeMapAlias :: forall a b (ak :: AliasKind) (α :: Lifetime). (a %1 -> b) %1 -> Alias ak α a %1 -> Alias ak α b Source #

Conversions from/to BO monad.

unsafeBOToLinIO :: forall (α :: Lifetime) a. BO α a %1 -> IO a Source #

Unsafely converts a BO computation to linear IO.

unsafeLinIOToBO :: forall a (α :: Lifetime). IO a %1 -> BO α a Source #

Unsafely performs a linear IO computation in BO monad.

This is really, really unsafe. If you don't know what you are doing, you MUST NOT use this function, otherwise you can break purity in a hard way.

unsafeBOToSystemIO :: forall (α :: Lifetime) a. BO α a %1 -> IO a Source #

Unsafely performs a BO in the standard, non-linear IO monad.

unsafeSystemIOToBO :: forall a (α :: Lifetime). IO a %1 -> BO α a Source #

Unsafely performs a standard, non-linear IO computation in BO monad.

This is really, really unsafe. If you don't know what you are doing, you MUST NOT use this function, otherwise you can break purity in a hard way.

unsafeSTToBO :: forall s a (α :: Lifetime). ST s a %1 -> BO α a Source #

Unsafely peforms a ST computation in BO monad.

unsafeBOToST :: forall (α :: Lifetime) a s. BO α a %1 -> ST s a Source #

Unsafely peforms a BO computation in ST monad.

This is really unsafe. If you don't know what you are doing, you MUST NOT use this function, otherwise you can break purity in a hard way.

unsafeUnBO :: forall (α :: Lifetime) a. BO α a %1 -> State# (ForBO α) %1 -> (# State# (ForBO α), a #) Source #