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

Data.Unrestricted.Internal.Ur

Synopsis

Documentation

data Ur a where Source #

Ur a represents unrestricted values of type a in a linear context. The key idea is that because the contructor holds a with a regular arrow, a function that uses Ur a linearly can use a however it likes. > someLinear :: Ur a %1-> (a,a) > someLinear (Ur a) = (a,a)

Constructors

Ur :: a -> Ur a 

Instances

Instances details
Functor Ur Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

fmap :: (a -> b) -> Ur a -> Ur b #

(<$) :: a -> Ur b -> Ur a #

Applicative Ur Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

pure :: a -> Ur a #

(<*>) :: Ur (a -> b) -> Ur a -> Ur b #

liftA2 :: (a -> b -> c) -> Ur a -> Ur b -> Ur c #

(*>) :: Ur a -> Ur b -> Ur b #

(<*) :: Ur a -> Ur b -> Ur a #

Foldable Ur Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

fold :: Monoid m => Ur m -> m #

foldMap :: Monoid m => (a -> m) -> Ur a -> m #

foldMap' :: Monoid m => (a -> m) -> Ur a -> m #

foldr :: (a -> b -> b) -> b -> Ur a -> b #

foldr' :: (a -> b -> b) -> b -> Ur a -> b #

foldl :: (b -> a -> b) -> b -> Ur a -> b #

foldl' :: (b -> a -> b) -> b -> Ur a -> b #

foldr1 :: (a -> a -> a) -> Ur a -> a #

foldl1 :: (a -> a -> a) -> Ur a -> a #

toList :: Ur a -> [a] #

null :: Ur a -> Bool #

length :: Ur a -> Int #

elem :: Eq a => a -> Ur a -> Bool #

maximum :: Ord a => Ur a -> a #

minimum :: Ord a => Ur a -> a #

sum :: Num a => Ur a -> a #

product :: Num a => Ur a -> a #

Traversable Ur Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

traverse :: Applicative f => (a -> f b) -> Ur a -> f (Ur b) #

sequenceA :: Applicative f => Ur (f a) -> f (Ur a) #

mapM :: Monad m => (a -> m b) -> Ur a -> m (Ur b) #

sequence :: Monad m => Ur (m a) -> m (Ur a) #

Functor Ur Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

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

Applicative Ur Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

pure :: a -> Ur a Source #

(<*>) :: Ur (a %1 -> b) %1 -> Ur a %1 -> Ur b Source #

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

Storable a => Storable (Ur a) Source # 
Instance details

Defined in Foreign.Marshal.Pure

Methods

sizeOf :: Ur a -> Int #

alignment :: Ur a -> Int #

peekElemOff :: Ptr (Ur a) -> Int -> IO (Ur a) #

pokeElemOff :: Ptr (Ur a) -> Int -> Ur a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Ur a) #

pokeByteOff :: Ptr b -> Int -> Ur a -> IO () #

peek :: Ptr (Ur a) -> IO (Ur a) #

poke :: Ptr (Ur a) -> Ur a -> IO () #

Consumable (Ur a) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

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

Dupable (Ur a) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

dupV :: forall (n :: Nat). KnownNat n => Ur a %1 -> V n (Ur a) Source #

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

Movable (Ur a) Source # 
Instance details

Defined in Data.Unrestricted.Internal.Instances

Methods

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

Eq a => Eq (Ur a) Source # 
Instance details

Defined in Data.Ord.Linear.Internal.Eq

Methods

(==) :: Ur a %1 -> Ur a %1 -> Bool Source #

(/=) :: Ur a %1 -> Ur a %1 -> Bool Source #

Ord a => Ord (Ur a) Source # 
Instance details

Defined in Data.Ord.Linear.Internal.Ord

Methods

compare :: Ur a %1 -> Ur a %1 -> Ordering Source #

(<=) :: Ur a %1 -> Ur a %1 -> Bool Source #

(<) :: Ur a %1 -> Ur a %1 -> Bool Source #

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

(>=) :: Ur a %1 -> Ur a %1 -> Bool Source #

KnownRepresentable a => KnownRepresentable (Ur a) Source # 
Instance details

Defined in Foreign.Marshal.Pure

Methods

storable :: Dict (Storable (Ur a))

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

Get an a out of an Ur a. If you call this function on a linearly bound Ur a, then the a you get out has to be used linearly, for example:

restricted :: Ur a %1-> b
restricted x = f (unur x)
  where
    -- f __must__ be linear
    f :: a %1-> b
    f x = ...

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

Lifts a function on a linear Ur a.

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

Lifts a function to work on two linear Ur a.