Module

Data.Function.Sub

Package
purescript-substructural
Repository
rightfold/purescript-substructural

#Sub Source

data Sub :: Type -> Type -> Type

A function that will not copy or discard references to its argument, unless it is allowed to by a Clone or Drop instance.

Currently there is no syntax for Sub literals. You can create Sub values only through combinators (mainly <<<) and the FFI (normal pure unary JavaScript function).

Instances

#type (-*) Source

Operator alias for Data.Function.Sub.Sub (right-associative / precedence 4)

#runShared Source

runShared :: forall b a. Shared a => Shared b => (a -* b) -> a -> b

Run a function over shared values.

#liftShared Source

liftShared :: forall b a. Shared a => Shared b => (a -> b) -> a -* b

Lift a function over shared values into a Sub.

#Clone Source

class Clone a  where

Values which can be cloned. Instances of Clone must satisfy the following laws:

  • Clone: fst' <<< clone = snd' <<< clone = id

Members

Instances

#Drop Source

class Drop a  where

Values which can be dropped.

Members

Instances

#Shared Source

class (Clone a, Drop a) <= Shared a 

Values for which multiple live references can exist. Clone and Drop instances may be no-ops.

Instances

#unsafeClone Source

unsafeClone :: forall a. a -* (Tuple a a)

Unsafely clone a value.

#unsafeDrop Source

unsafeDrop :: forall a. a -* Unit

Unsafely drop a value.

#Borrow Source

data Borrow :: Type -> Type

A Borrow is a reference to a value. When a borrow to a value is live, the value cannot be accessed unless it is Shared. Some functions take borrows to avoid inconvenient tupling.

Instances

#borrow Source

borrow :: forall b a. Shared b => ((Borrow a) -* b) -> a -* (Tuple a b)

Borrow a value during the execution of a function.