linear-base-0.1.0: Standard library for linear types.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Unrestricted.Internal.Movable

Contents

Synopsis

Movable

class Dupable a => Movable a where Source #

Use Movable a to represent a type which can be used many times even when given linearly. Simple data types such as Bool or [] are Movable. Though, bear in mind that this typically induces a deep copy of the value.

Formally, Movable a is the class of coalgebras of the Ur comonad. That is

  • unur (move x) = x
  • @move @(Ur a) (move @a x) = fmap (move @a) $ move @a x

Additionally, a Movable instance must be compatible with its Dupable parent instance. That is:

  • case move x of {Ur _ -> ()} = consume x
  • case move x of {Ur x -> (x, x)} = dup2 x

Methods

move :: a %1 -> Ur a Source #

Instances

Instances details
Movable Bool Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Bool %1 -> Ur Bool Source #

Movable Char Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Char %1 -> Ur Char Source #

Movable Double Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Double %1 -> Ur Double Source #

Movable Int Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Int %1 -> Ur Int Source #

Movable Ordering Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Ordering %1 -> Ur Ordering Source #

Movable () Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: () %1 -> Ur () Source #

Movable Any Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Any %1 -> Ur Any Source #

Movable All Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: All %1 -> Ur All Source #

Movable a => Movable [a] Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: [a] %1 -> Ur [a] Source #

Movable a => Movable (Maybe a) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Maybe a %1 -> Ur (Maybe a) Source #

Movable a => Movable (Sum a) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Sum a %1 -> Ur (Sum a) Source #

Movable a => Movable (Product a) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Product a %1 -> Ur (Product a) Source #

Movable a => Movable (NonEmpty a) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: NonEmpty a %1 -> Ur (NonEmpty a) Source #

Movable (Ur a) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Ur a %1 -> Ur (Ur a) Source #

(Movable a, Movable b) => Movable (Either a b) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: Either a b %1 -> Ur (Either a b) Source #

(Movable a, Movable b) => Movable (a, b) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: (a, b) %1 -> Ur (a, b) Source #

(Movable a, Movable b, Movable c) => Movable (a, b, c) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

move :: (a, b, c) %1 -> Ur (a, b, c) Source #