| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Prelude.Linear
Description
This module provides a replacement for Prelude with
support for linear programming via linear versions of
standard data types, functions and type classes.
A simple example:
>>>:set -XLinearTypes>>>:set -XNoImplicitPrelude>>>import Prelude.Linear>>>:{boolToInt :: Bool %1-> Int boolToInt False = 0 boolToInt True = 1 :}
>>>:{makeInt :: Either Int Bool %1-> Int makeInt = either id boolToInt :}
This module is designed to be imported unqualifed.
Synopsis
- module Data.Bool.Linear
- data Char
- module Data.Maybe.Linear
- module Data.Either.Linear
- module Prelude.Linear.Internal.TypeEq
- fst :: (a, b) -> a
- snd :: (a, b) -> b
- curry :: forall a b c (p :: Multiplicity) (q :: Multiplicity). ((a, b) %p -> c) %q -> a %p -> b %p -> c
- uncurry :: forall a b c (p :: Multiplicity) (q :: Multiplicity). (a %p -> b %p -> c) %q -> (a, b) %p -> c
- module Data.Ord.Linear
- class Enum a where
- succ :: a -> a
- pred :: a -> a
- toEnum :: Int -> a
- fromEnum :: a -> Int
- enumFrom :: a -> [a]
- enumFromThen :: a -> a -> [a]
- enumFromTo :: a -> a -> [a]
- enumFromThenTo :: a -> a -> a -> [a]
- class Bounded a where
- data Int
- data Integer
- data Float
- data Double
- type Rational = Ratio Integer
- data Word
- module Data.Num.Linear
- class (Num a, Ord a) => Real a where
- toRational :: a -> Rational
- class (Real a, Enum a) => Integral a where
- class Fractional a => Floating a where
- class Num a => Fractional a where
- (/) :: a -> a -> a
- recip :: a -> a
- fromRational :: Rational -> a
- class (Real a, Fractional a) => RealFrac a where
- class (RealFrac a, Floating a) => RealFloat a where
- floatRadix :: a -> Integer
- floatDigits :: a -> Int
- floatRange :: a -> (Int, Int)
- decodeFloat :: a -> (Integer, Int)
- encodeFloat :: Integer -> Int -> a
- exponent :: a -> Int
- significand :: a -> a
- scaleFloat :: Int -> a -> a
- isNaN :: a -> Bool
- isInfinite :: a -> Bool
- isDenormalized :: a -> Bool
- isNegativeZero :: a -> Bool
- isIEEE :: a -> Bool
- atan2 :: a -> a -> a
- subtract :: Num a => a -> a -> a
- even :: Integral a => a -> Bool
- odd :: Integral a => a -> Bool
- gcd :: Integral a => a -> a -> a
- lcm :: Integral a => a -> a -> a
- (^) :: (Num a, Integral b) => a -> b -> a
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- fromIntegral :: (Integral a, Num b) => a -> b
- realToFrac :: (Real a, Fractional b) => a -> b
- (<*) :: (Applicative f, Consumable b) => f a %1 -> f b %1 -> f a
- module Data.Monoid.Linear
- id :: forall a (q :: Multiplicity). a %q -> a
- const :: forall a b (q :: Multiplicity). a %q -> b -> a
- (.) :: forall b c a (q :: Multiplicity) (m :: Multiplicity) (n :: Multiplicity). (b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c
- flip :: forall a b c (q :: Multiplicity) (p :: Multiplicity) (r :: Multiplicity). (a %p -> b %q -> c) %r -> b %q -> a %p -> c
- ($) :: forall a b (p :: Multiplicity) (q :: Multiplicity). (a %p -> b) %q -> a %p -> b
- (&) :: forall a b (p :: Multiplicity) (q :: Multiplicity). a %p -> (a %p -> b) %q -> b
- until :: (a -> Bool) -> (a -> a) -> a -> a
- error :: HasCallStack => [Char] -> a
- errorWithoutStackTrace :: [Char] -> a
- undefined :: HasCallStack => a
- seq :: forall a b (q :: Multiplicity). a -> b %q -> b
- ($!) :: forall a b (p :: Multiplicity) (q :: Multiplicity). (a %p -> b) %q -> a %p -> b
- module Data.List.Linear
- module Data.String
- type ShowS = String -> String
- class Show a where
- shows :: Show a => a -> ShowS
- showChar :: Char -> ShowS
- showString :: String -> ShowS
- showParen :: Bool -> ShowS -> ShowS
- type ReadS a = String -> [(a, String)]
- class Read a where
- reads :: Read a => ReadS a
- readParen :: Bool -> ReadS a -> ReadS a
- read :: Read a => String -> a
- lex :: ReadS String
- data IO a
- putChar :: Char -> IO ()
- putStr :: String -> IO ()
- putStrLn :: String -> IO ()
- print :: Show a => a -> IO ()
- getChar :: IO Char
- getLine :: IO String
- getContents :: IO String
- interact :: (String -> String) -> IO ()
- type FilePath = String
- readFile :: FilePath -> IO String
- writeFile :: FilePath -> String -> IO ()
- appendFile :: FilePath -> String -> IO ()
- readIO :: Read a => String -> IO a
- readLn :: Read a => IO a
- data Ur a where
- unur :: Ur a %1 -> a
- class Consumable a where
- consume :: a %1 -> ()
- class Consumable a => Dupable a where
- dupR :: a %1 -> Replicator a
- dup2 :: a %1 -> (a, a)
- class Dupable a => Movable a where
- lseq :: Consumable a => a %1 -> b %1 -> b
- dup :: Dupable a => a %1 -> (a, a)
- dup3 :: Dupable a => a %1 -> (a, a, a)
- forget :: (a %1 -> b) %1 -> a -> b
Standard Types, Classes and Related Functions
Basic data types
module Data.Bool.Linear
The character type Char represents Unicode codespace
and its elements are code points as in definitions
D9 and D10 of the Unicode Standard.
Character literals in Haskell are single-quoted: 'Q', 'Я' or 'Ω'.
To represent a single quote itself use '\'', and to represent a backslash
use '\\'. The full grammar can be found in the section 2.6 of the
Haskell 2010 Language Report.
To specify a character by its code point one can use decimal, hexadecimal
or octal notation: '\65', '\x41' and '\o101' are all alternative forms
of 'A'. The largest code point is '\x10ffff'.
There is a special escape syntax for ASCII control characters:
| Escape | Alternatives | Meaning |
|---|---|---|
'\NUL' | '\0' | null character |
'\SOH' | '\1' | start of heading |
'\STX' | '\2' | start of text |
'\ETX' | '\3' | end of text |
'\EOT' | '\4' | end of transmission |
'\ENQ' | '\5' | enquiry |
'\ACK' | '\6' | acknowledge |
'\BEL' | '\7', '\a' | bell (alert) |
'\BS' | '\8', '\b' | backspace |
'\HT' | '\9', '\t' | horizontal tab |
'\LF' | '\10', '\n' | line feed (new line) |
'\VT' | '\11', '\v' | vertical tab |
'\FF' | '\12', '\f' | form feed |
'\CR' | '\13', '\r' | carriage return |
'\SO' | '\14' | shift out |
'\SI' | '\15' | shift in |
'\DLE' | '\16' | data link escape |
'\DC1' | '\17' | device control 1 |
'\DC2' | '\18' | device control 2 |
'\DC3' | '\19' | device control 3 |
'\DC4' | '\20' | device control 4 |
'\NAK' | '\21' | negative acknowledge |
'\SYN' | '\22' | synchronous idle |
'\ETB' | '\23' | end of transmission block |
'\CAN' | '\24' | cancel |
'\EM' | '\25' | end of medium |
'\SUB' | '\26' | substitute |
'\ESC' | '\27' | escape |
'\FS' | '\28' | file separator |
'\GS' | '\29' | group separator |
'\RS' | '\30' | record separator |
'\US' | '\31' | unit separator |
'\SP' | '\32', ' ' | space |
'\DEL' | '\127' | delete |
Instances
| Data Char | Since: base-4.0.0.0 | ||||
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Char -> c Char # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Char # dataTypeOf :: Char -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Char) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Char) # gmapT :: (forall b. Data b => b -> b) -> Char -> Char # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Char -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Char -> r # gmapQ :: (forall d. Data d => d -> u) -> Char -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Char -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Char -> m Char # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Char -> m Char # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Char -> m Char # | |||||
| Storable Char | Since: base-2.1 | ||||
Defined in Foreign.Storable | |||||
| Bounded Char | Since: base-2.1 | ||||
| Enum Char | Since: base-2.1 | ||||
| Ix Char | Since: base-2.1 | ||||
| Read Char | Since: base-2.1 | ||||
| Show Char | Since: base-2.1 | ||||
| IsChar Char | Since: base-2.1 | ||||
| PrintfArg Char | Since: base-2.1 | ||||
Defined in Text.Printf | |||||
| NFData Char | |||||
Defined in Control.DeepSeq | |||||
| Eq Char | |||||
| Ord Char | |||||
| Hashable Char | |||||
Defined in Data.Hashable.Class | |||||
| Eq Char Source # | |||||
| Ord Char Source # | |||||
| Consumable Char Source # | |||||
Defined in Data.Unrestricted.Linear.Internal.Consumable | |||||
| Dupable Char Source # | |||||
| Movable Char Source # | |||||
| Prim Char | |||||
Defined in Data.Primitive.Types Methods sizeOfType# :: Proxy Char -> Int# # alignmentOfType# :: Proxy Char -> Int# # alignment# :: Char -> Int# # indexByteArray# :: ByteArray# -> Int# -> Char # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Char #) # writeByteArray# :: MutableByteArray# s -> Int# -> Char -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Char -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Char # readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Char #) # writeOffAddr# :: Addr# -> Int# -> Char -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Char -> State# s -> State# s # | |||||
| Uniform Char | |||||
Defined in System.Random.Internal Methods uniformM :: StatefulGen g m => g -> m Char # | |||||
| UniformRange Char | |||||
| Unbox Char | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| TestCoercion SChar | Since: base-4.18.0.0 | ||||
Defined in GHC.TypeLits | |||||
| TestEquality SChar | Since: base-4.18.0.0 | ||||
Defined in GHC.TypeLits | |||||
| Lift Char | |||||
| Vector Vector Char | |||||
Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: Mutable Vector s Char -> ST s (Vector Char) basicUnsafeThaw :: Vector Char -> ST s (Mutable Vector s Char) basicLength :: Vector Char -> Int basicUnsafeSlice :: Int -> Int -> Vector Char -> Vector Char basicUnsafeIndexM :: Vector Char -> Int -> Box Char basicUnsafeCopy :: Mutable Vector s Char -> Vector Char -> ST s () | |||||
| MVector MVector Char | |||||
Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s Char -> Int basicUnsafeSlice :: Int -> Int -> MVector s Char -> MVector s Char basicOverlaps :: MVector s Char -> MVector s Char -> Bool basicUnsafeNew :: Int -> ST s (MVector s Char) basicInitialize :: MVector s Char -> ST s () basicUnsafeReplicate :: Int -> Char -> ST s (MVector s Char) basicUnsafeRead :: MVector s Char -> Int -> ST s Char basicUnsafeWrite :: MVector s Char -> Int -> Char -> ST s () basicClear :: MVector s Char -> ST s () basicSet :: MVector s Char -> Char -> ST s () basicUnsafeCopy :: MVector s Char -> MVector s Char -> ST s () basicUnsafeMove :: MVector s Char -> MVector s Char -> ST s () basicUnsafeGrow :: MVector s Char -> Int -> ST s (MVector s Char) | |||||
| Generic1 (URec Char :: k -> Type) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Foldable (UChar :: Type -> Type) | Since: base-4.9.0.0 | ||||
Defined in Data.Foldable Methods fold :: Monoid m => UChar m -> m # foldMap :: Monoid m => (a -> m) -> UChar a -> m # foldMap' :: Monoid m => (a -> m) -> UChar a -> m # foldr :: (a -> b -> b) -> b -> UChar a -> b # foldr' :: (a -> b -> b) -> b -> UChar a -> b # foldl :: (b -> a -> b) -> b -> UChar a -> b # foldl' :: (b -> a -> b) -> b -> UChar a -> b # foldr1 :: (a -> a -> a) -> UChar a -> a # foldl1 :: (a -> a -> a) -> UChar a -> a # elem :: Eq a => a -> UChar a -> Bool # maximum :: Ord a => UChar a -> a # minimum :: Ord a => UChar a -> a # | |||||
| Traversable (UChar :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Functor (UChar :: Type -> Type) Source # | |||||
| GTraversable (UChar :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable Methods gtraverse :: Applicative f => (a %1 -> f b) -> UChar a %1 -> Curried (Yoneda f) (Yoneda f) (UChar b) | |||||
| Traversable (UChar :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable | |||||
| Functor (URec Char :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Generic (URec Char p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Show (URec Char p) | Since: base-4.9.0.0 | ||||
| Eq (URec Char p) | Since: base-4.9.0.0 | ||||
| Ord (URec Char p) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep Char | |||||
| newtype Vector Char | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| data URec Char (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 | ||||
| newtype MVector s Char | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| type Compare (a :: Char) (b :: Char) | |||||
Defined in Data.Type.Ord | |||||
| type Rep1 (URec Char :: k -> Type) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep1 (URec Char :: k -> Type) | |||||
Defined in Generics.Linear.Instances.Base | |||||
| type Rep (URec Char p) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep (URec Char p) | |||||
Defined in Generics.Linear.Instances.Base | |||||
module Data.Maybe.Linear
module Data.Either.Linear
Tuples
curry :: forall a b c (p :: Multiplicity) (q :: Multiplicity). ((a, b) %p -> c) %q -> a %p -> b %p -> c Source #
uncurry :: forall a b c (p :: Multiplicity) (q :: Multiplicity). (a %p -> b %p -> c) %q -> (a, b) %p -> c Source #
Basic type classes
module Data.Ord.Linear
Class Enum defines operations on sequentially ordered types.
The enumFrom... methods are used in Haskell's translation of
arithmetic sequences.
Instances of Enum may be derived for any enumeration type (types
whose constructors have no fields). The nullary constructors are
assumed to be numbered left-to-right by fromEnum from 0 through n-1.
See Chapter 10 of the Haskell Report for more details.
For any type that is an instance of class Bounded as well as Enum,
the following should hold:
- The calls
andsuccmaxBoundshould result in a runtime error.predminBound fromEnumandtoEnumshould give a runtime error if the result value is not representable in the result type. For example,is an error.toEnum7 ::BoolenumFromandenumFromThenshould be defined with an implicit bound, thus:
enumFrom x = enumFromTo x maxBound
enumFromThen x y = enumFromThenTo x y bound
where
bound | fromEnum y >= fromEnum x = maxBound
| otherwise = minBoundMethods
the successor of a value. For numeric types, succ adds 1.
the predecessor of a value. For numeric types, pred subtracts 1.
Convert from an Int.
Convert to an Int.
It is implementation-dependent what fromEnum returns when
applied to a value that is too large to fit in an Int.
Used in Haskell's translation of [n..] with [n..] = enumFrom n,
a possible implementation being enumFrom n = n : enumFrom (succ n).
For example:
enumFrom 4 :: [Integer] = [4,5,6,7,...]
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: Int]
enumFromThen :: a -> a -> [a] #
Used in Haskell's translation of [n,n'..]
with [n,n'..] = enumFromThen n n', a possible implementation being
enumFromThen n n' = n : n' : worker (f x) (f x n'),
worker s v = v : worker s (s v), x = fromEnum n' - fromEnum n and
f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y
For example:
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: Int]
enumFromTo :: a -> a -> [a] #
Used in Haskell's translation of [n..m] with
[n..m] = enumFromTo n m, a possible implementation being
enumFromTo n m
| n <= m = n : enumFromTo (succ n) m
| otherwise = [].
For example:
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumFromThenTo :: a -> a -> a -> [a] #
Used in Haskell's translation of [n,n'..m] with
[n,n'..m] = enumFromThenTo n n' m, a possible implementation
being enumFromThenTo n n' m = worker (f x) (c x) n m,
x = fromEnum n' - fromEnum n, c x = bool (>=) ((x 0)
f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y and
worker s c v m
| c v m = v : worker s c (s v) m
| otherwise = []
For example:
enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
Instances
The Bounded class is used to name the upper and lower limits of a
type. Ord is not a superclass of Bounded since types that are not
totally ordered may also have upper and lower bounds.
The Bounded class may be derived for any enumeration type;
minBound is the first constructor listed in the data declaration
and maxBound is the last.
Bounded may also be derived for single-constructor datatypes whose
constituent types are in Bounded.
Instances
| Bounded All | Since: base-2.1 |
| Bounded Any | Since: base-2.1 |
| Bounded CBool | |
| Bounded CChar | |
| Bounded CInt | |
| Bounded CIntMax | |
| Bounded CIntPtr | |
| Bounded CLLong | |
| Bounded CLong | |
| Bounded CPtrdiff | |
| Bounded CSChar | |
| Bounded CShort | |
| Bounded CSigAtomic | |
Defined in Foreign.C.Types | |
| Bounded CSize | |
| Bounded CUChar | |
| Bounded CUInt | |
| Bounded CUIntMax | |
| Bounded CUIntPtr | |
| Bounded CULLong | |
| Bounded CULong | |
| Bounded CUShort | |
| Bounded CWchar | |
| Bounded IntPtr | |
| Bounded WordPtr | |
| Bounded ByteOrder | Since: base-4.11.0.0 |
| Bounded Associativity | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Bounded DecidedStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Bounded SourceStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Bounded SourceUnpackedness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
| Bounded Int16 | Since: base-2.1 |
| Bounded Int32 | Since: base-2.1 |
| Bounded Int64 | Since: base-2.1 |
| Bounded Int8 | Since: base-2.1 |
| Bounded GeneralCategory | Since: base-2.1 |
Defined in GHC.Unicode | |
| Bounded Word16 | Since: base-2.1 |
| Bounded Word32 | Since: base-2.1 |
| Bounded Word64 | Since: base-2.1 |
| Bounded Word8 | Since: base-2.1 |
| Bounded CBlkCnt | |
| Bounded CBlkSize | |
| Bounded CClockId | |
| Bounded CDev | |
| Bounded CFsBlkCnt | |
| Bounded CFsFilCnt | |
| Bounded CGid | |
| Bounded CId | |
| Bounded CIno | |
| Bounded CKey | |
| Bounded CMode | |
| Bounded CNfds | |
| Bounded CNlink | |
| Bounded COff | |
| Bounded CPid | |
| Bounded CRLim | |
| Bounded CSocklen | |
| Bounded CSsize | |
| Bounded CTcflag | |
| Bounded CUid | |
| Bounded Fd | |
| Bounded Extension | |
| Bounded Ordering | Since: base-2.1 |
| Bounded I8 | |
| Bounded FPFormat | |
| Bounded () | Since: base-2.1 |
| Bounded Bool | Since: base-2.1 |
| Bounded Char | Since: base-2.1 |
| Bounded Int | Since: base-2.1 |
| Bounded Levity | Since: base-4.16.0.0 |
| Bounded VecCount | Since: base-4.10.0.0 |
| Bounded VecElem | Since: base-4.10.0.0 |
| Bounded Word | Since: base-2.1 |
| Bounded a => Bounded (And a) | Since: base-4.16 |
| Bounded a => Bounded (Iff a) | Since: base-4.16 |
| Bounded a => Bounded (Ior a) | Since: base-4.16 |
| Bounded a => Bounded (Xor a) | Since: base-4.16 |
| Bounded a => Bounded (Identity a) | Since: base-4.9.0.0 |
| Bounded a => Bounded (Down a) | Swaps Since: base-4.14.0.0 |
| Bounded a => Bounded (First a) | Since: base-4.9.0.0 |
| Bounded a => Bounded (Last a) | Since: base-4.9.0.0 |
| Bounded a => Bounded (Max a) | Since: base-4.9.0.0 |
| Bounded a => Bounded (Min a) | Since: base-4.9.0.0 |
| Bounded m => Bounded (WrappedMonoid m) | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
| Bounded a => Bounded (Dual a) | Since: base-2.1 |
| Bounded a => Bounded (Product a) | Since: base-2.1 |
| Bounded a => Bounded (Sum a) | Since: base-2.1 |
| Bounded a => Bounded (Solo a) | |
| Bounded (Proxy t) | Since: base-4.7.0.0 |
| (Bounded a, Bounded b) => Bounded (a, b) | Since: base-2.1 |
| Bounded a => Bounded (Const a b) | Since: base-4.9.0.0 |
| (Applicative f, Bounded a) => Bounded (Ap f a) | Since: base-4.12.0.0 |
| Coercible a b => Bounded (Coercion a b) | Since: base-4.7.0.0 |
| a ~ b => Bounded (a :~: b) | Since: base-4.7.0.0 |
| (Bounded a, Bounded b, Bounded c) => Bounded (a, b, c) | Since: base-2.1 |
| a ~~ b => Bounded (a :~~: b) | Since: base-4.10.0.0 |
| (Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d) | Since: base-2.1 |
| Bounded (f (g a)) => Bounded (Compose f g a) | Since: base-4.19.0.0 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a, b, c, d, e) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded (a, b, c, d, e, f) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g) => Bounded (a, b, c, d, e, f, g) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h) => Bounded (a, b, c, d, e, f, g, h) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i) => Bounded (a, b, c, d, e, f, g, h, i) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j) => Bounded (a, b, c, d, e, f, g, h, i, j) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k) => Bounded (a, b, c, d, e, f, g, h, i, j, k) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | Since: base-2.1 |
| (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n, Bounded o) => Bounded (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | Since: base-2.1 |
Numbers
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1].
The exact range for a given implementation can be determined by using
minBound and maxBound from the Bounded class.
Instances
| Data Int | Since: base-4.0.0.0 | ||||
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int -> c Int # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int # dataTypeOf :: Int -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int) # gmapT :: (forall b. Data b => b -> b) -> Int -> Int # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r # gmapQ :: (forall d. Data d => d -> u) -> Int -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Int -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int -> m Int # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int # | |||||
| Storable Int | Since: base-2.1 | ||||
Defined in Foreign.Storable | |||||
| Bits Int | Since: base-2.1 | ||||
Defined in GHC.Bits | |||||
| FiniteBits Int | Since: base-4.6.0.0 | ||||
Defined in GHC.Bits Methods finiteBitSize :: Int -> Int # countLeadingZeros :: Int -> Int # countTrailingZeros :: Int -> Int # | |||||
| Bounded Int | Since: base-2.1 | ||||
| Enum Int | Since: base-2.1 | ||||
| Ix Int | Since: base-2.1 | ||||
| Num Int | Since: base-2.1 | ||||
| Read Int | Since: base-2.1 | ||||
| Integral Int | Since: base-2.0.1 | ||||
| Real Int | Since: base-2.0.1 | ||||
Defined in GHC.Real Methods toRational :: Int -> Rational # | |||||
| Show Int | Since: base-2.1 | ||||
| PrintfArg Int | Since: base-2.1 | ||||
Defined in Text.Printf | |||||
| NFData Int | |||||
Defined in Control.DeepSeq | |||||
| Eq Int | |||||
| Ord Int | |||||
| Hashable Int | |||||
Defined in Data.Hashable.Class | |||||
| AddIdentity Int Source # | |||||
Defined in Data.Num.Linear | |||||
| Additive Int Source # | |||||
| AdditiveGroup Int Source # | |||||
| FromInteger Int Source # | |||||
Defined in Data.Num.Linear Methods fromInteger :: Integer %1 -> Int Source # | |||||
| MultIdentity Int Source # | |||||
Defined in Data.Num.Linear | |||||
| Multiplicative Int Source # | |||||
| Num Int Source # | |||||
| Ring Int Source # | |||||
Defined in Data.Num.Linear | |||||
| Semiring Int Source # | |||||
Defined in Data.Num.Linear | |||||
| Eq Int Source # | |||||
| Ord Int Source # | |||||
| Consumable Int Source # | |||||
Defined in Data.Unrestricted.Linear.Internal.Consumable | |||||
| Dupable Int Source # | |||||
| Movable Int Source # | |||||
| KnownRepresentable Int Source # | |||||
Defined in Foreign.Marshal.Pure.Internal | |||||
| Representable Int Source # | |||||
| Prim Int | |||||
Defined in Data.Primitive.Types Methods sizeOfType# :: Proxy Int -> Int# # alignmentOfType# :: Proxy Int -> Int# # alignment# :: Int -> Int# # indexByteArray# :: ByteArray# -> Int# -> Int # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int #) # writeByteArray# :: MutableByteArray# s -> Int# -> Int -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Int -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Int # readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int #) # writeOffAddr# :: Addr# -> Int# -> Int -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Int -> State# s -> State# s # | |||||
| Uniform Int | |||||
Defined in System.Random.Internal Methods uniformM :: StatefulGen g m => g -> m Int # | |||||
| UniformRange Int | |||||
| Unbox Int | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| Lift Int | |||||
| Vector Vector Int | |||||
Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: Mutable Vector s Int -> ST s (Vector Int) basicUnsafeThaw :: Vector Int -> ST s (Mutable Vector s Int) basicLength :: Vector Int -> Int basicUnsafeSlice :: Int -> Int -> Vector Int -> Vector Int basicUnsafeIndexM :: Vector Int -> Int -> Box Int basicUnsafeCopy :: Mutable Vector s Int -> Vector Int -> ST s () | |||||
| MVector MVector Int | |||||
Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s Int -> Int basicUnsafeSlice :: Int -> Int -> MVector s Int -> MVector s Int basicOverlaps :: MVector s Int -> MVector s Int -> Bool basicUnsafeNew :: Int -> ST s (MVector s Int) basicInitialize :: MVector s Int -> ST s () basicUnsafeReplicate :: Int -> Int -> ST s (MVector s Int) basicUnsafeRead :: MVector s Int -> Int -> ST s Int basicUnsafeWrite :: MVector s Int -> Int -> Int -> ST s () basicClear :: MVector s Int -> ST s () basicSet :: MVector s Int -> Int -> ST s () basicUnsafeCopy :: MVector s Int -> MVector s Int -> ST s () basicUnsafeMove :: MVector s Int -> MVector s Int -> ST s () basicUnsafeGrow :: MVector s Int -> Int -> ST s (MVector s Int) | |||||
| Generic1 (URec Int :: k -> Type) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Foldable (UInt :: Type -> Type) | Since: base-4.9.0.0 | ||||
Defined in Data.Foldable Methods fold :: Monoid m => UInt m -> m # foldMap :: Monoid m => (a -> m) -> UInt a -> m # foldMap' :: Monoid m => (a -> m) -> UInt a -> m # foldr :: (a -> b -> b) -> b -> UInt a -> b # foldr' :: (a -> b -> b) -> b -> UInt a -> b # foldl :: (b -> a -> b) -> b -> UInt a -> b # foldl' :: (b -> a -> b) -> b -> UInt a -> b # foldr1 :: (a -> a -> a) -> UInt a -> a # foldl1 :: (a -> a -> a) -> UInt a -> a # elem :: Eq a => a -> UInt a -> Bool # maximum :: Ord a => UInt a -> a # | |||||
| Traversable (UInt :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Functor (UInt :: Type -> Type) Source # | |||||
| GTraversable (UInt :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable Methods gtraverse :: Applicative f => (a %1 -> f b) -> UInt a %1 -> Curried (Yoneda f) (Yoneda f) (UInt b) | |||||
| Traversable (UInt :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable | |||||
| Functor (URec Int :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Generic (URec Int p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Show (URec Int p) | Since: base-4.9.0.0 | ||||
| Eq (URec Int p) | Since: base-4.9.0.0 | ||||
| Ord (URec Int p) | Since: base-4.9.0.0 | ||||
| type AsKnown Int Source # | |||||
Defined in Foreign.Marshal.Pure.Internal | |||||
| type Rep Int | |||||
| newtype Vector Int | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| data URec Int (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 | ||||
| newtype MVector s Int | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| type Rep1 (URec Int :: k -> Type) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep1 (URec Int :: k -> Type) | |||||
Defined in Generics.Linear.Instances.Base | |||||
| type Rep (URec Int p) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep (URec Int p) | |||||
Defined in Generics.Linear.Instances.Base | |||||
Arbitrary precision integers. In contrast with fixed-size integral types
such as Int, the Integer type represents the entire infinite range of
integers.
Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.
If the value is small (fit into an Int), IS constructor is used.
Otherwise IP and IN constructors are used to store a BigNat
representing respectively the positive or the negative value magnitude.
Instances
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
Instances
| Data Float | Since: base-4.0.0.0 | ||||
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Float -> c Float # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Float # dataTypeOf :: Float -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Float) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Float) # gmapT :: (forall b. Data b => b -> b) -> Float -> Float # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Float -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Float -> r # gmapQ :: (forall d. Data d => d -> u) -> Float -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Float -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Float -> m Float # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Float -> m Float # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Float -> m Float # | |||||
| Storable Float | Since: base-2.1 | ||||
| Floating Float | Since: base-2.1 | ||||
| RealFloat Float | Since: base-2.1 | ||||
Defined in GHC.Float Methods floatRadix :: Float -> Integer # floatDigits :: Float -> Int # floatRange :: Float -> (Int, Int) # decodeFloat :: Float -> (Integer, Int) # encodeFloat :: Integer -> Int -> Float # significand :: Float -> Float # scaleFloat :: Int -> Float -> Float # isInfinite :: Float -> Bool # isDenormalized :: Float -> Bool # isNegativeZero :: Float -> Bool # | |||||
| Read Float | Since: base-2.1 | ||||
| PrintfArg Float | Since: base-2.1 | ||||
Defined in Text.Printf | |||||
| NFData Float | |||||
Defined in Control.DeepSeq | |||||
| Eq Float | Note that due to the presence of
Also note that
| ||||
| Ord Float | See | ||||
| Hashable Float | Note: prior to The Since: hashable-1.3.0.0 | ||||
Defined in Data.Hashable.Class | |||||
| AddIdentity Float Source # | |||||
Defined in Data.Num.Linear | |||||
| Additive Float Source # | |||||
| AdditiveGroup Float Source # | |||||
| FromInteger Float Source # | |||||
Defined in Data.Num.Linear Methods fromInteger :: Integer %1 -> Float Source # | |||||
| MultIdentity Float Source # | |||||
Defined in Data.Num.Linear | |||||
| Multiplicative Float Source # | |||||
| Num Float Source # | |||||
| Ring Float Source # | |||||
Defined in Data.Num.Linear | |||||
| Semiring Float Source # | |||||
Defined in Data.Num.Linear | |||||
| Consumable Float Source # | |||||
Defined in Data.Unrestricted.Linear.Internal.Consumable | |||||
| Dupable Float Source # | |||||
| Movable Float Source # | |||||
| Prim Float | |||||
Defined in Data.Primitive.Types Methods sizeOfType# :: Proxy Float -> Int# # alignmentOfType# :: Proxy Float -> Int# # alignment# :: Float -> Int# # indexByteArray# :: ByteArray# -> Int# -> Float # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Float #) # writeByteArray# :: MutableByteArray# s -> Int# -> Float -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Float -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Float # readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Float #) # writeOffAddr# :: Addr# -> Int# -> Float -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Float -> State# s -> State# s # | |||||
| UniformRange Float | |||||
| Unbox Float | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| Lift Float | |||||
| Vector Vector Float | |||||
Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: Mutable Vector s Float -> ST s (Vector Float) basicUnsafeThaw :: Vector Float -> ST s (Mutable Vector s Float) basicLength :: Vector Float -> Int basicUnsafeSlice :: Int -> Int -> Vector Float -> Vector Float basicUnsafeIndexM :: Vector Float -> Int -> Box Float basicUnsafeCopy :: Mutable Vector s Float -> Vector Float -> ST s () | |||||
| MVector MVector Float | |||||
Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s Float -> Int basicUnsafeSlice :: Int -> Int -> MVector s Float -> MVector s Float basicOverlaps :: MVector s Float -> MVector s Float -> Bool basicUnsafeNew :: Int -> ST s (MVector s Float) basicInitialize :: MVector s Float -> ST s () basicUnsafeReplicate :: Int -> Float -> ST s (MVector s Float) basicUnsafeRead :: MVector s Float -> Int -> ST s Float basicUnsafeWrite :: MVector s Float -> Int -> Float -> ST s () basicClear :: MVector s Float -> ST s () basicSet :: MVector s Float -> Float -> ST s () basicUnsafeCopy :: MVector s Float -> MVector s Float -> ST s () basicUnsafeMove :: MVector s Float -> MVector s Float -> ST s () basicUnsafeGrow :: MVector s Float -> Int -> ST s (MVector s Float) | |||||
| Generic1 (URec Float :: k -> Type) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Foldable (UFloat :: Type -> Type) | Since: base-4.9.0.0 | ||||
Defined in Data.Foldable Methods fold :: Monoid m => UFloat m -> m # foldMap :: Monoid m => (a -> m) -> UFloat a -> m # foldMap' :: Monoid m => (a -> m) -> UFloat a -> m # foldr :: (a -> b -> b) -> b -> UFloat a -> b # foldr' :: (a -> b -> b) -> b -> UFloat a -> b # foldl :: (b -> a -> b) -> b -> UFloat a -> b # foldl' :: (b -> a -> b) -> b -> UFloat a -> b # foldr1 :: (a -> a -> a) -> UFloat a -> a # foldl1 :: (a -> a -> a) -> UFloat a -> a # elem :: Eq a => a -> UFloat a -> Bool # maximum :: Ord a => UFloat a -> a # minimum :: Ord a => UFloat a -> a # | |||||
| Traversable (UFloat :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Functor (UFloat :: Type -> Type) Source # | |||||
| GTraversable (UFloat :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable Methods gtraverse :: Applicative f => (a %1 -> f b) -> UFloat a %1 -> Curried (Yoneda f) (Yoneda f) (UFloat b) | |||||
| Traversable (UFloat :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable | |||||
| Functor (URec Float :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Generic (URec Float p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Show (URec Float p) | |||||
| Eq (URec Float p) | |||||
| Ord (URec Float p) | |||||
Defined in GHC.Generics | |||||
| type Rep Float | |||||
| newtype Vector Float | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| data URec Float (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 | ||||
| newtype MVector s Float | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| type Rep1 (URec Float :: k -> Type) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep1 (URec Float :: k -> Type) | |||||
Defined in Generics.Linear.Instances.Base | |||||
| type Rep (URec Float p) | |||||
Defined in GHC.Generics | |||||
| type Rep (URec Float p) | |||||
Defined in Generics.Linear.Instances.Base | |||||
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
Instances
| Data Double | Since: base-4.0.0.0 | ||||
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Double -> c Double # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Double # toConstr :: Double -> Constr # dataTypeOf :: Double -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Double) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Double) # gmapT :: (forall b. Data b => b -> b) -> Double -> Double # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Double -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Double -> r # gmapQ :: (forall d. Data d => d -> u) -> Double -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Double -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Double -> m Double # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Double -> m Double # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Double -> m Double # | |||||
| Storable Double | Since: base-2.1 | ||||
| Floating Double | Since: base-2.1 | ||||
| RealFloat Double | Since: base-2.1 | ||||
Defined in GHC.Float Methods floatRadix :: Double -> Integer # floatDigits :: Double -> Int # floatRange :: Double -> (Int, Int) # decodeFloat :: Double -> (Integer, Int) # encodeFloat :: Integer -> Int -> Double # significand :: Double -> Double # scaleFloat :: Int -> Double -> Double # isInfinite :: Double -> Bool # isDenormalized :: Double -> Bool # isNegativeZero :: Double -> Bool # | |||||
| Read Double | Since: base-2.1 | ||||
| PrintfArg Double | Since: base-2.1 | ||||
Defined in Text.Printf | |||||
| NFData Double | |||||
Defined in Control.DeepSeq | |||||
| Eq Double | Note that due to the presence of
Also note that
| ||||
| Ord Double | IEEE 754 IEEE 754-2008, section 5.11 requires that if at least one of arguments of
IEEE 754-2008, section 5.10 defines Thus, users must be extremely cautious when using Moving further, the behaviour of IEEE 754-2008 compliant | ||||
| Hashable Double | Note: prior to The Since: hashable-1.3.0.0 | ||||
Defined in Data.Hashable.Class | |||||
| AddIdentity Double Source # | |||||
Defined in Data.Num.Linear | |||||
| Additive Double Source # | |||||
| AdditiveGroup Double Source # | |||||
| FromInteger Double Source # | |||||
Defined in Data.Num.Linear Methods fromInteger :: Integer %1 -> Double Source # | |||||
| MultIdentity Double Source # | |||||
Defined in Data.Num.Linear | |||||
| Multiplicative Double Source # | |||||
| Num Double Source # | |||||
| Ring Double Source # | |||||
Defined in Data.Num.Linear | |||||
| Semiring Double Source # | |||||
Defined in Data.Num.Linear | |||||
| Eq Double Source # | |||||
| Ord Double Source # | |||||
| Consumable Double Source # | |||||
Defined in Data.Unrestricted.Linear.Internal.Consumable | |||||
| Dupable Double Source # | |||||
| Movable Double Source # | |||||
| Prim Double | |||||
Defined in Data.Primitive.Types Methods sizeOfType# :: Proxy Double -> Int# # alignmentOfType# :: Proxy Double -> Int# # alignment# :: Double -> Int# # indexByteArray# :: ByteArray# -> Int# -> Double # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Double #) # writeByteArray# :: MutableByteArray# s -> Int# -> Double -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Double -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Double # readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Double #) # writeOffAddr# :: Addr# -> Int# -> Double -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Double -> State# s -> State# s # | |||||
| UniformRange Double | |||||
| Unbox Double | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| Lift Double | |||||
| Vector Vector Double | |||||
Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: Mutable Vector s Double -> ST s (Vector Double) basicUnsafeThaw :: Vector Double -> ST s (Mutable Vector s Double) basicLength :: Vector Double -> Int basicUnsafeSlice :: Int -> Int -> Vector Double -> Vector Double basicUnsafeIndexM :: Vector Double -> Int -> Box Double basicUnsafeCopy :: Mutable Vector s Double -> Vector Double -> ST s () | |||||
| MVector MVector Double | |||||
Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s Double -> Int basicUnsafeSlice :: Int -> Int -> MVector s Double -> MVector s Double basicOverlaps :: MVector s Double -> MVector s Double -> Bool basicUnsafeNew :: Int -> ST s (MVector s Double) basicInitialize :: MVector s Double -> ST s () basicUnsafeReplicate :: Int -> Double -> ST s (MVector s Double) basicUnsafeRead :: MVector s Double -> Int -> ST s Double basicUnsafeWrite :: MVector s Double -> Int -> Double -> ST s () basicClear :: MVector s Double -> ST s () basicSet :: MVector s Double -> Double -> ST s () basicUnsafeCopy :: MVector s Double -> MVector s Double -> ST s () basicUnsafeMove :: MVector s Double -> MVector s Double -> ST s () basicUnsafeGrow :: MVector s Double -> Int -> ST s (MVector s Double) | |||||
| Generic1 (URec Double :: k -> Type) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Foldable (UDouble :: Type -> Type) | Since: base-4.9.0.0 | ||||
Defined in Data.Foldable Methods fold :: Monoid m => UDouble m -> m # foldMap :: Monoid m => (a -> m) -> UDouble a -> m # foldMap' :: Monoid m => (a -> m) -> UDouble a -> m # foldr :: (a -> b -> b) -> b -> UDouble a -> b # foldr' :: (a -> b -> b) -> b -> UDouble a -> b # foldl :: (b -> a -> b) -> b -> UDouble a -> b # foldl' :: (b -> a -> b) -> b -> UDouble a -> b # foldr1 :: (a -> a -> a) -> UDouble a -> a # foldl1 :: (a -> a -> a) -> UDouble a -> a # elem :: Eq a => a -> UDouble a -> Bool # maximum :: Ord a => UDouble a -> a # minimum :: Ord a => UDouble a -> a # | |||||
| Traversable (UDouble :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Functor (UDouble :: Type -> Type) Source # | |||||
| GTraversable (UDouble :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable Methods gtraverse :: Applicative f => (a %1 -> f b) -> UDouble a %1 -> Curried (Yoneda f) (Yoneda f) (UDouble b) | |||||
| Traversable (UDouble :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable | |||||
| Functor (URec Double :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Generic (URec Double p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Show (URec Double p) | Since: base-4.9.0.0 | ||||
| Eq (URec Double p) | Since: base-4.9.0.0 | ||||
| Ord (URec Double p) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics Methods compare :: URec Double p -> URec Double p -> Ordering # (<) :: URec Double p -> URec Double p -> Bool # (<=) :: URec Double p -> URec Double p -> Bool # (>) :: URec Double p -> URec Double p -> Bool # (>=) :: URec Double p -> URec Double p -> Bool # | |||||
| type Rep Double | |||||
| newtype Vector Double | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| data URec Double (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 | ||||
| newtype MVector s Double | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| type Rep1 (URec Double :: k -> Type) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep1 (URec Double :: k -> Type) | |||||
Defined in Generics.Linear.Instances.Base | |||||
| type Rep (URec Double p) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep (URec Double p) | |||||
Defined in Generics.Linear.Instances.Base | |||||
Instances
| Data Word | Since: base-4.0.0.0 | ||||
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Word -> c Word # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Word # dataTypeOf :: Word -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Word) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Word) # gmapT :: (forall b. Data b => b -> b) -> Word -> Word # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Word -> r # gmapQ :: (forall d. Data d => d -> u) -> Word -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Word -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Word -> m Word # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Word -> m Word # | |||||
| Storable Word | Since: base-2.1 | ||||
Defined in Foreign.Storable | |||||
| Bits Word | Since: base-2.1 | ||||
Defined in GHC.Bits Methods (.&.) :: Word -> Word -> Word # (.|.) :: Word -> Word -> Word # complement :: Word -> Word # shift :: Word -> Int -> Word # rotate :: Word -> Int -> Word # setBit :: Word -> Int -> Word # clearBit :: Word -> Int -> Word # complementBit :: Word -> Int -> Word # testBit :: Word -> Int -> Bool # bitSizeMaybe :: Word -> Maybe Int # shiftL :: Word -> Int -> Word # unsafeShiftL :: Word -> Int -> Word # shiftR :: Word -> Int -> Word # unsafeShiftR :: Word -> Int -> Word # rotateL :: Word -> Int -> Word # | |||||
| FiniteBits Word | Since: base-4.6.0.0 | ||||
Defined in GHC.Bits Methods finiteBitSize :: Word -> Int # countLeadingZeros :: Word -> Int # countTrailingZeros :: Word -> Int # | |||||
| Bounded Word | Since: base-2.1 | ||||
| Enum Word | Since: base-2.1 | ||||
| Ix Word | Since: base-4.6.0.0 | ||||
| Num Word | Since: base-2.1 | ||||
| Read Word | Since: base-4.5.0.0 | ||||
| Integral Word | Since: base-2.1 | ||||
| Real Word | Since: base-2.1 | ||||
Defined in GHC.Real Methods toRational :: Word -> Rational # | |||||
| Show Word | Since: base-2.1 | ||||
| PrintfArg Word | Since: base-2.1 | ||||
Defined in Text.Printf | |||||
| NFData Word | |||||
Defined in Control.DeepSeq | |||||
| Eq Word | |||||
| Ord Word | |||||
| Hashable Word | |||||
Defined in Data.Hashable.Class | |||||
| AddIdentity Word Source # | |||||
Defined in Data.Num.Linear | |||||
| Additive Word Source # | |||||
| AdditiveGroup Word Source # | |||||
| FromInteger Word Source # | |||||
Defined in Data.Num.Linear Methods fromInteger :: Integer %1 -> Word Source # | |||||
| MultIdentity Word Source # | |||||
Defined in Data.Num.Linear | |||||
| Multiplicative Word Source # | |||||
| Num Word Source # | |||||
| Ring Word Source # | |||||
Defined in Data.Num.Linear | |||||
| Semiring Word Source # | |||||
Defined in Data.Num.Linear | |||||
| Consumable Word Source # | |||||
Defined in Data.Unrestricted.Linear.Internal.Consumable | |||||
| Dupable Word Source # | |||||
| Movable Word Source # | |||||
| KnownRepresentable Word Source # | |||||
Defined in Foreign.Marshal.Pure.Internal | |||||
| Representable Word Source # | |||||
| Prim Word | |||||
Defined in Data.Primitive.Types Methods sizeOfType# :: Proxy Word -> Int# # alignmentOfType# :: Proxy Word -> Int# # alignment# :: Word -> Int# # indexByteArray# :: ByteArray# -> Int# -> Word # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word #) # writeByteArray# :: MutableByteArray# s -> Int# -> Word -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Word -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Word # readOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word #) # writeOffAddr# :: Addr# -> Int# -> Word -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Word -> State# s -> State# s # | |||||
| Uniform Word | |||||
Defined in System.Random.Internal Methods uniformM :: StatefulGen g m => g -> m Word # | |||||
| UniformRange Word | |||||
| Unbox Word | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| Lift Word | |||||
| Vector Vector Word | |||||
Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: Mutable Vector s Word -> ST s (Vector Word) basicUnsafeThaw :: Vector Word -> ST s (Mutable Vector s Word) basicLength :: Vector Word -> Int basicUnsafeSlice :: Int -> Int -> Vector Word -> Vector Word basicUnsafeIndexM :: Vector Word -> Int -> Box Word basicUnsafeCopy :: Mutable Vector s Word -> Vector Word -> ST s () | |||||
| MVector MVector Word | |||||
Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s Word -> Int basicUnsafeSlice :: Int -> Int -> MVector s Word -> MVector s Word basicOverlaps :: MVector s Word -> MVector s Word -> Bool basicUnsafeNew :: Int -> ST s (MVector s Word) basicInitialize :: MVector s Word -> ST s () basicUnsafeReplicate :: Int -> Word -> ST s (MVector s Word) basicUnsafeRead :: MVector s Word -> Int -> ST s Word basicUnsafeWrite :: MVector s Word -> Int -> Word -> ST s () basicClear :: MVector s Word -> ST s () basicSet :: MVector s Word -> Word -> ST s () basicUnsafeCopy :: MVector s Word -> MVector s Word -> ST s () basicUnsafeMove :: MVector s Word -> MVector s Word -> ST s () basicUnsafeGrow :: MVector s Word -> Int -> ST s (MVector s Word) | |||||
| Generic1 (URec Word :: k -> Type) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Foldable (UWord :: Type -> Type) | Since: base-4.9.0.0 | ||||
Defined in Data.Foldable Methods fold :: Monoid m => UWord m -> m # foldMap :: Monoid m => (a -> m) -> UWord a -> m # foldMap' :: Monoid m => (a -> m) -> UWord a -> m # foldr :: (a -> b -> b) -> b -> UWord a -> b # foldr' :: (a -> b -> b) -> b -> UWord a -> b # foldl :: (b -> a -> b) -> b -> UWord a -> b # foldl' :: (b -> a -> b) -> b -> UWord a -> b # foldr1 :: (a -> a -> a) -> UWord a -> a # foldl1 :: (a -> a -> a) -> UWord a -> a # elem :: Eq a => a -> UWord a -> Bool # maximum :: Ord a => UWord a -> a # minimum :: Ord a => UWord a -> a # | |||||
| Traversable (UWord :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Functor (UWord :: Type -> Type) Source # | |||||
| GTraversable (UWord :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable Methods gtraverse :: Applicative f => (a %1 -> f b) -> UWord a %1 -> Curried (Yoneda f) (Yoneda f) (UWord b) | |||||
| Traversable (UWord :: Type -> Type) Source # | |||||
Defined in Data.Functor.Linear.Internal.Traversable | |||||
| Functor (URec Word :: Type -> Type) | Since: base-4.9.0.0 | ||||
| Generic (URec Word p) | |||||
Defined in GHC.Generics Associated Types
| |||||
| Show (URec Word p) | Since: base-4.9.0.0 | ||||
| Eq (URec Word p) | Since: base-4.9.0.0 | ||||
| Ord (URec Word p) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type AsKnown Word Source # | |||||
Defined in Foreign.Marshal.Pure.Internal | |||||
| type Rep Word | |||||
| newtype Vector Word | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| data URec Word (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 | ||||
| newtype MVector s Word | |||||
Defined in Data.Vector.Unboxed.Base | |||||
| type Rep1 (URec Word :: k -> Type) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep1 (URec Word :: k -> Type) | |||||
Defined in Generics.Linear.Instances.Base | |||||
| type Rep (URec Word p) | Since: base-4.9.0.0 | ||||
Defined in GHC.Generics | |||||
| type Rep (URec Word p) | |||||
Defined in Generics.Linear.Instances.Base | |||||
module Data.Num.Linear
class (Num a, Ord a) => Real a where #
Real numbers.
The Haskell report defines no laws for Real, however Real instances
are customarily expected to adhere to the following law:
- Coherence with
fromRational - if the type also implements
Fractional, thenfromRationalis a left inverse fortoRational, i.e.fromRational (toRational i) = i
The law does not hold for Float, Double, CFloat,
CDouble, etc., because these types contain non-finite values,
which cannot be roundtripped through Rational.
Methods
toRational :: a -> Rational #
the rational equivalent of its real argument with full precision
Instances
class (Real a, Enum a) => Integral a where #
Integral numbers, supporting integer division.
The Haskell Report defines no laws for Integral. However, Integral
instances are customarily expected to define a Euclidean domain and have the
following properties for the div/mod and quot/rem pairs, given
suitable Euclidean functions f and g:
x=y * quot x y + rem x ywithrem x y=fromInteger 0org (rem x y)<g yx=y * div x y + mod x ywithmod x y=fromInteger 0orf (mod x y)<f y
An example of a suitable Euclidean function, for Integer's instance, is
abs.
In addition, toInteger should be total, and fromInteger should be a left
inverse for it, i.e. fromInteger (toInteger i) = i.
Methods
quot :: a -> a -> a infixl 7 #
integer division truncated toward zero
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base.
integer remainder, satisfying
(x `quot` y)*y + (x `rem` y) == x
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base.
integer division truncated toward negative infinity
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base.
integer modulus, satisfying
(x `div` y)*y + (x `mod` y) == x
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base.
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base.
WARNING: This function is partial (because it throws when 0 is passed as
the divisor) for all the integer types in base.
conversion to Integer
Instances
class Fractional a => Floating a where #
Trigonometric and hyperbolic functions and related functions.
The Haskell Report defines no laws for Floating. However, (, +)(
and *)exp are customarily expected to define an exponential field and have
the following properties:
exp (a + b)=exp a * exp bexp (fromInteger 0)=fromInteger 1
Minimal complete definition
pi, exp, log, sin, cos, asin, acos, atan, sinh, cosh, asinh, acosh, atanh
Instances
class Num a => Fractional a where #
Fractional numbers, supporting real division.
The Haskell Report defines no laws for Fractional. However, ( and
+)( are customarily expected to define a division ring and have the
following properties:*)
recipgives the multiplicative inversex * recip x=recip x * x=fromInteger 1- Totality of
toRational toRationalis total- Coherence with
toRational - if the type also implements
Real, thenfromRationalis a left inverse fortoRational, i.e.fromRational (toRational i) = i
Note that it isn't customarily expected that a type instance of
Fractional implement a field. However, all instances in base do.
Minimal complete definition
fromRational, (recip | (/))
Methods
Fractional division.
Reciprocal fraction.
fromRational :: Rational -> a #
Conversion from a Rational (that is ).
A floating literal stands for an application of Ratio IntegerfromRational
to a value of type Rational, so such literals have type
(.Fractional a) => a
Instances
| Fractional CDouble | |
| Fractional CFloat | |
| RealFloat a => Fractional (Complex a) | Since: base-2.1 |
| Fractional a => Fractional (Identity a) | Since: base-4.9.0.0 |
| Fractional a => Fractional (Down a) | Since: base-4.14.0.0 |
| Integral a => Fractional (Ratio a) | Since: base-2.0.1 |
| HasResolution a => Fractional (Fixed a) | Since: base-2.1 |
| Fractional a => Fractional (Op a b) | |
| Fractional a => Fractional (Const a b) | Since: base-4.9.0.0 |
class (Real a, Fractional a) => RealFrac a where #
Extracting components of fractions.
Minimal complete definition
Methods
properFraction :: Integral b => a -> (b, a) #
The function properFraction takes a real fractional number x
and returns a pair (n,f) such that x = n+f, and:
nis an integral number with the same sign asx; andfis a fraction with the same type and sign asx, and with absolute value less than1.
The default definitions of the ceiling, floor, truncate
and round functions are in terms of properFraction.
truncate :: Integral b => a -> b #
returns the integer nearest truncate xx between zero and x
round :: Integral b => a -> b #
returns the nearest integer to round xx;
the even integer if x is equidistant between two integers
ceiling :: Integral b => a -> b #
returns the least integer not less than ceiling xx
floor :: Integral b => a -> b #
returns the greatest integer not greater than floor xx
Instances
class (RealFrac a, Floating a) => RealFloat a where #
Efficient, machine-independent access to the components of a floating-point number.
Minimal complete definition
floatRadix, floatDigits, floatRange, decodeFloat, encodeFloat, isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE
Methods
floatRadix :: a -> Integer #
a constant function, returning the radix of the representation
(often 2)
floatDigits :: a -> Int #
a constant function, returning the number of digits of
floatRadix in the significand
floatRange :: a -> (Int, Int) #
a constant function, returning the lowest and highest values the exponent may assume
decodeFloat :: a -> (Integer, Int) #
The function decodeFloat applied to a real floating-point
number returns the significand expressed as an Integer and an
appropriately scaled exponent (an Int). If
yields decodeFloat x(m,n), then x is equal in value to m*b^^n, where b
is the floating-point radix, and furthermore, either m and n
are both zero or else b^(d-1) <= , where abs m < b^dd is
the value of .
In particular, floatDigits x. If the type
contains a negative zero, also decodeFloat 0 = (0,0).
The result of decodeFloat (-0.0) = (0,0) is unspecified if either of
decodeFloat x or isNaN x is isInfinite xTrue.
encodeFloat :: Integer -> Int -> a #
encodeFloat performs the inverse of decodeFloat in the
sense that for finite x with the exception of -0.0,
.
uncurry encodeFloat (decodeFloat x) = x is one of the two closest representable
floating-point numbers to encodeFloat m nm*b^^n (or ±Infinity if overflow
occurs); usually the closer, but if m contains too many bits,
the result may be rounded in the wrong direction.
exponent corresponds to the second component of decodeFloat.
and for finite nonzero exponent 0 = 0x,
.
If exponent x = snd (decodeFloat x) + floatDigits xx is a finite floating-point number, it is equal in value to
, where significand x * b ^^ exponent xb is the
floating-point radix.
The behaviour is unspecified on infinite or NaN values.
significand :: a -> a #
The first component of decodeFloat, scaled to lie in the open
interval (-1,1), either 0.0 or of absolute value >= 1/b,
where b is the floating-point radix.
The behaviour is unspecified on infinite or NaN values.
scaleFloat :: Int -> a -> a #
multiplies a floating-point number by an integer power of the radix
True if the argument is an IEEE "not-a-number" (NaN) value
isInfinite :: a -> Bool #
True if the argument is an IEEE infinity or negative infinity
isDenormalized :: a -> Bool #
True if the argument is too small to be represented in
normalized format
isNegativeZero :: a -> Bool #
True if the argument is an IEEE negative zero
True if the argument is an IEEE floating point number
a version of arctangent taking two real floating-point arguments.
For real floating x and y, computes the angle
(from the positive x-axis) of the vector from the origin to the
point atan2 y x(x,y). returns a value in the range [atan2 y x-pi,
pi]. It follows the Common Lisp semantics for the origin when
signed zeroes are supported. , with atan2 y 1y in a type
that is RealFloat, should return the same value as .
A default definition of atan yatan2 is provided, but implementors
can provide a more accurate implementation.
Instances
Numeric functions
gcd :: Integral a => a -> a -> a #
is the non-negative factor of both gcd x yx and y of which
every common factor of x and y is also a factor; for example
, gcd 4 2 = 2, gcd (-4) 6 = 2 = gcd 0 44. = gcd 0 00.
(That is, the common divisor that is "greatest" in the divisibility
preordering.)
Note: Since for signed fixed-width integer types, ,
the result may be negative if one of the arguments is abs minBound < 0 (and
necessarily is if the other is minBound0 or ) for such types.minBound
lcm :: Integral a => a -> a -> a #
is the smallest positive integer that both lcm x yx and y divide.
(^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 #
raise a number to an integral power
fromIntegral :: (Integral a, Num b) => a -> b #
General coercion from Integral types.
WARNING: This function performs silent truncation if the result type is not at least as big as the argument's type.
realToFrac :: (Real a, Fractional b) => a -> b #
General coercion to Fractional types.
WARNING: This function goes through the Rational type, which does not have values for NaN for example.
This means it does not round-trip.
For Double it also behaves differently with or without -O0:
Prelude> realToFrac nan -- With -O0 -Infinity Prelude> realToFrac nan NaN
Monads and functors
(<*) :: (Applicative f, Consumable b) => f a %1 -> f b %1 -> f a infixl 4 Source #
Linearly typed replacement for the standard (<*) function.
Semigroups and monoids
module Data.Monoid.Linear
Miscellaneous functions
id :: forall a (q :: Multiplicity). a %q -> a Source #
const :: forall a b (q :: Multiplicity). a %q -> b -> a Source #
(.) :: forall b c a (q :: Multiplicity) (m :: Multiplicity) (n :: Multiplicity). (b %1 -> c) %q -> (a %1 -> b) %m -> a %n -> c infixr 9 Source #
Beware: (.) is not compatible with the standard one because it is
higher-order and we don't have sufficient multiplicity polymorphism yet.
flip :: forall a b c (q :: Multiplicity) (p :: Multiplicity) (r :: Multiplicity). (a %p -> b %q -> c) %r -> b %q -> a %p -> c Source #
Replacement for the flip function with generalized multiplicities.
($) :: forall a b (p :: Multiplicity) (q :: Multiplicity). (a %p -> b) %q -> a %p -> b infixr 0 Source #
(&) :: forall a b (p :: Multiplicity) (q :: Multiplicity). a %p -> (a %p -> b) %q -> b infixl 1 Source #
until :: (a -> Bool) -> (a -> a) -> a -> a #
yields the result of applying until p ff until p holds.
error :: HasCallStack => [Char] -> a #
error stops execution and displays an error message.
errorWithoutStackTrace :: [Char] -> a #
A variant of error that does not produce a stack trace.
Since: base-4.9.0.0
undefined :: HasCallStack => a #
seq :: forall a b (q :: Multiplicity). a -> b %q -> b infixr 0 Source #
seq x y only forces x to head normal form, therefore is not guaranteed
to consume x when the resulting computation is consumed. Therefore, seq
cannot be linear in it's first argument.
($!) :: forall a b (p :: Multiplicity) (q :: Multiplicity). (a %p -> b) %q -> a %p -> b infixr 0 Source #
List operations
module Data.List.Linear
Functions on strings
module Data.String
Converting to and from String
Conversion of values to readable Strings.
Derived instances of Show have the following properties, which
are compatible with derived instances of Read:
- The result of
showis a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrecwill produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
xis less thand(associativity is ignored). Thus, ifdis0then the result is never surrounded in parentheses; ifdis11it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
showwill produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show is equivalent to
instance (Show a) => Show (Tree a) where
showsPrec d (Leaf m) = showParen (d > app_prec) $
showString "Leaf " . showsPrec (app_prec+1) m
where app_prec = 10
showsPrec d (u :^: v) = showParen (d > up_prec) $
showsPrec (up_prec+1) u .
showString " :^: " .
showsPrec (up_prec+1) v
where up_prec = 5Note that right-associativity of :^: is ignored. For example,
produces the stringshow(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)".
Methods
Arguments
| :: Int | the operator precedence of the enclosing
context (a number from |
| -> a | the value to be converted to a |
| -> ShowS |
Convert a value to a readable String.
showsPrec should satisfy the law
showsPrec d x r ++ s == showsPrec d x (r ++ s)
Derived instances of Read and Show satisfy the following:
That is, readsPrec parses the string produced by
showsPrec, and delivers the value that showsPrec started with.
Instances
utility function converting a Char to a show function that
simply prepends the character unchanged.
showString :: String -> ShowS #
utility function converting a String to a show function that
simply prepends the string unchanged.
Parsing of Strings, producing values.
Derived instances of Read make the following assumptions, which
derived instances of Show obey:
- If the constructor is defined to be an infix operator, then the
derived
Readinstance will parse only infix applications of the constructor (not the prefix form). - Associativity is not used to reduce the occurrence of parentheses, although precedence may be.
- If the constructor is defined using record syntax, the derived
Readwill parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration. - The derived
Readinstance allows arbitrary Haskell whitespace between tokens of the input string. Extra parentheses are also allowed.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Read in Haskell 2010 is equivalent to
instance (Read a) => Read (Tree a) where
readsPrec d r = readParen (d > app_prec)
(\r -> [(Leaf m,t) |
("Leaf",s) <- lex r,
(m,t) <- readsPrec (app_prec+1) s]) r
++ readParen (d > up_prec)
(\r -> [(u:^:v,w) |
(u,s) <- readsPrec (up_prec+1) r,
(":^:",t) <- lex s,
(v,w) <- readsPrec (up_prec+1) t]) r
where app_prec = 10
up_prec = 5Note that right-associativity of :^: is unused.
The derived instance in GHC is equivalent to
instance (Read a) => Read (Tree a) where
readPrec = parens $ (prec app_prec $ do
Ident "Leaf" <- lexP
m <- step readPrec
return (Leaf m))
+++ (prec up_prec $ do
u <- step readPrec
Symbol ":^:" <- lexP
v <- step readPrec
return (u :^: v))
where app_prec = 10
up_prec = 5
readListPrec = readListPrecDefaultWhy do both readsPrec and readPrec exist, and why does GHC opt to
implement readPrec in derived Read instances instead of readsPrec?
The reason is that readsPrec is based on the ReadS type, and although
ReadS is mentioned in the Haskell 2010 Report, it is not a very efficient
parser data structure.
readPrec, on the other hand, is based on a much more efficient ReadPrec
datatype (a.k.a "new-style parsers"), but its definition relies on the use
of the RankNTypes language extension. Therefore, readPrec (and its
cousin, readListPrec) are marked as GHC-only. Nevertheless, it is
recommended to use readPrec instead of readsPrec whenever possible
for the efficiency improvements it brings.
As mentioned above, derived Read instances in GHC will implement
readPrec instead of readsPrec. The default implementations of
readsPrec (and its cousin, readList) will simply use readPrec under
the hood. If you are writing a Read instance by hand, it is recommended
to write it like so:
instanceReadT wherereadPrec= ...readListPrec=readListPrecDefault
Methods
Arguments
| :: Int | the operator precedence of the enclosing
context (a number from |
| -> ReadS a |
attempts to parse a value from the front of the string, returning a list of (parsed value, remaining string) pairs. If there is no successful parse, the returned list is empty.
Derived instances of Read and Show satisfy the following:
That is, readsPrec parses the string produced by
showsPrec, and delivers the value that
showsPrec started with.
Instances
| Read All | Since: base-2.1 |
| Read Any | Since: base-2.1 |
| Read Version | Since: base-2.1 |
| Read CBool | |
| Read CChar | |
| Read CClock | |
| Read CDouble | |
| Read CFloat | |
| Read CInt | |
| Read CIntMax | |
| Read CIntPtr | |
| Read CLLong | |
| Read CLong | |
| Read CPtrdiff | |
| Read CSChar | |
| Read CSUSeconds | |
Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CSUSeconds # readList :: ReadS [CSUSeconds] # readPrec :: ReadPrec CSUSeconds # readListPrec :: ReadPrec [CSUSeconds] # | |
| Read CShort | |
| Read CSigAtomic | |
Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CSigAtomic # readList :: ReadS [CSigAtomic] # readPrec :: ReadPrec CSigAtomic # readListPrec :: ReadPrec [CSigAtomic] # | |
| Read CSize | |
| Read CTime | |
| Read CUChar | |
| Read CUInt | |
| Read CUIntMax | |
| Read CUIntPtr | |
| Read CULLong | |
| Read CULong | |
| Read CUSeconds | |
| Read CUShort | |
| Read CWchar | |
| Read IntPtr | |
| Read WordPtr | |
| Read Void | Reading a Since: base-4.8.0.0 |
| Read ByteOrder | Since: base-4.11.0.0 |
| Read Associativity | Since: base-4.6.0.0 |
Defined in GHC.Generics Methods readsPrec :: Int -> ReadS Associativity # readList :: ReadS [Associativity] # | |
| Read DecidedStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods readsPrec :: Int -> ReadS DecidedStrictness # readList :: ReadS [DecidedStrictness] # | |
| Read Fixity | Since: base-4.6.0.0 |
| Read SourceStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods readsPrec :: Int -> ReadS SourceStrictness # readList :: ReadS [SourceStrictness] # | |
| Read SourceUnpackedness | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods readsPrec :: Int -> ReadS SourceUnpackedness # readList :: ReadS [SourceUnpackedness] # | |
| Read SeekMode | Since: base-4.2.0.0 |
| Read ExitCode | |
| Read BufferMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methods readsPrec :: Int -> ReadS BufferMode # readList :: ReadS [BufferMode] # readPrec :: ReadPrec BufferMode # readListPrec :: ReadPrec [BufferMode] # | |
| Read Newline | Since: base-4.3.0.0 |
| Read NewlineMode | Since: base-4.3.0.0 |
Defined in GHC.IO.Handle.Types Methods readsPrec :: Int -> ReadS NewlineMode # readList :: ReadS [NewlineMode] # readPrec :: ReadPrec NewlineMode # readListPrec :: ReadPrec [NewlineMode] # | |
| Read IOMode | Since: base-4.2.0.0 |
| Read Int16 | Since: base-2.1 |
| Read Int32 | Since: base-2.1 |
| Read Int64 | Since: base-2.1 |
| Read Int8 | Since: base-2.1 |
| Read GCDetails | Since: base-4.10.0.0 |
| Read RTSStats | Since: base-4.10.0.0 |
| Read SomeChar | |
| Read SomeSymbol | Since: base-4.7.0.0 |
Defined in GHC.TypeLits Methods readsPrec :: Int -> ReadS SomeSymbol # readList :: ReadS [SomeSymbol] # readPrec :: ReadPrec SomeSymbol # readListPrec :: ReadPrec [SomeSymbol] # | |
| Read SomeNat | Since: base-4.7.0.0 |
| Read GeneralCategory | Since: base-2.1 |
Defined in GHC.Read Methods readsPrec :: Int -> ReadS GeneralCategory # readList :: ReadS [GeneralCategory] # | |
| Read Word16 | Since: base-2.1 |
| Read Word32 | Since: base-2.1 |
| Read Word64 | Since: base-2.1 |
| Read Word8 | Since: base-2.1 |
| Read CBlkCnt | |
| Read CBlkSize | |
| Read CCc | |
| Read CClockId | |
| Read CDev | |
| Read CFsBlkCnt | |
| Read CFsFilCnt | |
| Read CGid | |
| Read CId | |
| Read CIno | |
| Read CKey | |
| Read CMode | |
| Read CNfds | |
| Read CNlink | |
| Read COff | |
| Read CPid | |
| Read CRLim | |
| Read CSocklen | |
| Read CSpeed | |
| Read CSsize | |
| Read CTcflag | |
| Read CUid | |
| Read Fd | |
| Read Lexeme | Since: base-2.1 |
| Read ByteString | |
Defined in Data.ByteString.Internal.Type Methods readsPrec :: Int -> ReadS ByteString # readList :: ReadS [ByteString] # readPrec :: ReadPrec ByteString # readListPrec :: ReadPrec [ByteString] # | |
| Read ByteString | |
Defined in Data.ByteString.Lazy.Internal Methods readsPrec :: Int -> ReadS ByteString # readList :: ReadS [ByteString] # readPrec :: ReadPrec ByteString # readListPrec :: ReadPrec [ByteString] # | |
| Read ShortByteString | |
Defined in Data.ByteString.Short.Internal Methods readsPrec :: Int -> ReadS ShortByteString # readList :: ReadS [ShortByteString] # | |
| Read IntSet | |
| Read Ordering | Since: base-2.1 |
| Read I8 | |
| Read FPFormat | |
| Read DatatypeVariant | |
Defined in Language.Haskell.TH.Datatype Methods readsPrec :: Int -> ReadS DatatypeVariant # readList :: ReadS [DatatypeVariant] # | |
| Read Integer | Since: base-2.1 |
| Read Natural | Since: base-4.8.0.0 |
| Read () | Since: base-2.1 |
| Read Bool | Since: base-2.1 |
| Read Char | Since: base-2.1 |
| Read Double | Since: base-2.1 |
| Read Float | Since: base-2.1 |
| Read Int | Since: base-2.1 |
| Read Word | Since: base-4.5.0.0 |
| Read a => Read (ZipList a) | Since: base-4.7.0.0 |
| Read a => Read (And a) | Since: base-4.16 |
| Read a => Read (Iff a) | Since: base-4.16 |
| Read a => Read (Ior a) | Since: base-4.16 |
| Read a => Read (Xor a) | Since: base-4.16 |
| Read a => Read (Complex a) | Since: base-2.1 |
| Read a => Read (Identity a) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Read a => Read (First a) | Since: base-2.1 |
| Read a => Read (Last a) | Since: base-2.1 |
| Read a => Read (Down a) | This instance would be equivalent to the derived instances of the
Since: base-4.7.0.0 |
| Read a => Read (First a) | Since: base-4.9.0.0 |
| Read a => Read (Last a) | Since: base-4.9.0.0 |
| Read a => Read (Max a) | Since: base-4.9.0.0 |
| Read a => Read (Min a) | Since: base-4.9.0.0 |
| Read m => Read (WrappedMonoid m) | Since: base-4.9.0.0 |
Defined in Data.Semigroup Methods readsPrec :: Int -> ReadS (WrappedMonoid m) # readList :: ReadS [WrappedMonoid m] # readPrec :: ReadPrec (WrappedMonoid m) # readListPrec :: ReadPrec [WrappedMonoid m] # | |
| Read a => Read (Dual a) | Since: base-2.1 |
| Read a => Read (Product a) | Since: base-2.1 |
| Read a => Read (Sum a) | Since: base-2.1 |
| Read a => Read (NonEmpty a) | Since: base-4.11.0.0 |
| Read p => Read (Par1 p) | Since: base-4.7.0.0 |
| (Integral a, Read a) => Read (Ratio a) | Since: base-2.1 |
| Read vertex => Read (SCC vertex) | Since: containers-0.5.9 |
| Read e => Read (IntMap e) | |
| Read a => Read (Seq a) | |
| Read a => Read (ViewL a) | |
| Read a => Read (ViewR a) | |
| (Read a, Ord a) => Read (Set a) | |
| Read a => Read (Tree a) | |
| Read a => Read (Array a) | |
| Read a => Read (SmallArray a) | |
Defined in Data.Primitive.SmallArray Methods readsPrec :: Int -> ReadS (SmallArray a) # readList :: ReadS [SmallArray a] # readPrec :: ReadPrec (SmallArray a) # readListPrec :: ReadPrec [SmallArray a] # | |
| Read a => Read (Vector a) | |
| (Read a, Prim a) => Read (Vector a) | |
| (Read a, Storable a) => Read (Vector a) | |
| Read a => Read (Vector a) | |
| Read a => Read (Maybe a) | Since: base-2.1 |
| Read a => Read (Solo a) | Since: base-4.15 |
| Read a => Read [a] | Since: base-2.1 |
| (Read a, Read b) => Read (Either a b) | Since: base-3.0 |
| HasResolution a => Read (Fixed a) | Since: base-4.3.0.0 |
| Read (Proxy t) | Since: base-4.7.0.0 |
| (Read a, Read b) => Read (Arg a b) | Since: base-4.9.0.0 |
| (Ix a, Read a, Read b) => Read (Array a b) | Since: base-2.1 |
| Read (U1 p) | Since: base-4.9.0.0 |
| Read (V1 p) | Since: base-4.9.0.0 |
| (Ord k, Read k, Read e) => Read (Map k e) | |
| (Read1 f, Read a) => Read (Lift f a) | |
| (Read1 m, Read a) => Read (MaybeT m a) | |
| (Read a, Read b) => Read (a, b) | Since: base-2.1 |
| Read a => Read (Const a b) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Read (f a) => Read (Ap f a) | Since: base-4.12.0.0 |
| Read (f a) => Read (Alt f a) | Since: base-4.8.0.0 |
| Coercible a b => Read (Coercion a b) | Since: base-4.7.0.0 |
| a ~ b => Read (a :~: b) | Since: base-4.7.0.0 |
| Read (f p) => Read (Rec1 f p) | Since: base-4.7.0.0 |
| (Read1 f, Read a) => Read (Backwards f a) | |
| (Read e, Read1 m, Read a) => Read (ExceptT e m a) | |
| (Read1 f, Read a) => Read (IdentityT f a) | |
| (Read w, Read1 m, Read a) => Read (WriterT w m a) | |
| (Read w, Read1 m, Read a) => Read (WriterT w m a) | |
| Read a => Read (Constant a b) | |
| (Read1 f, Read a) => Read (Reverse f a) | |
| (Read a, Read b, Read c) => Read (a, b, c) | Since: base-2.1 |
| (Read (f a), Read (g a)) => Read (Product f g a) | Since: base-4.18.0.0 |
| (Read (f a), Read (g a)) => Read (Sum f g a) | Since: base-4.18.0.0 |
| a ~~ b => Read (a :~~: b) | Since: base-4.10.0.0 |
| (Read (f p), Read (g p)) => Read ((f :*: g) p) | Since: base-4.7.0.0 |
| (Read (f p), Read (g p)) => Read ((f :+: g) p) | Since: base-4.7.0.0 |
| Read c => Read (K1 i c p) | Since: base-4.7.0.0 |
| Read (f a) => Read (MP1 m f a) | |
| (Read a, Read b, Read c, Read d) => Read (a, b, c, d) | Since: base-2.1 |
| Read (f (g a)) => Read (Compose f g a) | Since: base-4.18.0.0 |
| Read (f (g p)) => Read ((f :.: g) p) | Since: base-4.7.0.0 |
| Read (f p) => Read (M1 i c f p) | Since: base-4.7.0.0 |
| Read (f (g x)) => Read ((f :.: g) x) | |
| (Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | Since: base-2.1 |
| (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | Since: base-2.1 |
Defined in GHC.Read | |
read :: Read a => String -> a #
The read function reads input from a string, which must be
completely consumed by the input process. read fails with an error if the
parse is unsuccessful, and it is therefore discouraged from being used in
real applications. Use readMaybe or readEither for safe alternatives.
>>>read "123" :: Int123
>>>read "hello" :: Int*** Exception: Prelude.read: no parse
The lex function reads a single lexeme from the input, discarding
initial white space, and returning the characters that constitute the
lexeme. If the input string contains only white space, lex returns a
single successful `lexeme' consisting of the empty string. (Thus
.) If there is no legal lexeme at the
beginning of the input string, lex "" = [("","")]lex fails (i.e. returns []).
This lexer is not completely faithful to the Haskell lexical syntax in the following respects:
- Qualified names are not handled properly
- Octal and hexadecimal numerics are not recognized as a single token
- Comments are not treated properly
Basic input and output
A value of type is a computation which, when performed,
does some I/O before returning a value of type IO aa.
There is really only one way to "perform" an I/O action: bind it to
Main.main in your program. When your program is run, the I/O will
be performed. It isn't possible to perform I/O from an arbitrary
function, unless that function is itself in the IO monad and called
at some point, directly or indirectly, from Main.main.
IO is a monad, so IO actions can be combined using either the do-notation
or the >> and >>= operations from the Monad
class.
Instances
print :: Show a => a -> IO () #
The print function outputs a value of any printable type to the
standard output device.
Printable types are those that are instances of class Show; print
converts values to strings for output using the show operation and
adds a newline.
For example, a program to print the first 20 integers and their powers of 2 could be written as:
main = print ([(n, 2^n) | n <- [0..19]])
getContents :: IO String #
The getContents operation returns all user input as a single string,
which is read lazily as it is needed
(same as hGetContents stdin).
interact :: (String -> String) -> IO () #
The interact function takes a function of type String->String
as its argument. The entire input from the standard input device is
passed to this function as its argument, and the resulting string is
output on the standard output device.
Files
File and directory names are values of type String, whose precise
meaning is operating system dependent. Files can be opened, yielding a
handle which can then be used to operate on the contents of that file.
readFile :: FilePath -> IO String #
The readFile function reads a file and
returns the contents of the file as a string.
The file is read lazily, on demand, as with getContents.
writeFile :: FilePath -> String -> IO () #
The computation writeFile file str function writes the string str,
to the file file.
appendFile :: FilePath -> String -> IO () #
The computation appendFile file str function appends the string str,
to the file file.
Note that writeFile and appendFile write a literal string
to a file. To write a value of any printable type, as with print,
use the show function to convert the value to a string first.
main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])
Using Ur values in linear code
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)
Instances
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 = ...Doing non-linear operations inside linear functions
class Consumable a where Source #
Instances
| Consumable All Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Any Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Void Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Int16 Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Int32 Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Int64 Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Int8 Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Word16 Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Word32 Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Word64 Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Word8 Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable ByteString Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances Methods consume :: ByteString %1 -> () Source # | |
| Consumable ShortByteString Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances Methods consume :: ShortByteString %1 -> () Source # | |
| Consumable Ordering Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Pool Source # | |
Defined in Foreign.Marshal.Pure.Internal | |
| Consumable Text Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Integer Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable Natural Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable () Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Bool Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Char Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Double Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Float Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Int Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable Word Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (First a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (Last a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (First a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (Last a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (Max a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (Min a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (WrappedMonoid a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable Methods consume :: WrappedMonoid a %1 -> () Source # | |
| Consumable a => Consumable (Dual a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (Product a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (Sum a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (NonEmpty a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| (Generic a, GConsumable (Rep a)) => Consumable (Generically a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable Methods consume :: Generically a %1 -> () Source # | |
| Consumable (Array a) Source # | |
Defined in Data.Array.Mutable.Linear.Internal | |
| Consumable (Replicator a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable Methods consume :: Replicator a %1 -> () Source # | |
| Consumable (Set a) Source # | |
Defined in Data.Set.Mutable.Linear.Internal | |
| Movable a => Consumable (AsMovable a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable (Ur a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable (Vector a) Source # | |
Defined in Data.Vector.Mutable.Linear.Internal | |
| Consumable a => Consumable (Vector a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (Maybe a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable (Solo a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable a => Consumable [a] Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| (Consumable e, Consumable a) => Consumable (Either e a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| (Consumable a, Consumable b) => Consumable (Arg a b) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable (HashMap k v) Source # | |
Defined in Data.HashMap.Mutable.Linear.Internal | |
| (KnownNat n, Consumable a) => Consumable (V n a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| Consumable (V 0 a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances | |
| (Consumable a, Consumable b) => Consumable (a, b) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable (f a) => Consumable (Ap f a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| Consumable (f a) => Consumable (Alt f a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| (Consumable a, Consumable b, Consumable c) => Consumable (a, b, c) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| (Consumable a, Consumable b, Consumable c, Consumable d) => Consumable (a, b, c, d) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
| (Consumable a, Consumable b, Consumable c, Consumable d, Consumable e) => Consumable (a, b, c, d, e) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
class Consumable a => Dupable a where Source #
The laws of Dupable are dual to those of Monoid:
- 1.
first consume (dup2 a) ≃ a ≃ second consume (dup2 a)(dup2neutrality) - 2.
first dup2 (dup2 a) ≃ (second dup2 (dup2 a))(dup2associativity)
where the (≃) sign represents equality up to type isomorphism.
- 3.
dup2 = Replicator.elim (,) . dupR(coherence betweendup2anddupR) - 4.
consume = Replicator.elim () . dupR(coherence betweenconsumeanddupR) - 5.
Replicator.extract . dupR = id(dupRidentity) - 6.
dupR . dupR = (Replicator.map dupR) . dupR(dupRinterchange)
(Laws 1-2 and 5-6 are equivalent)
Implementation of Dupable for Movable types should
be done with deriving via .AsMovable
Implementation of Dupable for other types can be done with
deriving via . Note that at present this mechanism
can have performance problems for recursive parameterized types.
Specifically, the methods will not specialize to underlying GenericallyDupable
instances. See this GHC issue.
Methods
dupR :: a %1 -> Replicator a Source #
Creates a Replicator for the given a.
You usually want to define this method using Replicator's
Applicative instance. For instance, here is an
implementation of :Dupable [a]
instance Dupable a => Dupable [a] where dupR [] = pure [] dupR (a : as) = (:) <$> dupR a <*> dupR as
dup2 :: a %1 -> (a, a) Source #
Creates two as from a , in a linear fashion.Dupable a
Instances
| Dupable All Source # | |
| Dupable Any Source # | |
| Dupable Int16 Source # | |
| Dupable Int32 Source # | |
| Dupable Int64 Source # | |
| Dupable Int8 Source # | |
| Dupable Word16 Source # | |
| Dupable Word32 Source # | |
| Dupable Word64 Source # | |
| Dupable Word8 Source # | |
| Dupable ByteString Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances Methods dupR :: ByteString %1 -> Replicator ByteString Source # dup2 :: ByteString %1 -> (ByteString, ByteString) Source # | |
| Dupable ShortByteString Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances Methods dupR :: ShortByteString %1 -> Replicator ShortByteString Source # dup2 :: ShortByteString %1 -> (ShortByteString, ShortByteString) Source # | |
| Dupable Ordering Source # | |
| Dupable Pool Source # | |
| Dupable Text Source # | |
| Dupable Integer Source # | |
| Dupable Natural Source # | |
| Dupable () Source # | |
Defined in Data.Unrestricted.Linear.Internal.Dupable | |
| Dupable Bool Source # | |
| Dupable Char Source # | |
| Dupable Double Source # | |
| Dupable Float Source # | |
| Dupable Int Source # | |
| Dupable Word Source # | |
| Dupable a => Dupable (Product a) Source # | |
| Dupable a => Dupable (Sum a) Source # | |
| Dupable a => Dupable (NonEmpty a) Source # | |
| (Generic a, GDupable (Rep a)) => Dupable (Generically a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Dupable Methods dupR :: Generically a %1 -> Replicator (Generically a) Source # dup2 :: Generically a %1 -> (Generically a, Generically a) Source # | |
| Dupable (Array a) Source # | |
| Dupable (Replicator a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Dupable Methods dupR :: Replicator a %1 -> Replicator (Replicator a) Source # dup2 :: Replicator a %1 -> (Replicator a, Replicator a) Source # | |
| Dupable (Set a) Source # | |
| Movable a => Dupable (AsMovable a) Source # | |
| Dupable (Ur a) Source # | |
| Dupable (Vector a) Source # | |
| Dupable a => Dupable (Maybe a) Source # | |
| Dupable a => Dupable (Solo a) Source # | |
| Dupable a => Dupable [a] Source # | |
Defined in Data.Unrestricted.Linear.Internal.Dupable | |
| (Dupable a, Dupable b) => Dupable (Either a b) Source # | |
| Dupable (HashMap k v) Source # | |
| (KnownNat n, Dupable a) => Dupable (V n a) Source # | |
| (Dupable a, Dupable b) => Dupable (a, b) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Dupable | |
| (Dupable a, Dupable b, Dupable c) => Dupable (a, b, c) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Dupable | |
| (Dupable a, Dupable b, Dupable c, Dupable d) => Dupable (a, b, c, d) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Dupable | |
| (Dupable a, Dupable b, Dupable c, Dupable d, Dupable e) => Dupable (a, b, c, d, e) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Dupable | |
class Dupable a => Movable a where Source #
Use to represent a type which can be used many times even
when given linearly. Simple data types such as Movable aBool or [] are Movable.
Though, bear in mind that this typically induces a deep copy of the value.
Formally, is the class of
coalgebras of the
Movable aUr 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 xcase move x of {Ur x -> (x, x)} = dup2 x
Instances
| Movable All Source # | |
| Movable Any Source # | |
| Movable Int16 Source # | |
| Movable Int32 Source # | |
| Movable Int64 Source # | |
| Movable Int8 Source # | |
| Movable Word16 Source # | |
| Movable Word32 Source # | |
| Movable Word64 Source # | |
| Movable Word8 Source # | |
| Movable ByteString Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances Methods move :: ByteString %1 -> Ur ByteString Source # | |
| Movable ShortByteString Source # | |
Defined in Data.Unrestricted.Linear.Internal.Instances Methods move :: ShortByteString %1 -> Ur ShortByteString Source # | |
| Movable Ordering Source # | |
| Movable Text Source # | |
| Movable Integer Source # | |
| Movable Natural Source # | |
| Movable () Source # | |
Defined in Data.Unrestricted.Linear.Internal.Movable | |
| Movable Bool Source # | |
| Movable Char Source # | |
| Movable Double Source # | |
| Movable Float Source # | |
| Movable Int Source # | |
| Movable Word Source # | |
| Movable a => Movable (Product a) Source # | |
| Movable a => Movable (Sum a) Source # | |
| Movable a => Movable (NonEmpty a) Source # | |
| (Generic a, GMovable (Rep a)) => Movable (Generically a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Movable Methods move :: Generically a %1 -> Ur (Generically a) Source # | |
| Movable a => Movable (AsMovable a) Source # | |
| Movable (Ur a) Source # | |
| Movable a => Movable (Maybe a) Source # | |
| Movable a => Movable (Solo a) Source # | |
| Movable a => Movable [a] Source # | |
Defined in Data.Unrestricted.Linear.Internal.Movable | |
| (Movable a, Movable b) => Movable (Either a b) Source # | |
| (Movable a, Movable b) => Movable (a, b) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Movable | |
| (Movable a, Movable b, Movable c) => Movable (a, b, c) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Movable | |
| (Movable a, Movable b, Movable c, Movable d) => Movable (a, b, c, d) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Movable | |
| (Movable a, Movable b, Movable c, Movable d, Movable e) => Movable (a, b, c, d, e) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Movable | |
lseq :: Consumable a => a %1 -> b %1 -> b infixr 0 Source #
Consume the first argument and return the second argument.
This is like seq but the first argument is restricted to be Consumable.