Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Tests.Core.Imports
Synopsis
- data Result
- = Success { }
- | GaveUp { }
- | Failure {
- numTests :: Int
- numDiscarded :: Int
- numShrinks :: Int
- numShrinkTries :: Int
- numShrinkFinal :: Int
- usedSeed :: QCGen
- usedSize :: Int
- reason :: String
- theException :: Maybe AnException
- output :: String
- failingTestCase :: [String]
- failingLabels :: [String]
- failingClasses :: Set String
- witnesses :: [Witness]
- | NoExpectedFailure { }
- class Testable prop where
- type ShowS = String -> String
- type String = [Char]
- data FUN
- data Bool
- data Char
- data Double
- data Float
- data Int
- data Word
- data Ordering
- data Maybe a
- class a ~# b => (a :: k) ~ (b :: k)
- data Integer
- data IO a
- type Type = TYPE LiftedRep
- type Constraint = CONSTRAINT LiftedRep
- class Show a where
- class Semigroup a => Monoid a where
- class Semigroup a where
- (<>) :: a -> a -> a
- class Functor f => Applicative (f :: Type -> Type) where
- class Functor (f :: Type -> Type) where
- class Applicative m => Monad (m :: Type -> Type) where
- data Fun a b = Fun (a :-> b, b, Shrunk) (a -> b)
- data Gen a
- class CoArbitrary a where
- coarbitrary :: a -> Gen b -> Gen b
- class Arbitrary2 (f :: Type -> Type -> Type) where
- liftArbitrary2 :: Gen a -> Gen b -> Gen (f a b)
- liftShrink2 :: (a -> [a]) -> (b -> [b]) -> f a b -> [f a b]
- class Arbitrary1 (f :: Type -> Type) where
- liftArbitrary :: Gen a -> Gen (f a)
- liftShrink :: (a -> [a]) -> f a -> [f a]
- class Arbitrary a where
- newtype PrintableString = PrintableString {}
- newtype UnicodeString = UnicodeString {}
- newtype ASCIIString = ASCIIString {}
- class ShrinkState s a where
- shrinkInit :: a -> s
- shrinkState :: a -> s -> [(a, s)]
- data Shrinking s a = Shrinking s a
- data Smart a = Smart Int a
- newtype Shrink2 a = Shrink2 {
- getShrink2 :: a
- newtype Small a = Small {
- getSmall :: a
- newtype Large a = Large {
- getLarge :: a
- newtype NonPositive a = NonPositive {
- getNonPositive :: a
- newtype NonNegative a = NonNegative {
- getNonNegative :: a
- newtype NonZero a = NonZero {
- getNonZero :: a
- newtype Negative a = Negative {
- getNegative :: a
- newtype Positive a = Positive {
- getPositive :: a
- newtype SortedList a = Sorted {
- getSorted :: [a]
- data InfiniteList a = InfiniteList {
- getInfiniteList :: [a]
- infiniteListInternalData :: InfiniteListInternalData a
- newtype NonEmptyList a = NonEmpty {
- getNonEmpty :: [a]
- newtype OrderedList a = Ordered {
- getOrdered :: [a]
- newtype Fixed a = Fixed {
- getFixed :: a
- newtype Blind a = Blind {
- getBlind :: a
- class Function a where
- data Confidence = Confidence {}
- data Witness = (Typeable a, Show a) => Wit a
- data Discard = Discard
- data Property
- data Args = Args {
- replay :: Maybe (QCGen, Int)
- maxSuccess :: Int
- maxDiscardRatio :: Int
- maxSize :: Int
- chatty :: Bool
- maxShrinks :: Int
- newtype PropertyM (m :: Type -> Type) a = MkPropertyM {
- unPropertyM :: (a -> Gen (m Property)) -> Gen (m Property)
- class Bounded a where
- 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 (Real a, Fractional a) => RealFrac a where
- class (Real a, Enum a) => Integral a where
- class Read a where
- class Eq a => Ord a where
- type Selector a = a -> Bool
- newtype S = S WORD
- newtype R = R WORD
- type Rational = Ratio Integer
- class Num a => Fractional a where
- (/) :: a -> a -> a
- recip :: a -> a
- fromRational :: Rational -> a
- class (Num a, Ord a) => Real a where
- toRational :: a -> Rational
- class Eq a where
- data Word8
- data Handle
- data Word64
- data Word32
- data Word16
- data Either a b
- class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where
- class Storable a where
- data Ptr a
- data TextEncoding
- type IOError = IOException
- class Fractional a => Floating a where
- class Num 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
- class Monad m => MonadFail (m :: Type -> Type) where
- class IsString a where
- fromString :: String -> a
- class Foldable (t :: Type -> Type) where
- foldMap :: Monoid m => (a -> m) -> t a -> m
- foldr :: (a -> b -> b) -> b -> t a -> b
- foldl :: (b -> a -> b) -> b -> t a -> b
- foldr1 :: (a -> a -> a) -> t a -> a
- foldl1 :: (a -> a -> a) -> t a -> a
- null :: t a -> Bool
- elem :: Eq a => a -> t a -> Bool
- maximum :: Ord a => t a -> a
- minimum :: Ord a => t a -> a
- sum :: Num a => t a -> a
- product :: Num a => t a -> a
- class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where
- traverse :: Applicative f => (a -> f b) -> t a -> f (t b)
- sequenceA :: Applicative f => t (f a) -> f (t a)
- mapM :: Monad m => (a -> m b) -> t a -> m (t b)
- sequence :: Monad m => t (m a) -> m (t a)
- type HasCallStack = ?callStack :: CallStack
- class Applicative f => Alternative (f :: Type -> Type) where
- class Bits b => FiniteBits b where
- finiteBitSize :: b -> Int
- countLeadingZeros :: b -> Int
- countTrailingZeros :: b -> Int
- class Eq a => Bits a where
- (.|.) :: a -> a -> a
- xor :: a -> a -> a
- complement :: a -> a
- shift :: a -> Int -> a
- rotate :: a -> Int -> a
- zeroBits :: a
- bit :: Int -> a
- setBit :: a -> Int -> a
- clearBit :: a -> Int -> a
- complementBit :: a -> Int -> a
- testBit :: a -> Int -> Bool
- bitSizeMaybe :: a -> Maybe Int
- bitSize :: a -> Int
- isSigned :: a -> Bool
- shiftL :: a -> Int -> a
- unsafeShiftL :: a -> Int -> a
- shiftR :: a -> Int -> a
- unsafeShiftR :: a -> Int -> a
- rotateL :: a -> Int -> a
- rotateR :: a -> Int -> a
- popCount :: a -> Int
- class (IsString fmt, Show fmt, Encodable fmt) => Format fmt where
- encodeByteString :: ByteString -> fmt
- decodeFormat :: fmt -> ByteString
- type ReadS a = String -> [(a, String)]
- newtype Iff a = Iff {
- getIff :: a
- newtype Xor a = Xor {
- getXor :: a
- newtype Ior a = Ior {
- getIor :: a
- newtype And a = And {
- getAnd :: a
- data KProxy t = KProxy
- data Proxy (t :: k) = Proxy
- data IOMode
- newtype Const a (b :: k) = Const {
- getConst :: a
- type FilePath = String
- data SeekMode
- data NewlineMode = NewlineMode {}
- data Newline
- data BufferMode
- data HandlePosn
- newtype ZipList a = ZipList {
- getZipList :: [a]
- newtype WrappedArrow (a :: Type -> Type -> Type) b c = WrapArrow {
- unwrapArrow :: a b c
- newtype WrappedMonad (m :: Type -> Type) a = WrapMonad {
- unwrapMonad :: m a
- class Example e where
- type Arg e
- type family Arg e
- data family Key p
- data ByteString
- type ActionWith a = a -> IO ()
- type SpecWith a = SpecM a ()
- type Spec = SpecWith ()
- type Expectation = Assertion
- data Tuple (dim :: Nat) a
- class (Unbox (WordType p), EndianStore (WordType p), KnownNat (WordsPerBlock p)) => Primitive p where
- type WordType p
- type WordsPerBlock p :: Nat
- newtype Poly1305 = Poly1305 WORD
- data BYTES a
- class ByteSource src where
- data FillResult a
- class ByteSource src => PureByteSource src
- data Base16
- data Base64
- class Encodable a where
- toByteString :: a -> ByteString
- fromByteString :: ByteString -> Maybe a
- unsafeFromByteString :: ByteString -> a
- data Access
- type Alloc mem = TwistRF AllocField (BYTES Int) mem
- class Memory m => Extractable m v where
- class Memory m => Initialisable m v where
- initialise :: v -> m -> IO ()
- class Memory m where
- memoryAlloc :: Alloc m
- unsafeToPointer :: m -> Ptr Word8
- data MemoryCell a
- class Memory mem => ReadAccessible mem where
- beforeReadAdjustment :: mem -> IO ()
- readAccess :: mem -> [Access]
- data VoidMemory
- class Memory mem => WriteAccessible mem where
- writeAccess :: mem -> [Access]
- afterWriteAdjustment :: mem -> IO ()
- type AlignedBlockPtr (n :: Nat) p = AlignedPtr n (Block p)
- type Block p = Tuple (WordsPerBlock p) (WordType p)
- newtype BlockCount p = BlockCount {
- unBlockCount :: Int
- type BlockPtr p = Ptr (Block p)
- data family Nounce p
- type family WordType p
- type family WordsPerBlock p :: Nat
- type ReadFrom = Transfer 'ReadFromBuffer
- type Transfer (t :: Mode) = SemiR (TransferAction t) (BYTES Int)
- type WriteTo = Transfer 'WriteToBuffer
- data Dest a
- data Src a
- data BE w
- class Storable w => EndianStore w where
- data LE w
- class Equality a where
- eq :: a -> a -> Result
- data AlignedPtr (n :: Nat) a
- class (Enum u, Monoid u) => LengthUnit u where
- class Pointer (ptr :: Type -> Type) where
- castPointer :: ptr a -> ptr b
- allocaPointer :: BYTES Int -> (ptr a -> IO b) -> IO b
- unsafeRawPtr :: ptr a -> Ptr a
- type Dimension (dim :: Nat) = KnownNat dim
- type Blake2b = Blake2 (LE Word64)
- type Blake2bMem = HashMemory128 Blake2b
- type Blake2s = Blake2 (LE Word32)
- type Blake2sMem = HashMemory64 Blake2s
- data ChaCha20 = ChaCha20
- data XChaCha20 = XChaCha20
- data ChaCha20Mem = ChaCha20Mem {
- keyCell :: MemoryCell (Key ChaCha20)
- ivCell :: MemoryCell (Nounce ChaCha20)
- counterCell :: MemoryCell WORD
- type WORD = Tuple 2 (LE Word64)
- type Sha256 = Sha2 (BE Word32)
- type Sha256Mem = HashMemory64 Sha256
- type Sha512 = Sha2 (BE Word64)
- type Sha512Mem = HashMemory128 Sha512
- pattern Fn3 :: (a -> b -> c -> d) -> Fun (a, b, c) d
- pattern Fn2 :: (a -> b -> c) -> Fun (a, b) c
- pattern Fn :: (a -> b) -> Fun a b
- hspec :: Spec -> IO ()
- vector :: Arbitrary a => Int -> Gen [a]
- assert :: forall (m :: Type -> Type). Monad m => Bool -> PropertyM m ()
- (==>) :: Testable prop => Bool -> prop -> Property
- ($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- otherwise :: Bool
- (++) :: [a] -> [a] -> [a]
- map :: (a -> b) -> [a] -> [b]
- join :: Monad m => m (m a) -> m a
- discard :: a
- variant :: Integral n => n -> Gen a -> Gen a
- sized :: (Int -> Gen a) -> Gen a
- getSize :: Gen Int
- resize :: HasCallStack => Int -> Gen a -> Gen a
- scale :: (Int -> Int) -> Gen a -> Gen a
- choose :: Random a => (a, a) -> Gen a
- chooseAny :: Random a => Gen a
- chooseEnum :: Enum a => (a, a) -> Gen a
- chooseInt :: (Int, Int) -> Gen Int
- chooseBoundedIntegral :: (Bounded a, Integral a) => (a, a) -> Gen a
- chooseInteger :: (Integer, Integer) -> Gen Integer
- generate :: Gen a -> IO a
- sample' :: Gen a -> IO [a]
- sample :: Show a => Gen a -> IO ()
- suchThat :: Gen a -> (a -> Bool) -> Gen a
- suchThatMap :: Gen a -> (a -> Maybe b) -> Gen b
- suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a)
- oneof :: HasCallStack => [Gen a] -> Gen a
- frequency :: HasCallStack => [(Int, Gen a)] -> Gen a
- elements :: HasCallStack => [a] -> Gen a
- sublistOf :: [a] -> Gen [a]
- shuffle :: [a] -> Gen [a]
- growingElements :: HasCallStack => [a] -> Gen a
- listOf :: Gen a -> Gen [a]
- listOf1 :: Gen a -> Gen [a]
- vectorOf :: Int -> Gen a -> Gen [a]
- infiniteListOf :: Gen a -> Gen [a]
- arbitrary1 :: (Arbitrary1 f, Arbitrary a) => Gen (f a)
- shrink1 :: (Arbitrary1 f, Arbitrary a) => f a -> [f a]
- arbitrary2 :: (Arbitrary2 f, Arbitrary a, Arbitrary b) => Gen (f a b)
- shrink2 :: (Arbitrary2 f, Arbitrary a, Arbitrary b) => f a b -> [f a b]
- genericShrink :: (Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) => a -> [a]
- recursivelyShrink :: (Generic a, RecursivelyShrink (Rep a)) => a -> [a]
- subterms :: (Generic a, GSubterms (Rep a) a) => a -> [a]
- shrinkList :: (a -> [a]) -> [a] -> [[a]]
- applyArbitrary2 :: (Arbitrary a, Arbitrary b) => (a -> b -> r) -> Gen r
- applyArbitrary3 :: (Arbitrary a, Arbitrary b, Arbitrary c) => (a -> b -> c -> r) -> Gen r
- applyArbitrary4 :: (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d) => (a -> b -> c -> d -> r) -> Gen r
- arbitrarySizedIntegral :: Integral a => Gen a
- arbitrarySizedNatural :: Integral a => Gen a
- arbitrarySizedFractional :: Fractional a => Gen a
- arbitraryBoundedIntegral :: (Bounded a, Integral a) => Gen a
- arbitraryBoundedRandom :: (Bounded a, Random a) => Gen a
- arbitraryBoundedEnum :: (Bounded a, Enum a) => Gen a
- arbitrarySizedBoundedIntegral :: (Bounded a, Integral a) => Gen a
- arbitraryUnicodeChar :: Gen Char
- arbitraryASCIIChar :: Gen Char
- arbitraryPrintableChar :: Gen Char
- shrinkNothing :: a -> [a]
- shrinkMap :: Arbitrary a => (a -> b) -> (b -> a) -> b -> [b]
- shrinkMapBy :: (a -> b) -> (b -> a) -> (a -> [a]) -> b -> [b]
- shrinkIntegral :: Integral a => a -> [a]
- shrinkBoundedEnum :: (Bounded a, Enum a, Eq a) => a -> [a]
- shrinkRealFrac :: RealFrac a => a -> [a]
- shrinkDecimal :: RealFrac a => a -> [a]
- genericCoarbitrary :: (Generic a, GCoArbitrary (Rep a)) => a -> Gen b -> Gen b
- (><) :: (Gen a -> Gen a) -> (Gen a -> Gen a) -> Gen a -> Gen a
- coarbitraryIntegral :: Integral a => a -> Gen b -> Gen b
- coarbitraryReal :: Real a => a -> Gen b -> Gen b
- coarbitraryShow :: Show a => a -> Gen b -> Gen b
- coarbitraryEnum :: Enum a => a -> Gen b -> Gen b
- orderedList :: (Ord a, Arbitrary a) => Gen [a]
- infiniteList :: Arbitrary a => Gen [a]
- functionBoundedEnum :: (Eq a, Bounded a, Enum a) => (a -> b) -> a :-> b
- functionRealFrac :: RealFrac a => (a -> b) -> a :-> b
- functionIntegral :: Integral a => (a -> b) -> a :-> b
- functionShow :: (Show a, Read a) => (a -> c) -> a :-> c
- functionVoid :: (forall b. void -> b) -> void :-> c
- functionMap :: Function b => (a -> b) -> (b -> a) -> (a -> c) -> a :-> c
- applyFun :: Fun a b -> a -> b
- applyFun2 :: Fun (a, b) c -> a -> b -> c
- applyFun3 :: Fun (a, b, c) d -> a -> b -> c -> d
- ioProperty :: Testable prop => IO prop -> Property
- idempotentIOProperty :: Testable prop => IO prop -> Property
- coerceWitness :: Typeable a => Witness -> a
- castWitness :: Typeable a => Witness -> Maybe a
- mapSize :: Testable prop => (Int -> Int) -> prop -> Property
- shrinking :: Testable prop => (a -> [a]) -> a -> (a -> prop) -> Property
- noShrinking :: Testable prop => prop -> Property
- counterexample :: Testable prop => String -> prop -> Property
- printTestCase :: Testable prop => String -> prop -> Property
- whenFail :: Testable prop => IO () -> prop -> Property
- whenFail' :: Testable prop => IO () -> prop -> Property
- verbose :: Testable prop => prop -> Property
- verboseShrinking :: Testable prop => prop -> Property
- expectFailure :: Testable prop => prop -> Property
- once :: Testable prop => prop -> Property
- again :: Testable prop => prop -> Property
- withMaxSuccess :: Testable prop => Int -> prop -> Property
- withDiscardRatio :: Testable prop => Int -> prop -> Property
- withMaxShrinks :: Testable prop => Int -> prop -> Property
- withMaxSize :: Testable prop => Int -> prop -> Property
- witness :: (Typeable a, Show a, Testable prop) => a -> prop -> Property
- checkCoverage :: Testable prop => prop -> Property
- checkCoverageWith :: Testable prop => Confidence -> prop -> Property
- stdConfidence :: Confidence
- label :: Testable prop => String -> prop -> Property
- collect :: (Show a, Testable prop) => a -> prop -> Property
- classify :: Testable prop => Bool -> String -> prop -> Property
- cover :: Testable prop => Double -> Bool -> String -> prop -> Property
- tabulate :: Testable prop => String -> [String] -> prop -> Property
- coverTable :: Testable prop => String -> [(String, Double)] -> prop -> Property
- within :: Testable prop => Int -> prop -> Property
- discardAfter :: Testable prop => Int -> prop -> Property
- forAll :: (Show a, Testable prop) => Gen a -> (a -> prop) -> Property
- forAllShow :: Testable prop => Gen a -> (a -> String) -> (a -> prop) -> Property
- forAllBlind :: Testable prop => Gen a -> (a -> prop) -> Property
- forAllShrink :: (Show a, Testable prop) => Gen a -> (a -> [a]) -> (a -> prop) -> Property
- forAllShrinkShow :: Testable prop => Gen a -> (a -> [a]) -> (a -> String) -> (a -> prop) -> Property
- forAllShrinkBlind :: Testable prop => Gen a -> (a -> [a]) -> (a -> prop) -> Property
- (.&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property
- (.&&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property
- conjoin :: Testable prop => [prop] -> Property
- (.||.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property
- disjoin :: Testable prop => [prop] -> Property
- (===) :: (Eq a, Show a) => a -> a -> Property
- (=/=) :: (Eq a, Show a) => a -> a -> Property
- total :: NFData a => a -> Property
- isSuccess :: Result -> Bool
- stdArgs :: Args
- quickCheck :: Testable prop => prop -> IO ()
- quickCheckWith :: Testable prop => Args -> prop -> IO ()
- quickCheckResult :: Testable prop => prop -> IO Result
- quickCheckWithResult :: Testable prop => Args -> prop -> IO Result
- recheck :: Testable prop => Result -> prop -> IO ()
- verboseCheck :: Testable prop => prop -> IO ()
- verboseCheckWith :: Testable prop => Args -> prop -> IO ()
- verboseCheckResult :: Testable prop => prop -> IO Result
- verboseCheckWithResult :: Testable prop => Args -> prop -> IO Result
- stop :: forall prop (m :: Type -> Type) a. (Testable prop, Monad m) => prop -> PropertyM m a
- assertWith :: forall (m :: Type -> Type). Monad m => Bool -> String -> PropertyM m ()
- pre :: forall (m :: Type -> Type). Monad m => Bool -> PropertyM m ()
- run :: Monad m => m a -> PropertyM m a
- pick :: forall (m :: Type -> Type) a. (Monad m, Show a) => Gen a -> PropertyM m a
- wp :: Monad m => m a -> (a -> PropertyM m b) -> PropertyM m b
- forAllM :: forall (m :: Type -> Type) a b. (Monad m, Show a) => Gen a -> (a -> PropertyM m b) -> PropertyM m b
- monitor :: forall (m :: Type -> Type). Monad m => (Property -> Property) -> PropertyM m ()
- monadic :: (Testable a, Monad m) => (m Property -> Property) -> PropertyM m a -> Property
- monadic' :: (Testable a, Monad m) => PropertyM m a -> Gen (m Property)
- monadicIO :: Testable a => PropertyM IO a -> Property
- monadicST :: Testable a => (forall s. PropertyM (ST s) a) -> Property
- runSTGen :: (forall s. Gen (ST s a)) -> Gen a
- assertException :: Exception exc => (exc -> Bool) -> a -> Property
- assertExceptionIO :: Exception exc => (exc -> Bool) -> IO a -> Property
- assertDeepException :: (NFData a, Exception exc) => (exc -> Bool) -> a -> Property
- assertDeepExceptionIO :: (NFData a, Exception exc) => (exc -> Bool) -> IO a -> Property
- polyQuickCheck :: Name -> ExpQ
- polyVerboseCheck :: Name -> ExpQ
- monomorphic :: Name -> ExpQ
- forAllProperties :: Q Exp
- allProperties :: Q Exp
- quickCheckAll :: Q Exp
- verboseCheckAll :: Q Exp
- labelledExamples :: Testable prop => prop -> IO ()
- labelledExamplesWith :: Testable prop => Args -> prop -> IO ()
- labelledExamplesResult :: Testable prop => prop -> IO Result
- labelledExamplesWithResult :: Testable prop => Args -> prop -> IO Result
- realToFrac :: (Real a, Fractional b) => a -> b
- fromIntegral :: (Integral a, Num b) => a -> b
- hIsTerminalDevice :: Handle -> IO Bool
- stdout :: Handle
- stdin :: Handle
- error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a
- zipWith :: forall a b c (dim :: Nat). (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Tuple dim a -> Tuple dim b -> Tuple dim c
- even :: Integral a => a -> Bool
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- hGetContents :: Handle -> IO String
- fst :: (a, b) -> a
- uncurry :: (a -> b -> c) -> (a, b) -> c
- openFile :: FilePath -> IOMode -> IO Handle
- length :: ByteString -> BYTES Int
- id :: a -> a
- head :: HasCallStack => [a] -> a
- forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
- stderr :: Handle
- forever :: Applicative f => f a -> f b
- utf8 :: TextEncoding
- mkTextEncoding :: String -> IO TextEncoding
- hSeek :: Handle -> SeekMode -> Integer -> IO ()
- hFlush :: Handle -> IO ()
- hLookAhead :: Handle -> IO Char
- fixIO :: (a -> IO a) -> IO a
- sizeOf :: Storable a => Proxy a -> BYTES Int
- readFile' :: FilePath -> IO String
- writeFile :: FilePath -> String -> IO ()
- getLine :: IO String
- putStrLn :: String -> IO ()
- hClose :: Handle -> IO ()
- hSetBinaryMode :: Handle -> Bool -> IO ()
- localeEncoding :: TextEncoding
- liftM :: Monad m => (a1 -> r) -> m a1 -> m r
- filter :: (a -> Bool) -> [a] -> [a]
- hGetBuf :: Handle -> Ptr a -> Int -> IO Int
- hPutBuf :: Handle -> Ptr a -> Int -> IO ()
- hWaitForInput :: Handle -> Int -> IO Bool
- cycle :: HasCallStack => [a] -> [a]
- seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b
- concat :: Foldable t => t [a] -> [a]
- zip :: [a] -> [b] -> [(a, b)]
- print :: Show a => a -> IO ()
- guard :: Alternative f => Bool -> f ()
- (^) :: (Num a, Integral b) => a -> b -> a
- (&&) :: Bool -> Bool -> Bool
- (||) :: Bool -> Bool -> Bool
- not :: Bool -> Bool
- errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a
- undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- liftA :: Applicative f => (a -> b) -> f a -> f b
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- when :: Applicative f => Bool -> f () -> f ()
- liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
- liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
- liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
- liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r
- ap :: Monad m => m (a -> b) -> m a -> m b
- const :: a -> b -> a
- (.) :: (b -> c) -> (a -> b) -> a -> c
- flip :: (a -> b -> c) -> b -> a -> c
- ($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b
- until :: (a -> Bool) -> (a -> a) -> a -> a
- asTypeOf :: a -> a -> a
- subtract :: Num a => a -> a -> a
- maybe :: b -> (a -> b) -> Maybe a -> b
- isJust :: Maybe a -> Bool
- isNothing :: Maybe a -> Bool
- fromJust :: HasCallStack => Maybe a -> a
- fromMaybe :: a -> Maybe a -> a
- maybeToList :: Maybe a -> [a]
- listToMaybe :: [a] -> Maybe a
- catMaybes :: [Maybe a] -> [a]
- mapMaybe :: (a -> Maybe b) -> [a] -> [b]
- tail :: HasCallStack => [a] -> [a]
- last :: HasCallStack => [a] -> a
- init :: HasCallStack => [a] -> [a]
- scanl :: (b -> a -> b) -> b -> [a] -> [b]
- scanl1 :: (a -> a -> a) -> [a] -> [a]
- scanr :: (a -> b -> b) -> b -> [a] -> [b]
- scanr1 :: (a -> a -> a) -> [a] -> [a]
- iterate :: (a -> a) -> a -> [a]
- repeat :: a -> [a]
- replicate :: LengthUnit l => l -> Word8 -> ByteString
- takeWhile :: (a -> Bool) -> [a] -> [a]
- dropWhile :: (a -> Bool) -> [a] -> [a]
- take :: Int -> [a] -> [a]
- drop :: Int -> [a] -> [a]
- splitAt :: Int -> [a] -> ([a], [a])
- span :: (a -> Bool) -> [a] -> ([a], [a])
- break :: (a -> Bool) -> [a] -> ([a], [a])
- reverse :: [a] -> [a]
- and :: Foldable t => t Bool -> Bool
- or :: Foldable t => t Bool -> Bool
- any :: Foldable t => (a -> Bool) -> t a -> Bool
- all :: Foldable t => (a -> Bool) -> t a -> Bool
- notElem :: (Foldable t, Eq a) => a -> t a -> Bool
- lookup :: Eq a => a -> [(a, b)] -> Maybe b
- concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
- (!!) :: HasCallStack => [a] -> Int -> a
- zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
- zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
- unzip :: [(a, b)] -> ([a], [b])
- unzip3 :: [(a, b, c)] -> ([a], [b], [c])
- shows :: Show a => a -> ShowS
- showChar :: Char -> ShowS
- showString :: String -> ShowS
- showParen :: Bool -> ShowS -> ShowS
- odd :: Integral a => a -> Bool
- (^^) :: (Fractional a, Integral b) => a -> b -> a
- gcd :: Integral a => a -> a -> a
- lcm :: Integral a => a -> a -> a
- bitDefault :: (Bits a, Num a) => Int -> a
- testBitDefault :: (Bits a, Num a) => a -> Int -> Bool
- popCountDefault :: (Bits a, Num a) => a -> Int
- toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
- byteSwap16 :: Word16 -> Word16
- byteSwap32 :: Word32 -> Word32
- byteSwap64 :: Word64 -> Word64
- bitReverse8 :: Word8 -> Word8
- bitReverse16 :: Word16 -> Word16
- bitReverse32 :: Word32 -> Word32
- bitReverse64 :: Word64 -> Word64
- fill :: (Pointer ptr, LengthUnit len, ByteSource src) => len -> src -> ptr a -> IO (FillResult src)
- snd :: (a, b) -> b
- curry :: ((a, b) -> c) -> a -> b -> c
- void :: Functor f => f a -> f ()
- optional :: Alternative f => f a -> f (Maybe a)
- lex :: ReadS String
- readParen :: Bool -> ReadS a -> ReadS a
- alignPtr :: Storable a => Ptr a -> Alignment -> Ptr a
- either :: (a -> c) -> (b -> c) -> Either a b -> c
- reads :: Read a => ReadS a
- read :: Read a => String -> a
- oneBits :: FiniteBits a => a
- (.^.) :: Bits a => a -> a -> a
- (.>>.) :: Bits a => a -> Int -> a
- (.<<.) :: Bits a => a -> Int -> a
- (!>>.) :: Bits a => a -> Int -> a
- (!<<.) :: Bits a => a -> Int -> a
- alignment :: Storable a => Proxy a -> Alignment
- asProxyTypeOf :: a -> proxy a -> a
- mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
- forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
- sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
- asum :: (Foldable t, Alternative f) => t (f a) -> f a
- msum :: (Foldable t, MonadPlus m) => t (m a) -> m a
- lines :: String -> [String]
- unlines :: [String] -> String
- words :: String -> [String]
- unwords :: [String] -> String
- userError :: String -> IOError
- encode :: (Encodable a, Format fmt) => a -> fmt
- write :: EndianStore a => a -> WriteTo
- nativeNewline :: Newline
- universalNewlineMode :: NewlineMode
- nativeNewlineMode :: NewlineMode
- noNewlineTranslation :: NewlineMode
- ioError :: IOError -> IO a
- utf8_bom :: TextEncoding
- utf32 :: TextEncoding
- utf32be :: TextEncoding
- utf32le :: TextEncoding
- utf16 :: TextEncoding
- utf16be :: TextEncoding
- utf16le :: TextEncoding
- latin1 :: TextEncoding
- char8 :: TextEncoding
- memcpy :: (LengthUnit l, Pointer ptrS, Pointer ptrD) => Dest (ptrD dest) -> Src (ptrS src) -> l -> IO ()
- hGetChar :: Handle -> IO Char
- hGetLine :: Handle -> IO String
- hGetContents' :: Handle -> IO String
- hPutChar :: Handle -> Char -> IO ()
- hPutStr :: Handle -> String -> IO ()
- hPutStrLn :: Handle -> String -> IO ()
- hPutBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int
- hGetBufSome :: Handle -> Ptr a -> Int -> IO Int
- hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int
- withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r
- openBinaryFile :: FilePath -> IOMode -> IO Handle
- withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r
- hFileSize :: Handle -> IO Integer
- hSetFileSize :: Handle -> Integer -> IO ()
- hIsEOF :: Handle -> IO Bool
- isEOF :: IO Bool
- hSetBuffering :: Handle -> BufferMode -> IO ()
- hSetEncoding :: Handle -> TextEncoding -> IO ()
- hGetEncoding :: Handle -> IO (Maybe TextEncoding)
- hGetPosn :: Handle -> IO HandlePosn
- hSetPosn :: HandlePosn -> IO ()
- hTell :: Handle -> IO Integer
- hIsOpen :: Handle -> IO Bool
- hIsClosed :: Handle -> IO Bool
- hIsReadable :: Handle -> IO Bool
- hIsWritable :: Handle -> IO Bool
- hGetBuffering :: Handle -> IO BufferMode
- hIsSeekable :: Handle -> IO Bool
- hSetEcho :: Handle -> Bool -> IO ()
- hGetEcho :: Handle -> IO Bool
- hSetNewlineMode :: Handle -> NewlineMode -> IO ()
- hShow :: Handle -> IO String
- putChar :: Char -> IO ()
- putStr :: String -> IO ()
- getChar :: IO Char
- getContents :: IO String
- getContents' :: IO String
- interact :: (String -> String) -> IO ()
- readFile :: FilePath -> IO String
- appendFile :: FilePath -> String -> IO ()
- readLn :: Read a => IO a
- readIO :: Read a => String -> IO a
- hReady :: Handle -> IO Bool
- hPrint :: Show a => Handle -> a -> IO ()
- openTempFile :: FilePath -> String -> IO (FilePath, Handle)
- openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle)
- openTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle)
- openBinaryTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle)
- filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a]
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])
- zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c]
- zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m ()
- foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
- foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m ()
- replicateM :: Applicative m => Int -> m a -> m [a]
- replicateM_ :: Applicative m => Int -> m a -> m ()
- unless :: Applicative f => Bool -> f () -> f ()
- (<$!>) :: Monad m => (a -> b) -> m a -> m b
- mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a
- runIO :: IO r -> SpecM a r
- decode :: (Format fmt, Encodable a) => fmt -> Maybe a
- atMost :: (LengthUnit src, LengthUnit dest) => src -> dest
- create :: LengthUnit l => l -> (Ptr a -> IO ()) -> IO ByteString
- memset :: (LengthUnit l, Pointer ptr) => ptr a -> Word8 -> l -> IO ()
- pack :: [Word8] -> ByteString
- modifyMaxSuccess :: (Int -> Int) -> SpecWith a -> SpecWith a
- modifyMaxDiscardRatio :: (Int -> Int) -> SpecWith a -> SpecWith a
- modifyMaxSize :: (Int -> Int) -> SpecWith a -> SpecWith a
- modifyMaxShrinks :: (Int -> Int) -> SpecWith a -> SpecWith a
- modifyArgs :: (Args -> Args) -> SpecWith a -> SpecWith a
- before :: IO a -> SpecWith a -> Spec
- before_ :: IO () -> SpecWith a -> SpecWith a
- beforeWith :: (b -> IO a) -> SpecWith a -> SpecWith b
- beforeAll :: HasCallStack => IO a -> SpecWith a -> Spec
- beforeAll_ :: HasCallStack => IO () -> SpecWith a -> SpecWith a
- beforeAllWith :: HasCallStack => (b -> IO a) -> SpecWith a -> SpecWith b
- after :: ActionWith a -> SpecWith a -> SpecWith a
- after_ :: IO () -> SpecWith a -> SpecWith a
- around :: (ActionWith a -> IO ()) -> SpecWith a -> Spec
- afterAll :: HasCallStack => ActionWith a -> SpecWith a -> SpecWith a
- afterAll_ :: HasCallStack => IO () -> SpecWith a -> SpecWith a
- around_ :: (IO () -> IO ()) -> SpecWith a -> SpecWith a
- aroundWith :: (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b
- aroundAll :: HasCallStack => (ActionWith a -> IO ()) -> SpecWith a -> Spec
- aroundAll_ :: HasCallStack => (IO () -> IO ()) -> SpecWith a -> SpecWith a
- aroundAllWith :: HasCallStack => (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b
- mapSubject :: (b -> a) -> SpecWith a -> SpecWith b
- ignoreSubject :: SpecWith () -> SpecWith a
- describe :: HasCallStack => String -> SpecWith a -> SpecWith a
- context :: HasCallStack => String -> SpecWith a -> SpecWith a
- xdescribe :: HasCallStack => String -> SpecWith a -> SpecWith a
- xcontext :: HasCallStack => String -> SpecWith a -> SpecWith a
- it :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- specify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- xit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- xspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- focus :: SpecWith a -> SpecWith a
- fit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- fspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a)
- fdescribe :: HasCallStack => String -> SpecWith a -> SpecWith a
- fcontext :: HasCallStack => String -> SpecWith a -> SpecWith a
- parallel :: SpecWith a -> SpecWith a
- sequential :: SpecWith a -> SpecWith a
- pending :: HasCallStack => Expectation
- pendingWith :: HasCallStack => String -> Expectation
- example :: Expectation -> Expectation
- prop :: (HasCallStack, Testable prop) => String -> prop -> Spec
- xprop :: (HasCallStack, Testable prop) => String -> prop -> Spec
- fprop :: (HasCallStack, Testable prop) => String -> prop -> Spec
- expectationFailure :: HasCallStack => String -> Expectation
- shouldBe :: (HasCallStack, Show a, Eq a) => a -> a -> Expectation
- shouldSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> Expectation
- shouldStartWith :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- shouldEndWith :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- shouldContain :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- shouldMatchList :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- shouldReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> Expectation
- shouldNotBe :: (HasCallStack, Show a, Eq a) => a -> a -> Expectation
- shouldNotSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> Expectation
- shouldNotContain :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation
- shouldNotReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> Expectation
- shouldThrow :: (HasCallStack, Exception e) => IO a -> Selector e -> Expectation
- anyException :: Selector SomeException
- anyErrorCall :: Selector ErrorCall
- errorCall :: String -> Selector ErrorCall
- anyIOException :: Selector IOException
- anyArithException :: Selector ArithException
- movePtr :: LengthUnit l => Ptr a -> l -> Ptr a
- translate :: (Format fmt1, Format fmt2) => fmt1 -> fmt2
- unsafeFromList :: forall a (dim :: Nat). (Unbox a, Dimension dim) => [a] -> Tuple dim a
- processChunks :: (Pointer ptr, MonadIO m, LengthUnit chunkSize, ByteSource src) => m a -> (BYTES Int -> m b) -> src -> ptr something -> chunkSize -> m b
- withFillResult :: (a -> b) -> (BYTES Int -> b) -> FillResult a -> b
- l1Cache :: BYTES Int
- unsafeDecode :: (Format fmt, Encodable a) => fmt -> a
- fromBase16 :: Encodable a => String -> a
- showBase16 :: Encodable a => a -> String
- copyCell :: Storable a => Dest (MemoryCell a) -> Src (MemoryCell a) -> IO ()
- memTransfer :: (ReadAccessible src, WriteAccessible dest) => Dest dest -> Src src -> IO ()
- modifyMem :: (Initialisable mem a, Extractable mem b) => (b -> a) -> mem -> IO ()
- pointerAlloc :: LengthUnit l => l -> Alloc (Ptr Word8)
- unsafeGetCellPointer :: Storable a => MemoryCell a -> Ptr a
- withCellPointer :: Storable a => (Ptr a -> IO b) -> MemoryCell a -> IO b
- withMemory :: Memory mem => (mem -> IO a) -> IO a
- withMemoryPtr :: Memory m => (BYTES Int -> Ptr Word8 -> IO a) -> m -> IO a
- withSecureMemory :: Memory mem => (mem -> IO a) -> IO a
- blocksOf :: Int -> Proxy p -> BlockCount p
- consume :: EndianStore a => (a -> IO b) -> ReadFrom
- consumeParse :: Parser a -> (a -> IO b) -> ReadFrom
- consumeStorable :: Storable a => (a -> IO b) -> ReadFrom
- glueWrites :: LengthUnit n => Word8 -> n -> WriteTo -> WriteTo -> WriteTo
- padWrite :: LengthUnit n => Word8 -> n -> WriteTo -> WriteTo
- prependWrite :: LengthUnit n => Word8 -> n -> WriteTo -> WriteTo
- skip :: forall l (t :: Mode). LengthUnit l => l -> Transfer t
- writeBytes :: LengthUnit n => Word8 -> n -> WriteTo
- writeEncodable :: Encodable a => a -> WriteTo
- writeStorable :: Storable a => a -> WriteTo
- writeStorableVector :: (Storable a, Vector v a) => v a -> WriteTo
- writeVector :: (EndianStore a, Vector v a) => v a -> WriteTo
- transferSize :: forall (t :: Mode). Transfer t -> BYTES Int
- writeByteString :: ByteString -> WriteTo
- destination :: a -> Dest a
- source :: a -> Src a
- bigEndian :: w -> BE w
- copyFromBytes :: EndianStore w => Dest (Ptr w) -> Src (Ptr Word8) -> Int -> IO ()
- copyToBytes :: EndianStore w => Dest (Ptr Word8) -> Src (Ptr w) -> Int -> IO ()
- littleEndian :: w -> LE w
- loadFrom :: (EndianStore w, LengthUnit offset) => Ptr w -> offset -> IO w
- loadFromIndex :: EndianStore w => Ptr w -> Int -> IO w
- storeAt :: (EndianStore w, LengthUnit offset) => Ptr w -> offset -> w -> IO ()
- storeAtIndex :: EndianStore w => Ptr w -> Int -> w -> IO ()
- alignedSizeOf :: Storable a => Proxy a -> BYTES Int
- allocaBuffer :: (LengthUnit l, Pointer ptr) => l -> (ptr something -> IO b) -> IO b
- allocaSecure :: (LengthUnit l, Pointer ptr) => l -> (ptr a -> IO b) -> IO b
- atLeast :: (LengthUnit src, LengthUnit dest) => src -> dest
- atLeastAligned :: LengthUnit l => l -> Alignment -> BYTES Int
- hFillBuf :: (LengthUnit bufSize, Pointer ptr) => Handle -> ptr a -> bufSize -> IO (BYTES Int)
- nextAlignedPtr :: forall a (n :: Nat). (Storable a, KnownNat n) => Ptr a -> AlignedPtr n a
- nextLocation :: Storable a => Ptr a -> Ptr a
- peekAligned :: Storable a => Ptr a -> IO a
- pokeAligned :: Storable a => Ptr a -> a -> IO ()
- ptrAlignment :: forall (n :: Nat) a. KnownNat n => Proxy (AlignedPtr n a) -> Alignment
- unsafeWithPointer :: Pointer ptr => (Ptr a -> b) -> ptr a -> b
- unsafeWithPointerCast :: Pointer ptr => (Ptr a -> b) -> ptr something -> b
- wipeMemory :: (LengthUnit l, Pointer ptr) => ptr a -> l -> IO ()
- diagonal :: forall a (dim :: Nat). (Unbox a, Dimension dim) => a -> Tuple dim a
- dimension :: forall (dim :: Nat) a. Dimension dim => Tuple dim a -> Int
- dimension' :: forall (dim :: Nat) a. Dimension dim => Proxy (Tuple dim a) -> Int
- generateIO :: forall (dim :: Nat) a. (Dimension dim, Unbox a) => IO a -> IO (Tuple dim a)
- initial :: forall a (dim0 :: Nat) (dim1 :: Nat). (Unbox a, Dimension dim0) => Tuple dim1 a -> Tuple dim0 a
- repeatM :: forall m a (dim :: Nat). (Monad m, Unbox a, Dimension dim) => m a -> m (Tuple dim a)
- unsafeFromVector :: forall a (dim :: Nat). Vector a -> Tuple dim a
- unsafeToVector :: forall (dim :: Nat) a. Tuple dim a -> Vector a
- createFrom :: LengthUnit l => l -> Ptr a -> IO ByteString
- unsafeCopyToPointer :: Pointer ptr => ByteString -> ptr a -> IO ()
- unsafeNCopyToPointer :: LengthUnit n => n -> ByteString -> Ptr a -> IO ()
- withByteString :: ByteString -> (Ptr something -> IO a) -> IO a
- blake2Pad :: Primitive prim => Proxy prim -> BYTES Int -> WriteTo
- counterCellPtr :: ChaCha20Mem -> Ptr WORD
- ivCellPtr :: ChaCha20Mem -> Ptr (Nounce ChaCha20)
- keyCellPtr :: ChaCha20Mem -> Ptr (Key ChaCha20)
- process256Last :: forall (n :: Nat). KnownNat n => Compressor256 n -> AlignedBlockPtr n Sha256 -> BYTES Int -> Sha256Mem -> IO ()
- process512Last :: forall (n :: Nat). KnownNat n => Compressor512 n -> AlignedBlockPtr n Sha512 -> BYTES Int -> Sha512Mem -> IO ()
Documentation
Result represents the test result
Constructors
Success | A successful test run |
Fields
| |
GaveUp | Given up |
Fields
| |
Failure | A failed test run |
Fields
| |
NoExpectedFailure | A property that should have failed did not |
Fields
|
The class of properties, i.e., types which QuickCheck knows how to test.
Typically a property will be a function returning Bool
or Property
.
Minimal complete definition
Methods
property :: prop -> Property #
Convert the thing to a property.
propertyForAllShrinkShow :: Gen a -> (a -> [a]) -> (a -> [String]) -> (a -> prop) -> Property #
Optional; used internally in order to improve shrinking.
Tests a property but also quantifies over an extra value
(with a custom shrink and show function).
The Testable
instance for functions defines
propertyForAllShrinkShow
in a way that improves shrinking.
Instances
Testable Discard | |
Testable Prop | |
Defined in Test.QuickCheck.Property | |
Testable Property | |
Testable Result | |
Defined in Test.QuickCheck.Property | |
Testable () | |
Defined in Test.QuickCheck.Property | |
Testable Bool | |
Testable prop => Testable (Gen prop) | |
Testable prop => Testable (Maybe prop) | |
(Arbitrary a, Show a, Testable prop) => Testable (a -> prop) | |
Defined in Test.QuickCheck.Property |
The builtin function type, written in infix form as a % m -> b
.
Values of this type are functions taking inputs of type a
and
producing outputs of type b
. The multiplicity of the input is
m
.
Note that
permits representation polymorphism in both
FUN
m a ba
and b
, so that types like
can still be
well-kinded.Int#
-> Int#
Instances
IsString WriteTo | |
Defined in Raaz.Core.Transfer.Unsafe Methods fromString :: String -> WriteTo # | |
Encodable WriteTo | |
Defined in Raaz.Core.Transfer.Unsafe | |
Distributive (BYTES Int) (TransferAction t) | |
Defined in Raaz.Core.Transfer.Unsafe | |
LAction (BYTES Int) (TransferAction t) | |
Defined in Raaz.Core.Transfer.Unsafe | |
(CoArbitrary a, Arbitrary b) => Arbitrary (a -> b) | |
(Arbitrary a, CoArbitrary b) => CoArbitrary (a -> b) | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: (a -> b) -> Gen b0 -> Gen b0 # | |
(Arbitrary a, Show a, Testable prop) => Testable (a -> prop) | |
Defined in Test.QuickCheck.Property | |
Monoid b => Monoid (a -> b) | Since: base-2.1 |
Semigroup b => Semigroup (a -> b) | Since: base-4.9.0.0 |
NFData (a -> b) | This instance is for convenience and consistency with Since: deepseq-1.3.0.0 |
Defined in Control.DeepSeq | |
Example (a -> Result) | |
Defined in Test.Hspec.Core.Example Methods evaluateExample :: (a -> Result) -> Params -> (ActionWith (Arg (a -> Result)) -> IO ()) -> ProgressCallback -> IO Result # | |
Example (a -> Expectation) | |
Defined in Test.Hspec.Core.Example Associated Types type Arg (a -> Expectation) # Methods evaluateExample :: (a -> Expectation) -> Params -> (ActionWith (Arg (a -> Expectation)) -> IO ()) -> ProgressCallback -> IO Result # | |
Example (a -> Bool) | |
Defined in Test.Hspec.Core.Example Methods evaluateExample :: (a -> Bool) -> Params -> (ActionWith (Arg (a -> Bool)) -> IO ()) -> ProgressCallback -> IO Result # | |
CoArbitrary a => Arbitrary1 ((->) a) | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary :: Gen a0 -> Gen (a -> a0) # liftShrink :: (a0 -> [a0]) -> (a -> a0) -> [a -> a0] # | |
Applicative ((->) r) | Since: base-2.1 |
Functor ((->) r) | Since: base-2.1 |
Monad ((->) r) | Since: base-2.1 |
type Arg (a -> Property) | |
Defined in Test.Hspec.Core.QuickCheck | |
type Arg (a -> Result) | |
Defined in Test.Hspec.Core.Example | |
type Arg (a -> Expectation) | |
Defined in Test.Hspec.Core.Example | |
type Arg (a -> Bool) | |
Defined in Test.Hspec.Core.Example |
Instances
The character type Char
is an enumeration whose values represent
Unicode (or equivalently ISO/IEC 10646) code points (i.e. characters, see
http://www.unicode.org/ for details). This set extends the ISO 8859-1
(Latin-1) character set (the first 256 characters), which is itself an extension
of the ASCII character set (the first 128 characters). A character literal in
Haskell has type Char
.
To convert a Char
to or from the corresponding Int
value defined
by Unicode, use toEnum
and fromEnum
from the
Enum
class respectively (or equivalently ord
and
chr
).
Instances
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
Arbitrary Double | |
CoArbitrary Double | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Double -> Gen b -> Gen b # | |
Function 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 |
NFData Double | |
Defined in Control.DeepSeq | |
Eq Double | Note that due to the presence of
Also note that
|
Ord Double | Note that due to the presence of
Also note that, due to the same,
|
Random Double | Note - |
UniformRange Double | |
Defined in System.Random.Internal | |
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) | |
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 (URec Double :: Type -> Type) | Since: base-4.9.0.0 |
Generic (URec Double p) | |
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 # | |
newtype Vector Double | |
data URec Double (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
newtype MVector s Double | |
type Rep1 (URec Double :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Double p) | Since: base-4.9.0.0 |
Defined in GHC.Generics |
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
Arbitrary Float | |
CoArbitrary Float | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Float -> Gen b -> Gen b # | |
Function 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 |
NFData Float | |
Defined in Control.DeepSeq | |
Eq Float | Note that due to the presence of
Also note that
|
Ord Float | Note that due to the presence of
Also note that, due to the same,
|
Random Float | Note - |
UniformRange Float | |
Defined in System.Random.Internal | |
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) | |
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 (URec Float :: Type -> Type) | Since: base-4.9.0.0 |
Generic (URec Float p) | |
Show (URec Float p) | |
Eq (URec Float p) | |
Ord (URec Float p) | |
Defined in GHC.Generics | |
newtype Vector Float | |
data URec Float (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
newtype MVector s Float | |
type Rep1 (URec Float :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Float p) | |
Defined in GHC.Generics |
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
Instances
Instances
Arbitrary Ordering | |
CoArbitrary Ordering | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Ordering -> Gen b -> Gen b # | |
Function Ordering | |
Monoid Ordering | Since: base-2.1 |
Semigroup Ordering | Since: base-4.9.0.0 |
Bounded Ordering | Since: base-2.1 |
Enum Ordering | Since: base-2.1 |
Generic Ordering | |
Read Ordering | Since: base-2.1 |
Show Ordering | Since: base-2.1 |
NFData Ordering | |
Defined in Control.DeepSeq | |
Eq Ordering | |
Ord Ordering | |
Defined in GHC.Classes | |
type Rep Ordering | Since: base-4.6.0.0 |
The Maybe
type encapsulates an optional value. A value of type
either contains a value of type Maybe
aa
(represented as
),
or it is empty (represented as Just
aNothing
). Using Maybe
is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as error
.
The Maybe
type is also a monad. It is a simple kind of error
monad, where all errors are represented by Nothing
. A richer
error monad can be built using the Either
type.
Instances
Arbitrary1 Maybe | |
Defined in Test.QuickCheck.Arbitrary | |
MonadFail Maybe | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable Methods fold :: Monoid m => Maybe m -> m # foldMap :: Monoid m => (a -> m) -> Maybe a -> m # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m # foldr :: (a -> b -> b) -> b -> Maybe a -> b # foldr' :: (a -> b -> b) -> b -> Maybe a -> b # foldl :: (b -> a -> b) -> b -> Maybe a -> b # foldl' :: (b -> a -> b) -> b -> Maybe a -> b # foldr1 :: (a -> a -> a) -> Maybe a -> a # foldl1 :: (a -> a -> a) -> Maybe a -> a # elem :: Eq a => a -> Maybe a -> Bool # maximum :: Ord a => Maybe a -> a # minimum :: Ord a => Maybe a -> a # | |
Traversable Maybe | Since: base-2.1 |
Alternative Maybe | Picks the leftmost Since: base-2.1 |
Applicative Maybe | Since: base-2.1 |
Functor Maybe | Since: base-2.1 |
Monad Maybe | Since: base-2.1 |
MonadPlus Maybe | Picks the leftmost Since: base-2.1 |
NFData1 Maybe | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Generic1 Maybe | |
Lift a => Lift (Maybe a :: Type) | |
Arbitrary a => Arbitrary (Maybe a) | |
CoArbitrary a => CoArbitrary (Maybe a) | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Maybe a -> Gen b -> Gen b # | |
Function a => Function (Maybe a) | |
Testable prop => Testable (Maybe prop) | |
Semigroup a => Monoid (Maybe a) | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
Semigroup a => Semigroup (Maybe a) | Since: base-4.9.0.0 |
Generic (Maybe a) | |
SingKind a => SingKind (Maybe a) | Since: base-4.9.0.0 |
Defined in GHC.Generics Associated Types type DemoteRep (Maybe a) | |
Read a => Read (Maybe a) | Since: base-2.1 |
Show a => Show (Maybe a) | Since: base-2.1 |
NFData a => NFData (Maybe a) | |
Defined in Control.DeepSeq | |
Eq a => Eq (Maybe a) | Since: base-2.1 |
Ord a => Ord (Maybe a) | Since: base-2.1 |
ByteSource src => ByteSource (Maybe src) | |
Defined in Raaz.Core.ByteSource | |
PureByteSource src => PureByteSource (Maybe src) | |
Defined in Raaz.Core.ByteSource | |
SingI ('Nothing :: Maybe a) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
SingI a2 => SingI ('Just a2 :: Maybe a1) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep1 Maybe | Since: base-4.6.0.0 |
type DemoteRep (Maybe a) | |
Defined in GHC.Generics | |
type Rep (Maybe a) | Since: base-4.6.0.0 |
Defined in GHC.Generics | |
data Sing (b :: Maybe a) | |
class a ~# b => (a :: k) ~ (b :: k) infix 4 #
Lifted, homogeneous equality. By lifted, we mean that it
can be bogus (deferred type error). By homogeneous, the two
types a
and b
must have the same kinds.
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 Integer
and IN
constructors are used to store a BigNat
representing respectively the positive or the negative value magnitude.
Invariant: Integer
and IN
are used iff value doesn't fit in IS
Instances
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
type Constraint = CONSTRAINT LiftedRep #
The kind of lifted constraints
Conversion of values to readable String
s.
Derived instances of Show
have the following properties, which
are compatible with derived instances of Read
:
- The result of
show
is 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
showsPrec
will produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
x
is less thand
(associativity is ignored). Thus, ifd
is0
then the result is never surrounded in parentheses; ifd
is11
it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
show
will 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 = 5
Note 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
class Semigroup a => Monoid a where #
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following:
- Right identity
x
<>
mempty
= x- Left identity
mempty
<>
x = x- Associativity
x
(<>
(y<>
z) = (x<>
y)<>
zSemigroup
law)- Concatenation
mconcat
=foldr
(<>
)mempty
You can alternatively define mconcat
instead of mempty
, in which case the
laws are:
- Unit
mconcat
(pure
x) = x- Multiplication
mconcat
(join
xss) =mconcat
(fmap
mconcat
xss)- Subclass
mconcat
(toList
xs) =sconcat
xs
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define newtype
s and make those instances
of Monoid
, e.g. Sum
and Product
.
NOTE: Semigroup
is a superclass of Monoid
since base-4.11.0.0.
Methods
Identity of mappend
>>>
"Hello world" <> mempty
"Hello world"
An associative operation
NOTE: This method is redundant and has the default
implementation
since base-4.11.0.0.
Should it be implemented manually, since mappend
= (<>
)mappend
is a synonym for
(<>
), it is expected that the two functions are defined the same
way. In a future GHC release mappend
will be removed from Monoid
.
Fold a list using the monoid.
For most types, the default definition for mconcat
will be
used, but the function is included in the class definition so
that an optimized version can be provided for specific types.
>>>
mconcat ["Hello", " ", "Haskell", "!"]
"Hello Haskell!"
Instances
Monoid ByteString | |
Defined in Data.ByteString.Internal.Type Methods mempty :: ByteString # mappend :: ByteString -> ByteString -> ByteString # mconcat :: [ByteString] -> ByteString # | |
Monoid ShortByteString | |
Defined in Data.ByteString.Short.Internal Methods mappend :: ShortByteString -> ShortByteString -> ShortByteString # mconcat :: [ShortByteString] -> ShortByteString # | |
Monoid IntSet | |
Monoid OsString | "String-Concatenation" for |
Monoid PosixString | |
Defined in System.OsString.Internal.Types Methods mempty :: PosixString # mappend :: PosixString -> PosixString -> PosixString # mconcat :: [PosixString] -> PosixString # | |
Monoid WindowsString | |
Defined in System.OsString.Internal.Types Methods mempty :: WindowsString # mappend :: WindowsString -> WindowsString -> WindowsString # mconcat :: [WindowsString] -> WindowsString # | |
Monoid Ordering | Since: base-2.1 |
Monoid Doc | |
Monoid Base16 | |
Monoid Base64 | |
Monoid Result | |
Monoid Alignment | |
Monoid () | Since: base-2.1 |
FiniteBits a => Monoid (And a) | This constraint is arguably too strong. However,
as some types (such as Since: base-4.16 |
FiniteBits a => Monoid (Iff a) | This constraint is arguably
too strong. However, as some types (such as Since: base-4.16 |
Bits a => Monoid (Ior a) | Since: base-4.16 |
Bits a => Monoid (Xor a) | Since: base-4.16 |
(Generic a, Monoid (Rep a ())) => Monoid (Generically a) | Since: base-4.17.0.0 |
Defined in GHC.Generics Methods mempty :: Generically a # mappend :: Generically a -> Generically a -> Generically a # mconcat :: [Generically a] -> Generically a # | |
Monoid p => Monoid (Par1 p) | Since: base-4.12.0.0 |
Monoid (IntMap a) | |
Monoid (Seq a) | |
Monoid (MergeSet a) | |
Ord a => Monoid (Set a) | |
Monoid a => Monoid (IO a) | Since: base-4.9.0.0 |
Monoid (Doc a) | |
Monoid (Array a) | |
Monoid (PrimArray a) | Since: primitive-0.6.4.0 |
Monoid (SmallArray a) | |
Defined in Data.Primitive.SmallArray Methods mempty :: SmallArray a # mappend :: SmallArray a -> SmallArray a -> SmallArray a # mconcat :: [SmallArray a] -> SmallArray a # | |
Monoid (BlockCount p) | |
Defined in Raaz.Core.Primitive Methods mempty :: BlockCount p # mappend :: BlockCount p -> BlockCount p -> BlockCount p # mconcat :: [BlockCount p] -> BlockCount p # | |
Monoid (TransferM t) | |
Num a => Monoid (BYTES a) | |
Monoid a => Monoid (Q a) | Since: template-haskell-2.17.0.0 |
Prim a => Monoid (Vector a) | |
Semigroup a => Monoid (Maybe a) | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
Monoid a => Monoid (a) | Since: base-4.15 |
Monoid [a] | Since: base-2.1 |
Monoid (Proxy s) | Since: base-4.7.0.0 |
Monoid (U1 p) | Since: base-4.12.0.0 |
Monoid a => Monoid (ST s a) | Since: base-4.11.0.0 |
Ord k => Monoid (Map k v) | |
(Monoid a, Monoid b) => Monoid (a, b) | Since: base-2.1 |
Monoid b => Monoid (a -> b) | Since: base-2.1 |
Monoid a => Monoid (Const a b) | Since: base-4.9.0.0 |
Monoid (f p) => Monoid (Rec1 f p) | Since: base-4.12.0.0 |
Monoid a => Monoid (Constant a b) | |
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | Since: base-2.1 |
(Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) | Since: base-4.12.0.0 |
Monoid c => Monoid (K1 i c p) | Since: base-4.12.0.0 |
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | Since: base-2.1 |
Monoid (f (g p)) => Monoid ((f :.: g) p) | Since: base-4.12.0.0 |
Monoid (f p) => Monoid (M1 i c f p) | Since: base-4.12.0.0 |
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) | Since: base-2.1 |
The class of semigroups (types with an associative binary operation).
Instances should satisfy the following:
You can alternatively define sconcat
instead of (<>
), in which case the
laws are:
Since: base-4.9.0.0
Instances
class Functor f => Applicative (f :: Type -> Type) where #
A functor with application, providing operations to
A minimal complete definition must include implementations of pure
and of either <*>
or liftA2
. If it defines both, then they must behave
the same as their default definitions:
(<*>
) =liftA2
id
liftA2
f x y = f<$>
x<*>
y
Further, any definition must satisfy the following:
- Identity
pure
id
<*>
v = v- Composition
pure
(.)<*>
u<*>
v<*>
w = u<*>
(v<*>
w)- Homomorphism
pure
f<*>
pure
x =pure
(f x)- Interchange
u
<*>
pure
y =pure
($
y)<*>
u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor
instance for f
will satisfy
It may be useful to note that supposing
forall x y. p (q x y) = f x . g y
it follows from the above that
liftA2
p (liftA2
q u v) =liftA2
f u .liftA2
g v
If f
is also a Monad
, it should satisfy
(which implies that pure
and <*>
satisfy the applicative functor laws).
Methods
Lift a value.
(<*>) :: f (a -> b) -> f a -> f b infixl 4 #
Sequential application.
A few functors support an implementation of <*>
that is more
efficient than the default one.
Example
Used in combination with (
, <$>
)(
can be used to build a record.<*>
)
>>>
data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
>>>
produceFoo :: Applicative f => f Foo
>>>
produceBar :: Applicative f => f Bar
>>>
produceBaz :: Applicative f => f Baz
>>>
mkState :: Applicative f => f MyState
>>>
mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
liftA2 :: (a -> b -> c) -> f a -> f b -> f c #
Lift a binary function to actions.
Some functors support an implementation of liftA2
that is more
efficient than the default one. In particular, if fmap
is an
expensive operation, it is likely better to use liftA2
than to
fmap
over the structure and then use <*>
.
This became a typeclass method in 4.10.0.0. Prior to that, it was
a function defined in terms of <*>
and fmap
.
Example
>>>
liftA2 (,) (Just 3) (Just 5)
Just (3,5)
(*>) :: f a -> f b -> f b infixl 4 #
Sequence actions, discarding the value of the first argument.
Examples
If used in conjunction with the Applicative instance for Maybe
,
you can chain Maybe computations, with a possible "early return"
in case of Nothing
.
>>>
Just 2 *> Just 3
Just 3
>>>
Nothing *> Just 3
Nothing
Of course a more interesting use case would be to have effectful computations instead of just returning pure values.
>>>
import Data.Char
>>>
import Text.ParserCombinators.ReadP
>>>
let p = string "my name is " *> munch1 isAlpha <* eof
>>>
readP_to_S p "my name is Simon"
[("Simon","")]
(<*) :: f a -> f b -> f a infixl 4 #
Sequence actions, discarding the value of the second argument.
Instances
Applicative Gen | |
Applicative Rose | |
Applicative ZipList | f <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN) where (\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]} Since: base-2.1 |
Applicative NonEmpty | Since: base-4.9.0.0 |
Applicative Par1 | Since: base-4.9.0.0 |
Applicative P | Since: base-4.5.0.0 |
Applicative ReadP | Since: base-4.6.0.0 |
Applicative Seq | Since: containers-0.5.4 |
Applicative Tree | |
Applicative IO | Since: base-2.1 |
Applicative Array | |
Applicative SmallArray | |
Defined in Data.Primitive.SmallArray Methods pure :: a -> SmallArray a # (<*>) :: SmallArray (a -> b) -> SmallArray a -> SmallArray b # liftA2 :: (a -> b -> c) -> SmallArray a -> SmallArray b -> SmallArray c # (*>) :: SmallArray a -> SmallArray b -> SmallArray b # (<*) :: SmallArray a -> SmallArray b -> SmallArray a # | |
Applicative Q | |
Applicative Maybe | Since: base-2.1 |
Applicative Solo | Since: base-4.15 |
Applicative List | Since: base-2.1 |
Applicative (PropertyM m) | |
Defined in Test.QuickCheck.Monadic | |
Monad m => Applicative (WrappedMonad m) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: a -> WrappedMonad m a # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a # | |
Applicative (Either e) | Since: base-3.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Applicative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Applicative (ST s) | Since: base-4.4.0.0 |
Applicative (SpecM a) | |
Monoid a => Applicative ((,) a) | For tuples, the ("hello ", (+15)) <*> ("world!", 2002) ("hello world!",2017) Since: base-2.1 |
Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: a0 -> WrappedArrow a b a0 # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
Monoid m => Applicative (Const m :: Type -> Type) | Since: base-2.0.1 |
(Generic1 f, Applicative (Rep1 f)) => Applicative (Generically1 f) | Since: base-4.17.0.0 |
Defined in GHC.Generics Methods pure :: a -> Generically1 f a # (<*>) :: Generically1 f (a -> b) -> Generically1 f a -> Generically1 f b # liftA2 :: (a -> b -> c) -> Generically1 f a -> Generically1 f b -> Generically1 f c # (*>) :: Generically1 f a -> Generically1 f b -> Generically1 f b # (<*) :: Generically1 f a -> Generically1 f b -> Generically1 f a # | |
Applicative f => Applicative (Rec1 f) | Since: base-4.9.0.0 |
(Applicative f, Monad f) => Applicative (WhenMissing f x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal Methods pure :: a -> WhenMissing f x a # (<*>) :: WhenMissing f x (a -> b) -> WhenMissing f x a -> WhenMissing f x b # liftA2 :: (a -> b -> c) -> WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x c # (*>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b # (<*) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x a # | |
Monoid a => Applicative (Constant a :: Type -> Type) | |
Defined in Data.Functor.Constant | |
(Monoid a, Monoid b) => Applicative ((,,) a b) | Since: base-4.14.0.0 |
(Applicative f, Applicative g) => Applicative (f :*: g) | Since: base-4.9.0.0 |
Monoid c => Applicative (K1 i c :: Type -> Type) | Since: base-4.12.0.0 |
(Monad f, Applicative f) => Applicative (WhenMatched f x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal Methods pure :: a -> WhenMatched f x y a # (<*>) :: WhenMatched f x y (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b # liftA2 :: (a -> b -> c) -> WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y c # (*>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b # (<*) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y a # | |
(Applicative f, Monad f) => Applicative (WhenMissing f k x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods pure :: a -> WhenMissing f k x a # (<*>) :: WhenMissing f k x (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b # liftA2 :: (a -> b -> c) -> WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x c # (*>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b # (<*) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x a # | |
(Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) | Since: base-4.14.0.0 |
Defined in GHC.Base | |
Applicative ((->) r) | Since: base-2.1 |
(Applicative f, Applicative g) => Applicative (f :.: g) | Since: base-4.9.0.0 |
Applicative f => Applicative (M1 i c f) | Since: base-4.9.0.0 |
(Monad f, Applicative f) => Applicative (WhenMatched f k x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods pure :: a -> WhenMatched f k x y a # (<*>) :: WhenMatched f k x y (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b # liftA2 :: (a -> b -> c) -> WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y c # (*>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b # (<*) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y a # |
class Functor (f :: Type -> Type) where #
A type f
is a Functor if it provides a function fmap
which, given any types a
and b
lets you apply any function from (a -> b)
to turn an f a
into an f b
, preserving the
structure of f
. Furthermore f
needs to adhere to the following:
Note, that the second law follows from the free theorem of the type fmap
and
the first law, so you need only check that the former condition holds.
See https://www.schoolofhaskell.com/user/edwardk/snippets/fmap or
https://github.com/quchen/articles/blob/master/second_functor_law.md
for an explanation.
Minimal complete definition
Methods
fmap :: (a -> b) -> f a -> f b #
fmap
is used to apply a function of type (a -> b)
to a value of type f a
,
where f is a functor, to produce a value of type f b
.
Note that for any type constructor with more than one parameter (e.g., Either
),
only the last type parameter can be modified with fmap
(e.g., b
in `Either a b`).
Some type constructors with two parameters or more have a
instance that allows
both the last and the penultimate parameters to be mapped over.Bifunctor
Examples
Convert from a
to a Maybe
IntMaybe String
using show
:
>>>
fmap show Nothing
Nothing>>>
fmap show (Just 3)
Just "3"
Convert from an
to an
Either
Int IntEither Int String
using show
:
>>>
fmap show (Left 17)
Left 17>>>
fmap show (Right 17)
Right "17"
Double each element of a list:
>>>
fmap (*2) [1,2,3]
[2,4,6]
Apply even
to the second element of a pair:
>>>
fmap even (2,2)
(2,True)
It may seem surprising that the function is only applied to the last element of the tuple
compared to the list example above which applies it to every element in the list.
To understand, remember that tuples are type constructors with multiple type parameters:
a tuple of 3 elements (a,b,c)
can also be written (,,) a b c
and its Functor
instance
is defined for Functor ((,,) a b)
(i.e., only the third parameter is free to be mapped over
with fmap
).
It explains why fmap
can be used with tuples containing values of different types as in the
following example:
>>>
fmap even ("hello", 1.0, 4)
("hello",1.0,True)
Instances
class Applicative m => Monad (m :: Type -> Type) where #
The Monad
class defines the basic operations over a monad,
a concept from a branch of mathematics known as category theory.
From the perspective of a Haskell programmer, however, it is best to
think of a monad as an abstract datatype of actions.
Haskell's do
expressions provide a convenient syntax for writing
monadic expressions.
Instances of Monad
should satisfy the following:
- Left identity
return
a>>=
k = k a- Right identity
m
>>=
return
= m- Associativity
m
>>=
(\x -> k x>>=
h) = (m>>=
k)>>=
h
Furthermore, the Monad
and Applicative
operations should relate as follows:
The above laws imply:
and that pure
and (<*>
) satisfy the applicative functor laws.
The instances of Monad
for lists, Maybe
and IO
defined in the Prelude satisfy these laws.
Minimal complete definition
Methods
(>>=) :: m a -> (a -> m b) -> m b infixl 1 #
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
'as
' can be understood as the >>=
bsdo
expression
do a <- as bs a
(>>) :: m a -> m b -> m b infixl 1 #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
'as
' can be understood as the >>
bsdo
expression
do as bs
Inject a value into the monadic type.
Instances
Monad Gen | |
Monad Rose | |
Monad NonEmpty | Since: base-4.9.0.0 |
Monad Par1 | Since: base-4.9.0.0 |
Monad P | Since: base-2.1 |
Monad ReadP | Since: base-2.1 |
Monad Seq | |
Monad Tree | |
Monad IO | Since: base-2.1 |
Monad Array | |
Monad SmallArray | |
Defined in Data.Primitive.SmallArray Methods (>>=) :: SmallArray a -> (a -> SmallArray b) -> SmallArray b # (>>) :: SmallArray a -> SmallArray b -> SmallArray b # return :: a -> SmallArray a # | |
Monad Q | |
Monad Maybe | Since: base-2.1 |
Monad Solo | Since: base-4.15 |
Monad List | Since: base-2.1 |
Monad m => Monad (PropertyM m) | |
Monad m => Monad (WrappedMonad m) | Since: base-4.7.0.0 |
Defined in Control.Applicative Methods (>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b # (>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # return :: a -> WrappedMonad m a # | |
Monad (Either e) | Since: base-4.4.0.0 |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Monad (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Monad (ST s) | Since: base-2.1 |
Monad (SpecM a) | |
Monoid a => Monad ((,) a) | Since: base-4.9.0.0 |
Monad f => Monad (Rec1 f) | Since: base-4.9.0.0 |
(Applicative f, Monad f) => Monad (WhenMissing f x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal Methods (>>=) :: WhenMissing f x a -> (a -> WhenMissing f x b) -> WhenMissing f x b # (>>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b # return :: a -> WhenMissing f x a # | |
(Monoid a, Monoid b) => Monad ((,,) a b) | Since: base-4.14.0.0 |
(Monad f, Monad g) => Monad (f :*: g) | Since: base-4.9.0.0 |
(Monad f, Applicative f) => Monad (WhenMatched f x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal Methods (>>=) :: WhenMatched f x y a -> (a -> WhenMatched f x y b) -> WhenMatched f x y b # (>>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b # return :: a -> WhenMatched f x y a # | |
(Applicative f, Monad f) => Monad (WhenMissing f k x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods (>>=) :: WhenMissing f k x a -> (a -> WhenMissing f k x b) -> WhenMissing f k x b # (>>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b # return :: a -> WhenMissing f k x a # | |
(Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c) | Since: base-4.14.0.0 |
Monad ((->) r) | Since: base-2.1 |
Monad f => Monad (M1 i c f) | Since: base-4.9.0.0 |
(Monad f, Applicative f) => Monad (WhenMatched f k x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal Methods (>>=) :: WhenMatched f k x y a -> (a -> WhenMatched f k x y b) -> WhenMatched f k x y b # (>>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b # return :: a -> WhenMatched f k x y a # |
Generation of random shrinkable, showable functions.
To generate random values of type
,
you must have an instance Fun
a b
.Function
a
A generator for values of type a
.
The third-party packages
QuickCheck-GenT
and
quickcheck-transformer
provide monad transformer versions of Gen
.
class CoArbitrary a where #
Used for random generation of functions.
You should consider using Fun
instead, which
can show the generated functions as strings.
If you are using a recent GHC, there is a default definition of
coarbitrary
using genericCoarbitrary
, so if your type has a
Generic
instance it's enough to say
instance CoArbitrary MyType
You should only use genericCoarbitrary
for data types where
equality is structural, i.e. if you can't have two different
representations of the same value. An example where it's not
safe is sets implemented using binary search trees: the same
set can be represented as several different trees.
Here you would have to explicitly define
coarbitrary s = coarbitrary (toList s)
.
Minimal complete definition
Nothing
Methods
coarbitrary :: a -> Gen b -> Gen b #
Used to generate a function of type a -> b
.
The first argument is a value, the second a generator.
You should use variant
to perturb the random generator;
the goal is that different values for the first argument will
lead to different calls to variant
. An example will help:
instance CoArbitrary a => CoArbitrary [a] where coarbitrary [] =variant
0 coarbitrary (x:xs) =variant
1 . coarbitrary (x,xs)
Instances
class Arbitrary2 (f :: Type -> Type -> Type) where #
Lifting of the Arbitrary
class to binary type constructors.
Minimal complete definition
Methods
liftArbitrary2 :: Gen a -> Gen b -> Gen (f a b) #
liftShrink2 :: (a -> [a]) -> (b -> [b]) -> f a b -> [f a b] #
Instances
Arbitrary2 Either | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary2 :: Gen a -> Gen b -> Gen (Either a b) # liftShrink2 :: (a -> [a]) -> (b -> [b]) -> Either a b -> [Either a b] # | |
Arbitrary2 (,) | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary2 :: Gen a -> Gen b -> Gen (a, b) # liftShrink2 :: (a -> [a]) -> (b -> [b]) -> (a, b) -> [(a, b)] # | |
Arbitrary2 (Const :: Type -> Type -> Type) | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary2 :: Gen a -> Gen b -> Gen (Const a b) # liftShrink2 :: (a -> [a]) -> (b -> [b]) -> Const a b -> [Const a b] # | |
Arbitrary2 (Constant :: Type -> Type -> Type) | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary2 :: Gen a -> Gen b -> Gen (Constant a b) # liftShrink2 :: (a -> [a]) -> (b -> [b]) -> Constant a b -> [Constant a b] # |
class Arbitrary1 (f :: Type -> Type) where #
Lifting of the Arbitrary
class to unary type constructors.
Minimal complete definition
Instances
Random generation and shrinking of values.
QuickCheck provides Arbitrary
instances for most types in base
,
except those which incur extra dependencies.
For a wider range of Arbitrary
instances see the
quickcheck-instances
package.
Minimal complete definition
Methods
A generator for values of the given type.
It is worth spending time thinking about what sort of test data
you want - good generators are often the difference between
finding bugs and not finding them. You can use sample
,
label
and classify
to check the quality of your test data.
There is no generic arbitrary
implementation included because we don't
know how to make a high-quality one. If you want one, consider using the
testing-feat or
generic-random packages.
The QuickCheck manual goes into detail on how to write good generators. Make sure to look at it, especially if your type is recursive!
Produces a (possibly) empty list of all the possible immediate shrinks of the given value.
The default implementation returns the empty list, so will not try to
shrink the value. If your data type has no special invariants, you can
enable shrinking by defining shrink =
, but by customising
the behaviour of genericShrink
shrink
you can often get simpler counterexamples.
Most implementations of shrink
should try at least three things:
- Shrink a term to any of its immediate subterms.
You can use
subterms
to do this. - Recursively apply
shrink
to all immediate subterms. You can userecursivelyShrink
to do this. - Type-specific shrinkings such as replacing a constructor by a simpler constructor.
For example, suppose we have the following implementation of binary trees:
data Tree a = Nil | Branch a (Tree a) (Tree a)
We can then define shrink
as follows:
shrink Nil = [] shrink (Branch x l r) = -- shrink Branch to Nil [Nil] ++ -- shrink to subterms [l, r] ++ -- recursively shrink subterms [Branch x' l' r' | (x', l', r') <- shrink (x, l, r)]
There are a couple of subtleties here:
- QuickCheck tries the shrinking candidates in the order they
appear in the list, so we put more aggressive shrinking steps
(such as replacing the whole tree by
Nil
) before smaller ones (such as recursively shrinking the subtrees). - It is tempting to write the last line as
[Branch x' l' r' | x' <- shrink x, l' <- shrink l, r' <- shrink r]
but this is the wrong thing! It will force QuickCheck to shrinkx
,l
andr
in tandem, and shrinking will stop once one of the three is fully shrunk.
There is a fair bit of boilerplate in the code above.
We can avoid it with the help of some generic functions.
The function genericShrink
tries shrinking a term to all of its
subterms and, failing that, recursively shrinks the subterms.
Using it, we can define shrink
as:
shrink x = shrinkToNil x ++ genericShrink x where shrinkToNil Nil = [] shrinkToNil (Branch _ l r) = [Nil]
genericShrink
is a combination of subterms
, which shrinks
a term to any of its subterms, and recursivelyShrink
, which shrinks
all subterms of a term. These may be useful if you need a bit more
control over shrinking than genericShrink
gives you.
A final gotcha: we cannot define shrink
as simply
as this shrinks shrink
x = Nil:genericShrink
xNil
to Nil
, and shrinking will go into an
infinite loop.
If all this leaves you bewildered, you might try
to begin with,
after deriving shrink
= genericShrink
Generic
for your type. However, if your data type has any
special invariants, you will need to check that genericShrink
can't break those invariants.
Instances
newtype PrintableString #
PrintableString
: generates a printable unicode String.
The string will not contain surrogate pairs.
Constructors
PrintableString | |
Fields |
Instances
newtype UnicodeString #
UnicodeString
: generates a unicode String.
The string will not contain surrogate pairs.
Constructors
UnicodeString | |
Fields |
Instances
Arbitrary UnicodeString | |
Defined in Test.QuickCheck.Modifiers | |
Read UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS UnicodeString # readList :: ReadS [UnicodeString] # | |
Show UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods showsPrec :: Int -> UnicodeString -> ShowS # show :: UnicodeString -> String # showList :: [UnicodeString] -> ShowS # | |
Eq UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods (==) :: UnicodeString -> UnicodeString -> Bool # (/=) :: UnicodeString -> UnicodeString -> Bool # | |
Ord UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods compare :: UnicodeString -> UnicodeString -> Ordering # (<) :: UnicodeString -> UnicodeString -> Bool # (<=) :: UnicodeString -> UnicodeString -> Bool # (>) :: UnicodeString -> UnicodeString -> Bool # (>=) :: UnicodeString -> UnicodeString -> Bool # max :: UnicodeString -> UnicodeString -> UnicodeString # min :: UnicodeString -> UnicodeString -> UnicodeString # |
newtype ASCIIString #
ASCIIString
: generates an ASCII string.
Constructors
ASCIIString | |
Fields |
Instances
Arbitrary ASCIIString | |
Defined in Test.QuickCheck.Modifiers | |
Read ASCIIString | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS ASCIIString # readList :: ReadS [ASCIIString] # readPrec :: ReadPrec ASCIIString # readListPrec :: ReadPrec [ASCIIString] # | |
Show ASCIIString | |
Defined in Test.QuickCheck.Modifiers Methods showsPrec :: Int -> ASCIIString -> ShowS # show :: ASCIIString -> String # showList :: [ASCIIString] -> ShowS # | |
Eq ASCIIString | |
Defined in Test.QuickCheck.Modifiers | |
Ord ASCIIString | |
Defined in Test.QuickCheck.Modifiers Methods compare :: ASCIIString -> ASCIIString -> Ordering # (<) :: ASCIIString -> ASCIIString -> Bool # (<=) :: ASCIIString -> ASCIIString -> Bool # (>) :: ASCIIString -> ASCIIString -> Bool # (>=) :: ASCIIString -> ASCIIString -> Bool # max :: ASCIIString -> ASCIIString -> ASCIIString # min :: ASCIIString -> ASCIIString -> ASCIIString # |
class ShrinkState s a where #
Shrinking _ x
: allows for maintaining a state during shrinking.
Constructors
Shrinking s a |
Smart _ x
: tries a different order when shrinking.
Shrink2 x
: allows 2 shrinking steps at the same time when shrinking x
Constructors
Shrink2 | |
Fields
|
Instances
Small x
: generates values of x
drawn from a small range.
The opposite of Large
.
Instances
Functor Small | |
Integral a => Arbitrary (Small a) | |
Enum a => Enum (Small a) | |
Ix a => Ix (Small a) | |
Defined in Test.QuickCheck.Modifiers | |
Num a => Num (Small a) | |
Read a => Read (Small a) | |
Integral a => Integral (Small a) | |
Defined in Test.QuickCheck.Modifiers | |
Real a => Real (Small a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational :: Small a -> Rational # | |
Show a => Show (Small a) | |
Eq a => Eq (Small a) | |
Ord a => Ord (Small a) | |
Defined in Test.QuickCheck.Modifiers |
Large x
: by default, QuickCheck generates Int
s drawn from a small
range. Large Int
gives you values drawn from the entire range instead.
Instances
Functor Large | |
(Integral a, Bounded a) => Arbitrary (Large a) | |
Enum a => Enum (Large a) | |
Ix a => Ix (Large a) | |
Defined in Test.QuickCheck.Modifiers | |
Num a => Num (Large a) | |
Read a => Read (Large a) | |
Integral a => Integral (Large a) | |
Defined in Test.QuickCheck.Modifiers | |
Real a => Real (Large a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational :: Large a -> Rational # | |
Show a => Show (Large a) | |
Eq a => Eq (Large a) | |
Ord a => Ord (Large a) | |
Defined in Test.QuickCheck.Modifiers |
newtype NonPositive a #
NonPositive x
: guarantees that x <= 0
.
Constructors
NonPositive | |
Fields
|
Instances
newtype NonNegative a #
NonNegative x
: guarantees that x >= 0
.
Constructors
NonNegative | |
Fields
|
Instances
NonZero x
: guarantees that x /= 0
.
Constructors
NonZero | |
Fields
|
Instances
Functor NonZero | |
(Num a, Eq a, Arbitrary a) => Arbitrary (NonZero a) | |
Enum a => Enum (NonZero a) | |
Defined in Test.QuickCheck.Modifiers Methods succ :: NonZero a -> NonZero a # pred :: NonZero a -> NonZero a # fromEnum :: NonZero a -> Int # enumFrom :: NonZero a -> [NonZero a] # enumFromThen :: NonZero a -> NonZero a -> [NonZero a] # enumFromTo :: NonZero a -> NonZero a -> [NonZero a] # enumFromThenTo :: NonZero a -> NonZero a -> NonZero a -> [NonZero a] # | |
Read a => Read (NonZero a) | |
Show a => Show (NonZero a) | |
Eq a => Eq (NonZero a) | |
Ord a => Ord (NonZero a) | |
Negative x
: guarantees that x < 0
.
Constructors
Negative | |
Fields
|
Instances
Functor Negative | |
(Num a, Ord a, Arbitrary a) => Arbitrary (Negative a) | |
Enum a => Enum (Negative a) | |
Defined in Test.QuickCheck.Modifiers Methods succ :: Negative a -> Negative a # pred :: Negative a -> Negative a # fromEnum :: Negative a -> Int # enumFrom :: Negative a -> [Negative a] # enumFromThen :: Negative a -> Negative a -> [Negative a] # enumFromTo :: Negative a -> Negative a -> [Negative a] # enumFromThenTo :: Negative a -> Negative a -> Negative a -> [Negative a] # | |
Read a => Read (Negative a) | |
Show a => Show (Negative a) | |
Eq a => Eq (Negative a) | |
Ord a => Ord (Negative a) | |
Defined in Test.QuickCheck.Modifiers |
Positive x
: guarantees that x > 0
.
Constructors
Positive | |
Fields
|
Instances
Functor Positive | |
(Num a, Ord a, Arbitrary a) => Arbitrary (Positive a) | |
Enum a => Enum (Positive a) | |
Defined in Test.QuickCheck.Modifiers Methods succ :: Positive a -> Positive a # pred :: Positive a -> Positive a # fromEnum :: Positive a -> Int # enumFrom :: Positive a -> [Positive a] # enumFromThen :: Positive a -> Positive a -> [Positive a] # enumFromTo :: Positive a -> Positive a -> [Positive a] # enumFromThenTo :: Positive a -> Positive a -> Positive a -> [Positive a] # | |
Read a => Read (Positive a) | |
Show a => Show (Positive a) | |
Eq a => Eq (Positive a) | |
Ord a => Ord (Positive a) | |
Defined in Test.QuickCheck.Modifiers |
newtype SortedList a #
Sorted xs
: guarantees that xs is sorted.
Instances
data InfiniteList a #
InfiniteList xs _
: guarantees that xs is an infinite list.
When a counterexample is found, only prints the prefix of xs
that was used by the program.
Here is a contrived example property:
prop_take_10 :: InfiniteList Char -> Bool prop_take_10 (InfiniteList xs _) = or [ x == 'a' | x <- take 10 xs ]
In the following counterexample, the list must start with "bbbbbbbbbb"
but
the remaining (infinite) part can contain anything:
>>>
quickCheck prop_take_10
*** Failed! Falsified (after 1 test and 14 shrinks): "bbbbbbbbbb" ++ ...
Constructors
InfiniteList | |
Fields
|
Instances
Arbitrary a => Arbitrary (InfiniteList a) | |
Defined in Test.QuickCheck.Modifiers | |
Show a => Show (InfiniteList a) | |
Defined in Test.QuickCheck.Modifiers Methods showsPrec :: Int -> InfiniteList a -> ShowS # show :: InfiniteList a -> String # showList :: [InfiniteList a] -> ShowS # |
newtype NonEmptyList a #
NonEmpty xs
: guarantees that xs is non-empty.
Constructors
NonEmpty | |
Fields
|
Instances
newtype OrderedList a #
Ordered xs
: guarantees that xs is ordered.
Constructors
Ordered | |
Fields
|
Instances
Fixed x
: as x, but will not be shrunk.
Instances
Functor Fixed | |
Arbitrary a => Arbitrary (Fixed a) | |
Enum a => Enum (Fixed a) | |
Num a => Num (Fixed a) | |
Read a => Read (Fixed a) | |
Integral a => Integral (Fixed a) | |
Defined in Test.QuickCheck.Modifiers | |
Real a => Real (Fixed a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational :: Fixed a -> Rational # | |
Show a => Show (Fixed a) | |
Eq a => Eq (Fixed a) | |
Ord a => Ord (Fixed a) | |
Defined in Test.QuickCheck.Modifiers |
Blind x
: as x, but x does not have to be in the Show
class.
Instances
Functor Blind | |
Arbitrary a => Arbitrary (Blind a) | |
Enum a => Enum (Blind a) | |
Num a => Num (Blind a) | |
Integral a => Integral (Blind a) | |
Defined in Test.QuickCheck.Modifiers | |
Real a => Real (Blind a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational :: Blind a -> Rational # | |
Show (Blind a) | |
Eq a => Eq (Blind a) | |
Ord a => Ord (Blind a) | |
Defined in Test.QuickCheck.Modifiers |
The class Function a
is used for random generation of showable
functions of type a -> b
.
There is a default implementation for function
, which you can use
if your type has structural equality. Otherwise, you can normally
use functionMap
or functionShow
.
Minimal complete definition
Nothing
Instances
data Confidence #
The statistical parameters used by checkCoverage
.
Constructors
Confidence | |
Fields
|
Instances
Show Confidence | |
Defined in Test.QuickCheck.State Methods showsPrec :: Int -> Confidence -> ShowS # show :: Confidence -> String # showList :: [Confidence] -> ShowS # |
If a property returns Discard
, the current test case is discarded,
the same as if a precondition was false.
An example is the definition of ==>
:
(==>) :: Testable prop => Bool -> prop -> Property False ==> _ = property Discard True ==> p = property p
Constructors
Discard |
The type of properties.
Instances
Testable Property | |
type Arg Property | |
Defined in Test.Hspec.Core.QuickCheck | |
type Arg (a -> Property) | |
Defined in Test.Hspec.Core.QuickCheck |
Args specifies arguments to the QuickCheck driver
Constructors
Args | |
Fields
|
newtype PropertyM (m :: Type -> Type) a #
The property monad is really a monad transformer that can contain
monadic computations in the monad m
it is parameterized by:
m
- them
-computations that may be performed withinPropertyM
Elements of PropertyM m a
may mix property operations and m
-computations.
Constructors
MkPropertyM | |
Fields
|
Instances
MonadTrans PropertyM | |
Defined in Test.QuickCheck.Monadic | |
Monad m => MonadFail (PropertyM m) | |
Defined in Test.QuickCheck.Monadic | |
MonadIO m => MonadIO (PropertyM m) | |
Defined in Test.QuickCheck.Monadic | |
Applicative (PropertyM m) | |
Defined in Test.QuickCheck.Monadic | |
Functor (PropertyM m) | |
Monad m => Monad (PropertyM m) | |
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 IntPtr | |
Bounded WordPtr | |
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 Word16 | Since: base-2.1 |
Bounded Word32 | Since: base-2.1 |
Bounded Word64 | Since: base-2.1 |
Bounded Word8 | Since: base-2.1 |
Bounded Ordering | Since: base-2.1 |
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 w => Bounded (BE w) | |
Bounded w => Bounded (LE w) | |
Bounded a => Bounded (BYTES a) | |
Bounded a => Bounded (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 |
(Bounded a, Bounded b, Bounded c) => Bounded (a, b, c) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d) | Since: base-2.1 |
(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 |
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
andsucc
maxBound
should result in a runtime error.pred
minBound
fromEnum
andtoEnum
should give a runtime error if the result value is not representable in the result type. For example,
is an error.toEnum
7 ::Bool
enumFrom
andenumFromThen
should 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 = minBound
Methods
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
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:
n
is an integral number with the same sign asx
; andf
is 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
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 y
withrem x y
=fromInteger 0
org (rem x y)
<g y
x
=y * div x y + mod x y
withmod x y
=fromInteger 0
orf (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
Parsing of String
s, 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
Read
instance 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
Read
will parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration. - The derived
Read
instance 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 = 5
Note 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 = readListPrecDefault
Why 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:
instanceRead
T 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 ASCIIString | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS ASCIIString # readList :: ReadS [ASCIIString] # readPrec :: ReadPrec ASCIIString # readListPrec :: ReadPrec [ASCIIString] # | |
Read PrintableString | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS PrintableString # readList :: ReadS [PrintableString] # | |
Read UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS UnicodeString # readList :: ReadS [UnicodeString] # | |
Read QCGen | |
Read Args | |
Read IntPtr | |
Read WordPtr | |
Read Void | Reading a Since: base-4.8.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 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 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 ShortByteString | |
Defined in Data.ByteString.Short.Internal Methods readsPrec :: Int -> ReadS ShortByteString # readList :: ReadS [ShortByteString] # | |
Read IntSet | |
Read Ordering | Since: base-2.1 |
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 (Fixed a) | |
Read a => Read (Large a) | |
Read a => Read (Negative a) | |
Read a => Read (NonEmptyList a) | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS (NonEmptyList a) # readList :: ReadS [NonEmptyList a] # readPrec :: ReadPrec (NonEmptyList a) # readListPrec :: ReadPrec [NonEmptyList a] # | |
Read a => Read (NonNegative a) | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS (NonNegative a) # readList :: ReadS [NonNegative a] # readPrec :: ReadPrec (NonNegative a) # readListPrec :: ReadPrec [NonNegative a] # | |
Read a => Read (NonPositive a) | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS (NonPositive a) # readList :: ReadS [NonPositive a] # readPrec :: ReadPrec (NonPositive a) # readListPrec :: ReadPrec [NonPositive a] # | |
Read a => Read (NonZero a) | |
Read a => Read (OrderedList a) | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS (OrderedList a) # readList :: ReadS [OrderedList a] # readPrec :: ReadPrec (OrderedList a) # readListPrec :: ReadPrec [OrderedList a] # | |
Read a => Read (Positive a) | |
Read a => Read (Shrink2 a) | |
Read a => Read (Small a) | |
Read a => Read (SortedList a) | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec :: Int -> ReadS (SortedList a) # readList :: ReadS [SortedList a] # readPrec :: ReadPrec (SortedList a) # readListPrec :: ReadPrec [SortedList a] # | |
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 (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 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 w => Read (BE w) | |
Read w => Read (LE w) | |
(Read a, Prim a) => Read (Vector a) | |
Read a => Read (Maybe a) | Since: base-2.1 |
Read a => Read (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 |
Read (Proxy t) | Since: base-4.7.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) | |
(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 p) => Read (Rec1 f p) | Since: base-4.7.0.0 |
Read a => Read (Constant a b) | |
(Read a, Read b, Read c) => Read (a, b, c) | Since: base-2.1 |
(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 a, Read b, Read c, Read d) => Read (a, b, c, d) | Since: base-2.1 |
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 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 |
The Ord
class is used for totally ordered datatypes.
Instances of Ord
can be derived for any user-defined datatype whose
constituent types are in Ord
. The declared order of the constructors in
the data declaration determines the ordering in derived Ord
instances. The
Ordering
datatype allows a single comparison to determine the precise
ordering of two objects.
Ord
, as defined by the Haskell report, implements a total order and has the
following properties:
- Comparability
x <= y || y <= x
=True
- Transitivity
- if
x <= y && y <= z
=True
, thenx <= z
=True
- Reflexivity
x <= x
=True
- Antisymmetry
- if
x <= y && y <= x
=True
, thenx == y
=True
The following operator interactions are expected to hold:
x >= y
=y <= x
x < y
=x <= y && x /= y
x > y
=y < x
x < y
=compare x y == LT
x > y
=compare x y == GT
x == y
=compare x y == EQ
min x y == if x <= y then x else y
=True
max x y == if x >= y then x else y
=True
Note that (7.) and (8.) do not require min
and max
to return either of
their arguments. The result is merely required to equal one of the
arguments in terms of (==)
.
Minimal complete definition: either compare
or <=
.
Using compare
can be more efficient for complex types.
Methods
compare :: a -> a -> Ordering #
(<) :: a -> a -> Bool infix 4 #
(<=) :: a -> a -> Bool infix 4 #
(>) :: a -> a -> Bool infix 4 #
Instances
Ord ASCIIString | |
Defined in Test.QuickCheck.Modifiers Methods compare :: ASCIIString -> ASCIIString -> Ordering # (<) :: ASCIIString -> ASCIIString -> Bool # (<=) :: ASCIIString -> ASCIIString -> Bool # (>) :: ASCIIString -> ASCIIString -> Bool # (>=) :: ASCIIString -> ASCIIString -> Bool # max :: ASCIIString -> ASCIIString -> ASCIIString # min :: ASCIIString -> ASCIIString -> ASCIIString # | |
Ord PrintableString | |
Defined in Test.QuickCheck.Modifiers Methods compare :: PrintableString -> PrintableString -> Ordering # (<) :: PrintableString -> PrintableString -> Bool # (<=) :: PrintableString -> PrintableString -> Bool # (>) :: PrintableString -> PrintableString -> Bool # (>=) :: PrintableString -> PrintableString -> Bool # max :: PrintableString -> PrintableString -> PrintableString # min :: PrintableString -> PrintableString -> PrintableString # | |
Ord UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods compare :: UnicodeString -> UnicodeString -> Ordering # (<) :: UnicodeString -> UnicodeString -> Bool # (<=) :: UnicodeString -> UnicodeString -> Bool # (>) :: UnicodeString -> UnicodeString -> Bool # (>=) :: UnicodeString -> UnicodeString -> Bool # max :: UnicodeString -> UnicodeString -> UnicodeString # min :: UnicodeString -> UnicodeString -> UnicodeString # | |
Ord SomeTypeRep | |
Defined in Data.Typeable.Internal Methods compare :: SomeTypeRep -> SomeTypeRep -> Ordering # (<) :: SomeTypeRep -> SomeTypeRep -> Bool # (<=) :: SomeTypeRep -> SomeTypeRep -> Bool # (>) :: SomeTypeRep -> SomeTypeRep -> Bool # (>=) :: SomeTypeRep -> SomeTypeRep -> Bool # max :: SomeTypeRep -> SomeTypeRep -> SomeTypeRep # min :: SomeTypeRep -> SomeTypeRep -> SomeTypeRep # | |
Ord IntPtr | |
Ord WordPtr | |
Ord Void | Since: base-4.8.0.0 |
Ord ErrorCall | Since: base-4.7.0.0 |
Ord ArithException | Since: base-3.0 |
Defined in GHC.Exception.Type Methods compare :: ArithException -> ArithException -> Ordering # (<) :: ArithException -> ArithException -> Bool # (<=) :: ArithException -> ArithException -> Bool # (>) :: ArithException -> ArithException -> Bool # (>=) :: ArithException -> ArithException -> Bool # max :: ArithException -> ArithException -> ArithException # min :: ArithException -> ArithException -> ArithException # | |
Ord Associativity | Since: base-4.6.0.0 |
Defined in GHC.Generics Methods compare :: Associativity -> Associativity -> Ordering # (<) :: Associativity -> Associativity -> Bool # (<=) :: Associativity -> Associativity -> Bool # (>) :: Associativity -> Associativity -> Bool # (>=) :: Associativity -> Associativity -> Bool # max :: Associativity -> Associativity -> Associativity # min :: Associativity -> Associativity -> Associativity # | |
Ord DecidedStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods compare :: DecidedStrictness -> DecidedStrictness -> Ordering # (<) :: DecidedStrictness -> DecidedStrictness -> Bool # (<=) :: DecidedStrictness -> DecidedStrictness -> Bool # (>) :: DecidedStrictness -> DecidedStrictness -> Bool # (>=) :: DecidedStrictness -> DecidedStrictness -> Bool # max :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness # min :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness # | |
Ord Fixity | Since: base-4.6.0.0 |
Ord SourceStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods compare :: SourceStrictness -> SourceStrictness -> Ordering # (<) :: SourceStrictness -> SourceStrictness -> Bool # (<=) :: SourceStrictness -> SourceStrictness -> Bool # (>) :: SourceStrictness -> SourceStrictness -> Bool # (>=) :: SourceStrictness -> SourceStrictness -> Bool # max :: SourceStrictness -> SourceStrictness -> SourceStrictness # min :: SourceStrictness -> SourceStrictness -> SourceStrictness # | |
Ord SourceUnpackedness | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods compare :: SourceUnpackedness -> SourceUnpackedness -> Ordering # (<) :: SourceUnpackedness -> SourceUnpackedness -> Bool # (<=) :: SourceUnpackedness -> SourceUnpackedness -> Bool # (>) :: SourceUnpackedness -> SourceUnpackedness -> Bool # (>=) :: SourceUnpackedness -> SourceUnpackedness -> Bool # max :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness # min :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness # | |
Ord SeekMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Device | |
Ord ArrayException | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception Methods compare :: ArrayException -> ArrayException -> Ordering # (<) :: ArrayException -> ArrayException -> Bool # (<=) :: ArrayException -> ArrayException -> Bool # (>) :: ArrayException -> ArrayException -> Bool # (>=) :: ArrayException -> ArrayException -> Bool # max :: ArrayException -> ArrayException -> ArrayException # min :: ArrayException -> ArrayException -> ArrayException # | |
Ord AsyncException | Since: base-4.2.0.0 |
Defined in GHC.IO.Exception Methods compare :: AsyncException -> AsyncException -> Ordering # (<) :: AsyncException -> AsyncException -> Bool # (<=) :: AsyncException -> AsyncException -> Bool # (>) :: AsyncException -> AsyncException -> Bool # (>=) :: AsyncException -> AsyncException -> Bool # max :: AsyncException -> AsyncException -> AsyncException # min :: AsyncException -> AsyncException -> AsyncException # | |
Ord ExitCode | |
Defined in GHC.IO.Exception | |
Ord BufferMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methods compare :: BufferMode -> BufferMode -> Ordering # (<) :: BufferMode -> BufferMode -> Bool # (<=) :: BufferMode -> BufferMode -> Bool # (>) :: BufferMode -> BufferMode -> Bool # (>=) :: BufferMode -> BufferMode -> Bool # max :: BufferMode -> BufferMode -> BufferMode # min :: BufferMode -> BufferMode -> BufferMode # | |
Ord Newline | Since: base-4.3.0.0 |
Ord NewlineMode | Since: base-4.3.0.0 |
Defined in GHC.IO.Handle.Types Methods compare :: NewlineMode -> NewlineMode -> Ordering # (<) :: NewlineMode -> NewlineMode -> Bool # (<=) :: NewlineMode -> NewlineMode -> Bool # (>) :: NewlineMode -> NewlineMode -> Bool # (>=) :: NewlineMode -> NewlineMode -> Bool # max :: NewlineMode -> NewlineMode -> NewlineMode # min :: NewlineMode -> NewlineMode -> NewlineMode # | |
Ord IOMode | Since: base-4.2.0.0 |
Ord SomeNat | Since: base-4.7.0.0 |
Ord Word16 | Since: base-2.1 |
Ord Word32 | Since: base-2.1 |
Ord Word64 | Since: base-2.1 |
Ord Word8 | Since: base-2.1 |
Ord ByteString | |
Defined in Data.ByteString.Internal.Type Methods compare :: ByteString -> ByteString -> Ordering # (<) :: ByteString -> ByteString -> Bool # (<=) :: ByteString -> ByteString -> Bool # (>) :: ByteString -> ByteString -> Bool # (>=) :: ByteString -> ByteString -> Bool # max :: ByteString -> ByteString -> ByteString # min :: ByteString -> ByteString -> ByteString # | |
Ord ShortByteString | |
Defined in Data.ByteString.Short.Internal Methods compare :: ShortByteString -> ShortByteString -> Ordering # (<) :: ShortByteString -> ShortByteString -> Bool # (<=) :: ShortByteString -> ShortByteString -> Bool # (>) :: ShortByteString -> ShortByteString -> Bool # (>=) :: ShortByteString -> ShortByteString -> Bool # max :: ShortByteString -> ShortByteString -> ShortByteString # min :: ShortByteString -> ShortByteString -> ShortByteString # | |
Ord IntSet | |
Ord OsChar | Byte ordering of the internal representation. |
Ord OsString | Byte ordering of the internal representation. |
Defined in System.OsString.Internal.Types | |
Ord PosixChar | |
Ord PosixString | |
Defined in System.OsString.Internal.Types Methods compare :: PosixString -> PosixString -> Ordering # (<) :: PosixString -> PosixString -> Bool # (<=) :: PosixString -> PosixString -> Bool # (>) :: PosixString -> PosixString -> Bool # (>=) :: PosixString -> PosixString -> Bool # max :: PosixString -> PosixString -> PosixString # min :: PosixString -> PosixString -> PosixString # | |
Ord WindowsChar | |
Defined in System.OsString.Internal.Types Methods compare :: WindowsChar -> WindowsChar -> Ordering # (<) :: WindowsChar -> WindowsChar -> Bool # (<=) :: WindowsChar -> WindowsChar -> Bool # (>) :: WindowsChar -> WindowsChar -> Bool # (>=) :: WindowsChar -> WindowsChar -> Bool # max :: WindowsChar -> WindowsChar -> WindowsChar # min :: WindowsChar -> WindowsChar -> WindowsChar # | |
Ord WindowsString | |
Defined in System.OsString.Internal.Types Methods compare :: WindowsString -> WindowsString -> Ordering # (<) :: WindowsString -> WindowsString -> Bool # (<=) :: WindowsString -> WindowsString -> Bool # (>) :: WindowsString -> WindowsString -> Bool # (>=) :: WindowsString -> WindowsString -> Bool # max :: WindowsString -> WindowsString -> WindowsString # min :: WindowsString -> WindowsString -> WindowsString # | |
Ord Ordering | |
Defined in GHC.Classes | |
Ord TyCon | |
Ord Alignment | |
Ord AnnLookup | |
Ord AnnTarget | |
Ord Bang | |
Ord Body | |
Ord Bytes | |
Ord Callconv | |
Defined in Language.Haskell.TH.Syntax | |
Ord Clause | |
Ord Con | |
Ord Dec | |
Ord DecidedStrictness | |
Defined in Language.Haskell.TH.Syntax Methods compare :: DecidedStrictness -> DecidedStrictness -> Ordering # (<) :: DecidedStrictness -> DecidedStrictness -> Bool # (<=) :: DecidedStrictness -> DecidedStrictness -> Bool # (>) :: DecidedStrictness -> DecidedStrictness -> Bool # (>=) :: DecidedStrictness -> DecidedStrictness -> Bool # max :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness # min :: DecidedStrictness -> DecidedStrictness -> DecidedStrictness # | |
Ord DerivClause | |
Defined in Language.Haskell.TH.Syntax Methods compare :: DerivClause -> DerivClause -> Ordering # (<) :: DerivClause -> DerivClause -> Bool # (<=) :: DerivClause -> DerivClause -> Bool # (>) :: DerivClause -> DerivClause -> Bool # (>=) :: DerivClause -> DerivClause -> Bool # max :: DerivClause -> DerivClause -> DerivClause # min :: DerivClause -> DerivClause -> DerivClause # | |
Ord DerivStrategy | |
Defined in Language.Haskell.TH.Syntax Methods compare :: DerivStrategy -> DerivStrategy -> Ordering # (<) :: DerivStrategy -> DerivStrategy -> Bool # (<=) :: DerivStrategy -> DerivStrategy -> Bool # (>) :: DerivStrategy -> DerivStrategy -> Bool # (>=) :: DerivStrategy -> DerivStrategy -> Bool # max :: DerivStrategy -> DerivStrategy -> DerivStrategy # min :: DerivStrategy -> DerivStrategy -> DerivStrategy # | |
Ord DocLoc | |
Ord Exp | |
Ord FamilyResultSig | |
Defined in Language.Haskell.TH.Syntax Methods compare :: FamilyResultSig -> FamilyResultSig -> Ordering # (<) :: FamilyResultSig -> FamilyResultSig -> Bool # (<=) :: FamilyResultSig -> FamilyResultSig -> Bool # (>) :: FamilyResultSig -> FamilyResultSig -> Bool # (>=) :: FamilyResultSig -> FamilyResultSig -> Bool # max :: FamilyResultSig -> FamilyResultSig -> FamilyResultSig # min :: FamilyResultSig -> FamilyResultSig -> FamilyResultSig # | |
Ord Fixity | |
Ord FixityDirection | |
Defined in Language.Haskell.TH.Syntax Methods compare :: FixityDirection -> FixityDirection -> Ordering # (<) :: FixityDirection -> FixityDirection -> Bool # (<=) :: FixityDirection -> FixityDirection -> Bool # (>) :: FixityDirection -> FixityDirection -> Bool # (>=) :: FixityDirection -> FixityDirection -> Bool # max :: FixityDirection -> FixityDirection -> FixityDirection # min :: FixityDirection -> FixityDirection -> FixityDirection # | |
Ord Foreign | |
Defined in Language.Haskell.TH.Syntax | |
Ord FunDep | |
Ord Guard | |
Ord Info | |
Ord InjectivityAnn | |
Defined in Language.Haskell.TH.Syntax Methods compare :: InjectivityAnn -> InjectivityAnn -> Ordering # (<) :: InjectivityAnn -> InjectivityAnn -> Bool # (<=) :: InjectivityAnn -> InjectivityAnn -> Bool # (>) :: InjectivityAnn -> InjectivityAnn -> Bool # (>=) :: InjectivityAnn -> InjectivityAnn -> Bool # max :: InjectivityAnn -> InjectivityAnn -> InjectivityAnn # min :: InjectivityAnn -> InjectivityAnn -> InjectivityAnn # | |
Ord Inline | |
Ord Lit | |
Ord Loc | |
Ord Match | |
Ord ModName | |
Defined in Language.Haskell.TH.Syntax | |
Ord Module | |
Ord ModuleInfo | |
Defined in Language.Haskell.TH.Syntax Methods compare :: ModuleInfo -> ModuleInfo -> Ordering # (<) :: ModuleInfo -> ModuleInfo -> Bool # (<=) :: ModuleInfo -> ModuleInfo -> Bool # (>) :: ModuleInfo -> ModuleInfo -> Bool # (>=) :: ModuleInfo -> ModuleInfo -> Bool # max :: ModuleInfo -> ModuleInfo -> ModuleInfo # min :: ModuleInfo -> ModuleInfo -> ModuleInfo # | |
Ord Name | |
Ord NameFlavour | |
Defined in Language.Haskell.TH.Syntax Methods compare :: NameFlavour -> NameFlavour -> Ordering # (<) :: NameFlavour -> NameFlavour -> Bool # (<=) :: NameFlavour -> NameFlavour -> Bool # (>) :: NameFlavour -> NameFlavour -> Bool # (>=) :: NameFlavour -> NameFlavour -> Bool # max :: NameFlavour -> NameFlavour -> NameFlavour # min :: NameFlavour -> NameFlavour -> NameFlavour # | |
Ord NameSpace | |
Ord OccName | |
Defined in Language.Haskell.TH.Syntax | |
Ord Overlap | |
Defined in Language.Haskell.TH.Syntax | |
Ord Pat | |
Ord PatSynArgs | |
Defined in Language.Haskell.TH.Syntax Methods compare :: PatSynArgs -> PatSynArgs -> Ordering # (<) :: PatSynArgs -> PatSynArgs -> Bool # (<=) :: PatSynArgs -> PatSynArgs -> Bool # (>) :: PatSynArgs -> PatSynArgs -> Bool # (>=) :: PatSynArgs -> PatSynArgs -> Bool # max :: PatSynArgs -> PatSynArgs -> PatSynArgs # min :: PatSynArgs -> PatSynArgs -> PatSynArgs # | |
Ord PatSynDir | |
Ord Phases | |
Ord PkgName | |
Defined in Language.Haskell.TH.Syntax | |
Ord Pragma | |
Ord Range | |
Ord Role | |
Ord RuleBndr | |
Defined in Language.Haskell.TH.Syntax | |
Ord RuleMatch | |
Ord Safety | |
Ord SourceStrictness | |
Defined in Language.Haskell.TH.Syntax Methods compare :: SourceStrictness -> SourceStrictness -> Ordering # (<) :: SourceStrictness -> SourceStrictness -> Bool # (<=) :: SourceStrictness -> SourceStrictness -> Bool # (>) :: SourceStrictness -> SourceStrictness -> Bool # (>=) :: SourceStrictness -> SourceStrictness -> Bool # max :: SourceStrictness -> SourceStrictness -> SourceStrictness # min :: SourceStrictness -> SourceStrictness -> SourceStrictness # | |
Ord SourceUnpackedness | |
Defined in Language.Haskell.TH.Syntax Methods compare :: SourceUnpackedness -> SourceUnpackedness -> Ordering # (<) :: SourceUnpackedness -> SourceUnpackedness -> Bool # (<=) :: SourceUnpackedness -> SourceUnpackedness -> Bool # (>) :: SourceUnpackedness -> SourceUnpackedness -> Bool # (>=) :: SourceUnpackedness -> SourceUnpackedness -> Bool # max :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness # min :: SourceUnpackedness -> SourceUnpackedness -> SourceUnpackedness # | |
Ord Specificity | |
Defined in Language.Haskell.TH.Syntax Methods compare :: Specificity -> Specificity -> Ordering # (<) :: Specificity -> Specificity -> Bool # (<=) :: Specificity -> Specificity -> Bool # (>) :: Specificity -> Specificity -> Bool # (>=) :: Specificity -> Specificity -> Bool # max :: Specificity -> Specificity -> Specificity # min :: Specificity -> Specificity -> Specificity # | |
Ord Stmt | |
Ord TyLit | |
Ord TySynEqn | |
Defined in Language.Haskell.TH.Syntax | |
Ord Type | |
Ord TypeFamilyHead | |
Defined in Language.Haskell.TH.Syntax Methods compare :: TypeFamilyHead -> TypeFamilyHead -> Ordering # (<) :: TypeFamilyHead -> TypeFamilyHead -> Bool # (<=) :: TypeFamilyHead -> TypeFamilyHead -> Bool # (>) :: TypeFamilyHead -> TypeFamilyHead -> Bool # (>=) :: TypeFamilyHead -> TypeFamilyHead -> Bool # max :: TypeFamilyHead -> TypeFamilyHead -> TypeFamilyHead # min :: TypeFamilyHead -> TypeFamilyHead -> TypeFamilyHead # | |
Ord LocalTime | |
Defined in Data.Time.LocalTime.Internal.LocalTime | |
Ord Integer | |
Ord Natural | |
Ord () | |
Ord Bool | |
Ord Char | |
Ord Double | Note that due to the presence of
Also note that, due to the same,
|
Ord Float | Note that due to the presence of
Also note that, due to the same,
|
Ord Int | |
Ord Word | |
Ord a => Ord (Blind a) | |
Defined in Test.QuickCheck.Modifiers | |
Ord a => Ord (Fixed a) | |
Defined in Test.QuickCheck.Modifiers | |
Ord a => Ord (Large a) | |
Defined in Test.QuickCheck.Modifiers | |
Ord a => Ord (Negative a) | |
Defined in Test.QuickCheck.Modifiers | |
Ord a => Ord (NonEmptyList a) | |
Defined in Test.QuickCheck.Modifiers Methods compare :: NonEmptyList a -> NonEmptyList a -> Ordering # (<) :: NonEmptyList a -> NonEmptyList a -> Bool # (<=) :: NonEmptyList a -> NonEmptyList a -> Bool # (>) :: NonEmptyList a -> NonEmptyList a -> Bool # (>=) :: NonEmptyList a -> NonEmptyList a -> Bool # max :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a # min :: NonEmptyList a -> NonEmptyList a -> NonEmptyList a # | |
Ord a => Ord (NonNegative a) | |
Defined in Test.QuickCheck.Modifiers Methods compare :: NonNegative a -> NonNegative a -> Ordering # (<) :: NonNegative a -> NonNegative a -> Bool # (<=) :: NonNegative a -> NonNegative a -> Bool # (>) :: NonNegative a -> NonNegative a -> Bool # (>=) :: NonNegative a -> NonNegative a -> Bool # max :: NonNegative a -> NonNegative a -> NonNegative a # min :: NonNegative a -> NonNegative a -> NonNegative a # | |
Ord a => Ord (NonPositive a) | |
Defined in Test.QuickCheck.Modifiers Methods compare :: NonPositive a -> NonPositive a -> Ordering # (<) :: NonPositive a -> NonPositive a -> Bool # (<=) :: NonPositive a -> NonPositive a -> Bool # (>) :: NonPositive a -> NonPositive a -> Bool # (>=) :: NonPositive a -> NonPositive a -> Bool # max :: NonPositive a -> NonPositive a -> NonPositive a # min :: NonPositive a -> NonPositive a -> NonPositive a # | |
Ord a => Ord (NonZero a) | |
Ord a => Ord (OrderedList a) | |
Defined in Test.QuickCheck.Modifiers Methods compare :: OrderedList a -> OrderedList a -> Ordering # (<) :: OrderedList a -> OrderedList a -> Bool # (<=) :: OrderedList a -> OrderedList a -> Bool # (>) :: OrderedList a -> OrderedList a -> Bool # (>=) :: OrderedList a -> OrderedList a -> Bool # max :: OrderedList a -> OrderedList a -> OrderedList a # min :: OrderedList a -> OrderedList a -> OrderedList a # | |
Ord a => Ord (Positive a) | |
Defined in Test.QuickCheck.Modifiers | |
Ord a => Ord (Shrink2 a) | |
Ord a => Ord (Small a) | |
Defined in Test.QuickCheck.Modifiers | |
Ord a => Ord (SortedList a) | |
Defined in Test.QuickCheck.Modifiers Methods compare :: SortedList a -> SortedList a -> Ordering # (<) :: SortedList a -> SortedList a -> Bool # (<=) :: SortedList a -> SortedList a -> Bool # (>) :: SortedList a -> SortedList a -> Bool # (>=) :: SortedList a -> SortedList a -> Bool # max :: SortedList a -> SortedList a -> SortedList a # min :: SortedList a -> SortedList a -> SortedList a # | |
Ord a => Ord (ZipList a) | Since: base-4.7.0.0 |
Ord a => Ord (NonEmpty a) | Since: base-4.9.0.0 |
Ord p => Ord (Par1 p) | Since: base-4.7.0.0 |
Ord (FunPtr a) | |
Defined in GHC.Ptr | |
Ord (Ptr a) | Since: base-2.1 |
Integral a => Ord (Ratio a) | Since: base-2.0.1 |
Ord a => Ord (IntMap a) | |
Defined in Data.IntMap.Internal | |
Ord a => Ord (Seq a) | |
Ord a => Ord (ViewL a) | |
Defined in Data.Sequence.Internal | |
Ord a => Ord (ViewR a) | |
Defined in Data.Sequence.Internal | |
Ord a => Ord (Intersection a) | |
Defined in Data.Set.Internal Methods compare :: Intersection a -> Intersection a -> Ordering # (<) :: Intersection a -> Intersection a -> Bool # (<=) :: Intersection a -> Intersection a -> Bool # (>) :: Intersection a -> Intersection a -> Bool # (>=) :: Intersection a -> Intersection a -> Bool # max :: Intersection a -> Intersection a -> Intersection a # min :: Intersection a -> Intersection a -> Intersection a # | |
Ord a => Ord (Set a) | |
Ord a => Ord (Tree a) | Since: containers-0.6.5 |
Ord a => Ord (Array a) | Lexicographic ordering. Subject to change between major versions. |
Defined in Data.Primitive.Array | |
(Ord a, Prim a) => Ord (PrimArray a) | Lexicographic ordering. Subject to change between major versions. Since: primitive-0.6.4.0 |
Defined in Data.Primitive.PrimArray | |
Ord a => Ord (SmallArray a) | Lexicographic ordering. Subject to change between major versions. |
Defined in Data.Primitive.SmallArray Methods compare :: SmallArray a -> SmallArray a -> Ordering # (<) :: SmallArray a -> SmallArray a -> Bool # (<=) :: SmallArray a -> SmallArray a -> Bool # (>) :: SmallArray a -> SmallArray a -> Bool # (>=) :: SmallArray a -> SmallArray a -> Bool # max :: SmallArray a -> SmallArray a -> SmallArray a # min :: SmallArray a -> SmallArray a -> SmallArray a # | |
Ord (BlockCount p) | |
Defined in Raaz.Core.Primitive Methods compare :: BlockCount p -> BlockCount p -> Ordering # (<) :: BlockCount p -> BlockCount p -> Bool # (<=) :: BlockCount p -> BlockCount p -> Bool # (>) :: BlockCount p -> BlockCount p -> Bool # (>=) :: BlockCount p -> BlockCount p -> Bool # max :: BlockCount p -> BlockCount p -> BlockCount p # min :: BlockCount p -> BlockCount p -> BlockCount p # | |
Ord w => Ord (BE w) | |
Ord w => Ord (LE w) | |
Ord a => Ord (BYTES a) | |
Defined in Raaz.Core.Types.Pointer | |
Ord g => Ord (StateGen g) | |
Defined in System.Random.Internal | |
Ord flag => Ord (TyVarBndr flag) | |
Defined in Language.Haskell.TH.Syntax Methods compare :: TyVarBndr flag -> TyVarBndr flag -> Ordering # (<) :: TyVarBndr flag -> TyVarBndr flag -> Bool # (<=) :: TyVarBndr flag -> TyVarBndr flag -> Bool # (>) :: TyVarBndr flag -> TyVarBndr flag -> Bool # (>=) :: TyVarBndr flag -> TyVarBndr flag -> Bool # | |
(Prim a, Ord a) => Ord (Vector a) | |
Defined in Data.Vector.Primitive | |
Ord a => Ord (Maybe a) | Since: base-2.1 |
Ord a => Ord (a) | |
Ord a => Ord [a] | |
(Ord a, Ord b) => Ord (Either a b) | Since: base-2.1 |
Ord (Proxy s) | Since: base-4.7.0.0 |
Ord (TypeRep a) | Since: base-4.4.0.0 |
Ord (U1 p) | Since: base-4.7.0.0 |
Ord (V1 p) | Since: base-4.9.0.0 |
(Ord k, Ord v) => Ord (Map k v) | |
(Ord a, Ord b) => Ord (a, b) | |
Ord a => Ord (Const a b) | Since: base-4.9.0.0 |
(Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a) | Since: base-4.18.0.0 |
Defined in GHC.Generics Methods compare :: Generically1 f a -> Generically1 f a -> Ordering # (<) :: Generically1 f a -> Generically1 f a -> Bool # (<=) :: Generically1 f a -> Generically1 f a -> Bool # (>) :: Generically1 f a -> Generically1 f a -> Bool # (>=) :: Generically1 f a -> Generically1 f a -> Bool # max :: Generically1 f a -> Generically1 f a -> Generically1 f a # min :: Generically1 f a -> Generically1 f a -> Generically1 f a # | |
Ord (f p) => Ord (Rec1 f p) | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
Ord (URec (Ptr ()) p) | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods compare :: URec (Ptr ()) p -> URec (Ptr ()) p -> Ordering # (<) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (<=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (>) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (>=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # max :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p # min :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p # | |
Ord (URec Char p) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
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 # | |
Ord (URec Float p) | |
Defined in GHC.Generics | |
Ord (URec Int p) | Since: base-4.9.0.0 |
Ord (URec Word p) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Ord a => Ord (Constant a b) | |
Defined in Data.Functor.Constant | |
(Ord a, Ord b, Ord c) => Ord (a, b, c) | |
(Ord (f p), Ord (g p)) => Ord ((f :*: g) p) | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
(Ord (f p), Ord (g p)) => Ord ((f :+: g) p) | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
Ord c => Ord (K1 i c p) | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
(Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d) | |
Defined in GHC.Classes | |
Ord (f (g p)) => Ord ((f :.: g) p) | Since: base-4.7.0.0 |
Defined in GHC.Generics | |
Ord (f p) => Ord (M1 i c f p) | Since: base-4.7.0.0 |
(Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e) -> (a, b, c, d, e) -> Ordering # (<) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool # (<=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool # (>) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool # (>=) :: (a, b, c, d, e) -> (a, b, c, d, e) -> Bool # max :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) # min :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f) => Ord (a, b, c, d, e, f) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Ordering # (<) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool # (<=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool # (>) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool # (>=) :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> Bool # max :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) # min :: (a, b, c, d, e, f) -> (a, b, c, d, e, f) -> (a, b, c, d, e, f) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g) => Ord (a, b, c, d, e, f, g) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Ordering # (<) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool # (<=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool # (>) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool # (>=) :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> Bool # max :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) # min :: (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) -> (a, b, c, d, e, f, g) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h) => Ord (a, b, c, d, e, f, g, h) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Ordering # (<) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool # (<=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool # (>) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool # (>=) :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> Bool # max :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) # min :: (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) -> (a, b, c, d, e, f, g, h) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i) => Ord (a, b, c, d, e, f, g, h, i) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Ordering # (<) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool # (<=) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool # (>) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool # (>=) :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> Bool # max :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) # min :: (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) -> (a, b, c, d, e, f, g, h, i) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j) => Ord (a, b, c, d, e, f, g, h, i, j) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Ordering # (<) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool # (<=) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool # (>) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool # (>=) :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> Bool # max :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) # min :: (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) -> (a, b, c, d, e, f, g, h, i, j) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k) => Ord (a, b, c, d, e, f, g, h, i, j, k) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Ordering # (<) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool # (<=) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool # (>) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool # (>=) :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> Bool # max :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) # min :: (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) -> (a, b, c, d, e, f, g, h, i, j, k) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l) => Ord (a, b, c, d, e, f, g, h, i, j, k, l) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Ordering # (<) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool # (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool # (>) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool # (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> Bool # max :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) # min :: (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (a, b, c, d, e, f, g, h, i, j, k, l) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Ordering # (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool # (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool # (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool # (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> Bool # max :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) # min :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Ordering # (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool # (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool # (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool # (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> Bool # max :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # min :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # | |
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) | |
Defined in GHC.Classes Methods compare :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Ordering # (<) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool # (<=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool # (>) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool # (>=) :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> Bool # max :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) # min :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) # |
A Selector
is a predicate; it can simultaneously constrain the type and
value of an exception.
Instances
Arbitrary S Source # | |
IsString S | |
Defined in Raaz.Primitive.Poly1305.Internal Methods fromString :: String -> S # | |
Storable S | |
Defined in Raaz.Primitive.Poly1305.Internal | |
Show S | |
Eq S | |
Encodable S | |
Defined in Raaz.Primitive.Poly1305.Internal Methods toByteString :: S -> ByteString # fromByteString :: ByteString -> Maybe S # unsafeFromByteString :: ByteString -> S # | |
EndianStore S | |
Equality S | |
Defined in Raaz.Primitive.Poly1305.Internal |
Instances
Arbitrary R Source # | |
IsString R | |
Defined in Raaz.Primitive.Poly1305.Internal Methods fromString :: String -> R # | |
Storable R | |
Defined in Raaz.Primitive.Poly1305.Internal | |
Show R | |
Eq R | |
Encodable R | |
Defined in Raaz.Primitive.Poly1305.Internal Methods toByteString :: R -> ByteString # fromByteString :: ByteString -> Maybe R # unsafeFromByteString :: ByteString -> R # | |
EndianStore R | |
Equality R | |
Defined in Raaz.Primitive.Poly1305.Internal |
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:*
)
recip
gives the multiplicative inversex * recip x
=recip x * x
=fromInteger 1
- Totality of
toRational
toRational
is total- Coherence with
toRational
- if the type also implements
Real
, thenfromRational
is 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
Integer
fromRational
to a value of type Rational
, so such literals have type
(
.Fractional
a) => a
Instances
Integral a => Fractional (Ratio a) | Since: base-2.0.1 |
Fractional a => Fractional (Const a b) | Since: base-4.9.0.0 |
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
, thenfromRational
is a left inverse fortoRational
, i.e.fromRational (toRational i) = i
Methods
toRational :: a -> Rational #
the rational equivalent of its real argument with full precision
Instances
The Eq
class defines equality (==
) and inequality (/=
).
All the basic datatypes exported by the Prelude are instances of Eq
,
and Eq
may be derived for any datatype whose constituents are also
instances of Eq
.
The Haskell Report defines no laws for Eq
. However, instances are
encouraged to follow these properties:
Instances
8-bit unsigned integer type
Instances
Haskell defines operations to read and write characters from and to files,
represented by values of type Handle
. Each value of this type is a
handle: a record used by the Haskell run-time system to manage I/O
with file system objects. A handle has at least the following properties:
- whether it manages input or output or both;
- whether it is open, closed or semi-closed;
- whether the object is seekable;
- whether buffering is disabled, or enabled on a line or block basis;
- a buffer (whose length may be zero).
Most handles will also have a current I/O position indicating where the next
input or output operation will occur. A handle is readable if it
manages only input or both input and output; likewise, it is writable if
it manages only output or both input and output. A handle is open when
first allocated.
Once it is closed it can no longer be used for either input or output,
though an implementation cannot re-use its storage while references
remain to it. Handles are in the Show
and Eq
classes. The string
produced by showing a handle is system dependent; it should include
enough information to identify the handle for debugging. A handle is
equal according to ==
only to itself; no attempt
is made to compare the internal state of different handles for equality.
Instances
Show Handle | Since: base-4.1.0.0 |
Eq Handle | Since: base-4.1.0.0 |
ByteSource Handle | |
Defined in Raaz.Core.ByteSource |
64-bit unsigned integer type
Instances
32-bit unsigned integer type
Instances
16-bit unsigned integer type
Instances
The Either
type represents values with two possibilities: a value of
type
is either Either
a b
or Left
a
.Right
b
The Either
type is sometimes used to represent a value which is
either correct or an error; by convention, the Left
constructor is
used to hold an error value and the Right
constructor is used to
hold a correct value (mnemonic: "right" also means "correct").
Examples
The type
is the type of values which can be either
a Either
String
Int
String
or an Int
. The Left
constructor can be used only on
String
s, and the Right
constructor can be used only on Int
s:
>>>
let s = Left "foo" :: Either String Int
>>>
s
Left "foo">>>
let n = Right 3 :: Either String Int
>>>
n
Right 3>>>
:type s
s :: Either String Int>>>
:type n
n :: Either String Int
The fmap
from our Functor
instance will ignore Left
values, but
will apply the supplied function to values contained in a Right
:
>>>
let s = Left "foo" :: Either String Int
>>>
let n = Right 3 :: Either String Int
>>>
fmap (*2) s
Left "foo">>>
fmap (*2) n
Right 6
The Monad
instance for Either
allows us to chain together multiple
actions which may fail, and fail overall if any of the individual
steps failed. First we'll write a function that can either parse an
Int
from a Char
, or fail.
>>>
import Data.Char ( digitToInt, isDigit )
>>>
:{
let parseEither :: Char -> Either String Int parseEither c | isDigit c = Right (digitToInt c) | otherwise = Left "parse error">>>
:}
The following should work, since both '1'
and '2'
can be
parsed as Int
s.
>>>
:{
let parseMultiple :: Either String Int parseMultiple = do x <- parseEither '1' y <- parseEither '2' return (x + y)>>>
:}
>>>
parseMultiple
Right 3
But the following should fail overall, since the first operation where
we attempt to parse 'm'
as an Int
will fail:
>>>
:{
let parseMultiple :: Either String Int parseMultiple = do x <- parseEither 'm' y <- parseEither '2' return (x + y)>>>
:}
>>>
parseMultiple
Left "parse error"
Instances
Arbitrary2 Either | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary2 :: Gen a -> Gen b -> Gen (Either a b) # liftShrink2 :: (a -> [a]) -> (b -> [b]) -> Either a b -> [Either a b] # | |
NFData2 Either | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Generic1 (Either a :: Type -> Type) | |
(Lift a, Lift b) => Lift (Either a b :: Type) | |
Arbitrary a => Arbitrary1 (Either a) | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary :: Gen a0 -> Gen (Either a a0) # liftShrink :: (a0 -> [a0]) -> Either a a0 -> [Either a a0] # | |
Foldable (Either a) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Either a m -> m # foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # toList :: Either a a0 -> [a0] # length :: Either a a0 -> Int # elem :: Eq a0 => a0 -> Either a a0 -> Bool # maximum :: Ord a0 => Either a a0 -> a0 # minimum :: Ord a0 => Either a a0 -> a0 # | |
Traversable (Either a) | Since: base-4.7.0.0 |
Defined in Data.Traversable | |
Applicative (Either e) | Since: base-3.0 |
Functor (Either a) | Since: base-3.0 |
Monad (Either e) | Since: base-4.4.0.0 |
NFData a => NFData1 (Either a) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
(Arbitrary a, Arbitrary b) => Arbitrary (Either a b) | |
(CoArbitrary a, CoArbitrary b) => CoArbitrary (Either a b) | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Either a b -> Gen b0 -> Gen b0 # | |
(Function a, Function b) => Function (Either a b) | |
Semigroup (Either a b) | Since: base-4.9.0.0 |
Generic (Either a b) | |
(Read a, Read b) => Read (Either a b) | Since: base-3.0 |
(Show a, Show b) => Show (Either a b) | Since: base-3.0 |
(NFData a, NFData b) => NFData (Either a b) | |
Defined in Control.DeepSeq | |
(Eq a, Eq b) => Eq (Either a b) | Since: base-2.1 |
(Ord a, Ord b) => Ord (Either a b) | Since: base-2.1 |
type Rep1 (Either a :: Type -> Type) | Since: base-4.6.0.0 |
Defined in GHC.Generics type Rep1 (Either a :: Type -> Type) = D1 ('MetaData "Either" "Data.Either" "base" 'False) (C1 ('MetaCons "Left" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Right" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1)) | |
type Rep (Either a b) | Since: base-4.6.0.0 |
Defined in GHC.Generics type Rep (Either a b) = D1 ('MetaData "Either" "Data.Either" "base" 'False) (C1 ('MetaCons "Left" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "Right" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b))) |
class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where #
Monads that also support choice and failure.
Minimal complete definition
Nothing
Methods
The identity of mplus
. It should also satisfy the equations
mzero >>= f = mzero v >> mzero = mzero
The default definition is
mzero = empty
An associative operation. The default definition is
mplus = (<|>
)
Instances
MonadPlus P | Since: base-2.1 |
Defined in Text.ParserCombinators.ReadP | |
MonadPlus ReadP | Since: base-2.1 |
MonadPlus Seq | |
MonadPlus IO | Takes the first non-throwing Since: base-4.9.0.0 |
MonadPlus Array | |
MonadPlus SmallArray | |
Defined in Data.Primitive.SmallArray | |
MonadPlus Maybe | Picks the leftmost Since: base-2.1 |
MonadPlus List | Combines lists by concatenation, starting from the empty list. Since: base-2.1 |
MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
MonadPlus (U1 :: Type -> Type) | Since: base-4.9.0.0 |
MonadPlus f => MonadPlus (Rec1 f) | Since: base-4.9.0.0 |
(MonadPlus f, MonadPlus g) => MonadPlus (f :*: g) | Since: base-4.9.0.0 |
MonadPlus f => MonadPlus (M1 i c f) | Since: base-4.9.0.0 |
The member functions of this class facilitate writing values of primitive types to raw memory (which may have been allocated with the above mentioned routines) and reading values from blocks of raw memory. The class, furthermore, includes support for computing the storage requirements and alignment restrictions of storable types.
Memory addresses are represented as values of type
, for some
Ptr
aa
which is an instance of class Storable
. The type argument to
Ptr
helps provide some valuable type safety in FFI code (you can't
mix pointers of different types without an explicit cast), while
helping the Haskell type system figure out which marshalling method is
needed for a given pointer.
All marshalling between Haskell and a foreign language ultimately
boils down to translating Haskell data structures into the binary
representation of a corresponding data structure of the foreign
language and vice versa. To code this marshalling in Haskell, it is
necessary to manipulate primitive data types stored in unstructured
memory blocks. The class Storable
facilitates this manipulation on
all types for which it is instantiated, which are the standard basic
types of Haskell, the fixed size Int
types (Int8
, Int16
,
Int32
, Int64
), the fixed size Word
types (Word8
, Word16
,
Word32
, Word64
), StablePtr
, all types from Foreign.C.Types,
as well as Ptr
.
Minimal complete definition
sizeOf, alignment, (peek | peekElemOff | peekByteOff), (poke | pokeElemOff | pokeByteOff)
Methods
Read a value from the given memory location.
Note that the peek and poke functions might require properly
aligned addresses to function correctly. This is architecture
dependent; thus, portable code should ensure that when peeking or
poking values of some type a
, the alignment
constraint for a
, as given by the function
alignment
is fulfilled.
Write the given value to the given memory location. Alignment
restrictions might apply; see peek
.
Instances
A value of type
represents a pointer to an object, or an
array of objects, which may be marshalled to or from Haskell values
of type Ptr
aa
.
The type a
will often be an instance of class
Storable
which provides the marshalling operations.
However this is not essential, and you can provide your own operations
to access the pointer. For example you might write small foreign
functions to get or set the fields of a C struct
.
Instances
IsString WriteTo | |
Defined in Raaz.Core.Transfer.Unsafe Methods fromString :: String -> WriteTo # | |
NFData1 Ptr | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Encodable WriteTo | |
Defined in Raaz.Core.Transfer.Unsafe | |
Pointer Ptr | |
Defined in Raaz.Core.Types.Pointer Methods castPointer :: Ptr a -> Ptr b # allocaPointer :: BYTES Int -> (Ptr a -> IO b) -> IO b # unsafeRawPtr :: Ptr a -> Ptr a # | |
Generic1 (URec (Ptr ()) :: k -> Type) | |
Foldable (UAddr :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UAddr m -> m # foldMap :: Monoid m => (a -> m) -> UAddr a -> m # foldMap' :: Monoid m => (a -> m) -> UAddr a -> m # foldr :: (a -> b -> b) -> b -> UAddr a -> b # foldr' :: (a -> b -> b) -> b -> UAddr a -> b # foldl :: (b -> a -> b) -> b -> UAddr a -> b # foldl' :: (b -> a -> b) -> b -> UAddr a -> b # foldr1 :: (a -> a -> a) -> UAddr a -> a # foldl1 :: (a -> a -> a) -> UAddr a -> a # elem :: Eq a => a -> UAddr a -> Bool # maximum :: Ord a => UAddr a -> a # minimum :: Ord a => UAddr a -> a # | |
Traversable (UAddr :: Type -> Type) | Since: base-4.9.0.0 |
Storable (Ptr a) | Since: base-2.1 |
Show (Ptr a) | Since: base-2.1 |
NFData (Ptr a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
Eq (Ptr a) | Since: base-2.1 |
Ord (Ptr a) | Since: base-2.1 |
Distributive (BYTES Int) (TransferAction t) | |
Defined in Raaz.Core.Transfer.Unsafe | |
LAction (BYTES Int) (TransferAction t) | |
Defined in Raaz.Core.Transfer.Unsafe | |
Functor (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0 |
Generic (URec (Ptr ()) p) | |
Eq (URec (Ptr ()) p) | Since: base-4.9.0.0 |
Ord (URec (Ptr ()) p) | Since: base-4.9.0.0 |
Defined in GHC.Generics Methods compare :: URec (Ptr ()) p -> URec (Ptr ()) p -> Ordering # (<) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (<=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (>) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # (>=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool # max :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p # min :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p # | |
data URec (Ptr ()) (p :: k) | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec (Ptr ()) :: k -> Type) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec (Ptr ()) p) | Since: base-4.9.0.0 |
Defined in GHC.Generics |
data TextEncoding #
A TextEncoding
is a specification of a conversion scheme
between sequences of bytes and sequences of Unicode characters.
For example, UTF-8 is an encoding of Unicode characters into a sequence
of bytes. The TextEncoding
for UTF-8 is utf8
.
Instances
Show TextEncoding | Since: base-4.3.0.0 |
Defined in GHC.IO.Encoding.Types Methods showsPrec :: Int -> TextEncoding -> ShowS # show :: TextEncoding -> String # showList :: [TextEncoding] -> ShowS # |
type IOError = IOException #
The Haskell 2010 type for exceptions in the IO
monad.
Any I/O operation may raise an IOException
instead of returning a result.
For a more general type of exception, including also those that arise
in pure code, see Exception
.
In Haskell 2010, this is an opaque type.
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 b
exp (fromInteger 0)
=fromInteger 1
Minimal complete definition
pi, exp, log, sin, cos, asin, acos, atan, sinh, cosh, asinh, acosh, atanh
Instances
Floating Double | Since: base-2.1 |
Floating Float | Since: base-2.1 |
Floating a => Floating (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods exp :: Const a b -> Const a b # log :: Const a b -> Const a b # sqrt :: Const a b -> Const a b # (**) :: Const a b -> Const a b -> Const a b # logBase :: Const a b -> Const a b -> Const a b # sin :: Const a b -> Const a b # cos :: Const a b -> Const a b # tan :: Const a b -> Const a b # asin :: Const a b -> Const a b # acos :: Const a b -> Const a b # atan :: Const a b -> Const a b # sinh :: Const a b -> Const a b # cosh :: Const a b -> Const a b # tanh :: Const a b -> Const a b # asinh :: Const a b -> Const a b # acosh :: Const a b -> Const a b # atanh :: Const a b -> Const a b # log1p :: Const a b -> Const a b # expm1 :: Const a b -> Const a b # |
Basic numeric class.
The Haskell Report defines no laws for Num
. However, (
and +
)(
are
customarily expected to define a ring and have the following properties:*
)
- Associativity of
(
+
) (x + y) + z
=x + (y + z)
- Commutativity of
(
+
) x + y
=y + x
is the additive identityfromInteger
0x + fromInteger 0
=x
negate
gives the additive inversex + negate x
=fromInteger 0
- Associativity of
(
*
) (x * y) * z
=x * (y * z)
is the multiplicative identityfromInteger
1x * fromInteger 1
=x
andfromInteger 1 * x
=x
- Distributivity of
(
with respect to*
)(
+
) a * (b + c)
=(a * b) + (a * c)
and(b + c) * a
=(b * a) + (c * a)
- Coherence with
toInteger
- if the type also implements
Integral
, thenfromInteger
is a left inverse fortoInteger
, i.e.fromInteger (toInteger i) == i
Note that it isn't customarily expected that a type instance of both Num
and Ord
implement an ordered ring. Indeed, in base
only Integer
and
Rational
do.
Methods
Unary negation.
Absolute value.
Sign of a number.
The functions abs
and signum
should satisfy the law:
abs x * signum x == x
For real numbers, the signum
is either -1
(negative), 0
(zero)
or 1
(positive).
fromInteger :: Integer -> a #
Conversion from an Integer
.
An integer literal represents the application of the function
fromInteger
to the appropriate value of type Integer
,
so such literals have type (
.Num
a) => a
Instances
Num IntPtr | |
Num WordPtr | |
Num Word16 | Since: base-2.1 |
Num Word32 | Since: base-2.1 |
Num Word64 | Since: base-2.1 |
Num Word8 | Since: base-2.1 |
Num Integer | Since: base-2.1 |
Num Natural | Note that Since: base-4.8.0.0 |
Num Int | Since: base-2.1 |
Num Word | Since: base-2.1 |
Num a => Num (Blind a) | |
Num a => Num (Fixed a) | |
Num a => Num (Large a) | |
Num a => Num (Shrink2 a) | |
Defined in Test.QuickCheck.Modifiers | |
Num a => Num (Small a) | |
Integral a => Num (Ratio a) | Since: base-2.0.1 |
Num w => Num (BE w) | |
Num w => Num (LE w) | |
Num a => Num (BYTES a) | |
Num a => Num (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const |
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
class Monad m => MonadFail (m :: Type -> Type) where #
When a value is bound in do
-notation, the pattern on the left
hand side of <-
might not match. In this case, this class
provides a function to recover.
A Monad
without a MonadFail
instance may only be used in conjunction
with pattern that always match, such as newtypes, tuples, data types with
only a single data constructor, and irrefutable patterns (~pat
).
Instances of MonadFail
should satisfy the following law: fail s
should
be a left zero for >>=
,
fail s >>= f = fail s
If your Monad
is also MonadPlus
, a popular definition is
fail _ = mzero
fail s
should be an action that runs in the monad itself, not an
exception (except in instances of MonadIO
). In particular,
fail
should not be implemented in terms of error
.
Since: base-4.9.0.0
Instances
MonadFail P | Since: base-4.9.0.0 |
Defined in Text.ParserCombinators.ReadP | |
MonadFail ReadP | Since: base-4.9.0.0 |
Defined in Text.ParserCombinators.ReadP | |
MonadFail IO | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
MonadFail Array | |
Defined in Data.Primitive.Array | |
MonadFail SmallArray | |
Defined in Data.Primitive.SmallArray Methods fail :: String -> SmallArray a # | |
MonadFail Q | |
Defined in Language.Haskell.TH.Syntax | |
MonadFail Maybe | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
MonadFail List | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
Monad m => MonadFail (PropertyM m) | |
Defined in Test.QuickCheck.Monadic |
Class for string-like datastructures; used by the overloaded string extension (-XOverloadedStrings in GHC).
Methods
fromString :: String -> a #
Instances
class Foldable (t :: Type -> Type) where #
The Foldable class represents data structures that can be reduced to a summary value one element at a time. Strict left-associative folds are a good fit for space-efficient reduction, while lazy right-associative folds are a good fit for corecursive iteration, or for folds that short-circuit after processing an initial subsequence of the structure's elements.
Instances can be derived automatically by enabling the DeriveFoldable
extension. For example, a derived instance for a binary tree might be:
{-# LANGUAGE DeriveFoldable #-} data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) deriving Foldable
A more detailed description can be found in the Overview section of Data.Foldable.
For the class laws see the Laws section of Data.Foldable.
Methods
foldMap :: Monoid m => (a -> m) -> t a -> m #
Map each element of the structure into a monoid, and combine the
results with (
. This fold is right-associative and lazy in the
accumulator. For strict left-associative folds consider <>
)foldMap'
instead.
Examples
Basic usage:
>>>
foldMap Sum [1, 3, 5]
Sum {getSum = 9}
>>>
foldMap Product [1, 3, 5]
Product {getProduct = 15}
>>>
foldMap (replicate 3) [1, 2, 3]
[1,1,1,2,2,2,3,3,3]
When a Monoid's (
is lazy in its second argument, <>
)foldMap
can
return a result even from an unbounded structure. For example, lazy
accumulation enables Data.ByteString.Builder to efficiently serialise
large data structures and produce the output incrementally:
>>>
import qualified Data.ByteString.Lazy as L
>>>
import qualified Data.ByteString.Builder as B
>>>
let bld :: Int -> B.Builder; bld i = B.intDec i <> B.word8 0x20
>>>
let lbs = B.toLazyByteString $ foldMap bld [0..]
>>>
L.take 64 lbs
"0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"
foldr :: (a -> b -> b) -> b -> t a -> b #
Right-associative fold of a structure, lazy in the accumulator.
In the case of lists, foldr
, when applied to a binary operator, a
starting value (typically the right-identity of the operator), and a
list, reduces the list using the binary operator, from right to left:
foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
Note that since the head of the resulting expression is produced by an
application of the operator to the first element of the list, given an
operator lazy in its right argument, foldr
can produce a terminating
expression from an unbounded list.
For a general Foldable
structure this should be semantically identical
to,
foldr f z =foldr
f z .toList
Examples
Basic usage:
>>>
foldr (||) False [False, True, False]
True
>>>
foldr (||) False []
False
>>>
foldr (\c acc -> acc ++ [c]) "foo" ['a', 'b', 'c', 'd']
"foodcba"
Infinite structures
⚠️ Applying foldr
to infinite structures usually doesn't terminate.
It may still terminate under one of the following conditions:
- the folding function is short-circuiting
- the folding function is lazy on its second argument
Short-circuiting
(
short-circuits on ||
)True
values, so the following terminates
because there is a True
value finitely far from the left side:
>>>
foldr (||) False (True : repeat False)
True
But the following doesn't terminate:
>>>
foldr (||) False (repeat False ++ [True])
* Hangs forever *
Laziness in the second argument
Applying foldr
to infinite structures terminates when the operator is
lazy in its second argument (the initial accumulator is never used in
this case, and so could be left undefined
, but []
is more clear):
>>>
take 5 $ foldr (\i acc -> i : fmap (+3) acc) [] (repeat 1)
[1,4,7,10,13]
foldl :: (b -> a -> b) -> b -> t a -> b #
Left-associative fold of a structure, lazy in the accumulator. This is rarely what you want, but can work well for structures with efficient right-to-left sequencing and an operator that is lazy in its left argument.
In the case of lists, foldl
, when applied to a binary operator, a
starting value (typically the left-identity of the operator), and a
list, reduces the list using the binary operator, from left to right:
foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
Note that to produce the outermost application of the operator the
entire input list must be traversed. Like all left-associative folds,
foldl
will diverge if given an infinite list.
If you want an efficient strict left-fold, you probably want to use
foldl'
instead of foldl
. The reason for this is that the latter
does not force the inner results (e.g. z `f` x1
in the above
example) before applying them to the operator (e.g. to (`f` x2)
).
This results in a thunk chain O(n) elements long, which then must be
evaluated from the outside-in.
For a general Foldable
structure this should be semantically identical
to:
foldl f z =foldl
f z .toList
Examples
The first example is a strict fold, which in practice is best performed
with foldl'
.
>>>
foldl (+) 42 [1,2,3,4]
52
Though the result below is lazy, the input is reversed before prepending it to the initial accumulator, so corecursion begins only after traversing the entire input string.
>>>
foldl (\acc c -> c : acc) "abcd" "efgh"
"hgfeabcd"
A left fold of a structure that is infinite on the right cannot terminate, even when for any finite input the fold just returns the initial accumulator:
>>>
foldl (\a _ -> a) 0 $ repeat 1
* Hangs forever *
WARNING: When it comes to lists, you always want to use either foldl'
or foldr
instead.
foldr1 :: (a -> a -> a) -> t a -> a #
A variant of foldr
that has no base case,
and thus may only be applied to non-empty structures.
This function is non-total and will raise a runtime exception if the structure happens to be empty.
Examples
Basic usage:
>>>
foldr1 (+) [1..4]
10
>>>
foldr1 (+) []
Exception: Prelude.foldr1: empty list
>>>
foldr1 (+) Nothing
*** Exception: foldr1: empty structure
>>>
foldr1 (-) [1..4]
-2
>>>
foldr1 (&&) [True, False, True, True]
False
>>>
foldr1 (||) [False, False, True, True]
True
>>>
foldr1 (+) [1..]
* Hangs forever *
foldl1 :: (a -> a -> a) -> t a -> a #
A variant of foldl
that has no base case,
and thus may only be applied to non-empty structures.
This function is non-total and will raise a runtime exception if the structure happens to be empty.
foldl1
f =foldl1
f .toList
Examples
Basic usage:
>>>
foldl1 (+) [1..4]
10
>>>
foldl1 (+) []
*** Exception: Prelude.foldl1: empty list
>>>
foldl1 (+) Nothing
*** Exception: foldl1: empty structure
>>>
foldl1 (-) [1..4]
-8
>>>
foldl1 (&&) [True, False, True, True]
False
>>>
foldl1 (||) [False, False, True, True]
True
>>>
foldl1 (+) [1..]
* Hangs forever *
Test whether the structure is empty. The default implementation is Left-associative and lazy in both the initial element and the accumulator. Thus optimised for structures where the first element can be accessed in constant time. Structures where this is not the case should have a non-default implementation.
Examples
Basic usage:
>>>
null []
True
>>>
null [1]
False
null
is expected to terminate even for infinite structures.
The default implementation terminates provided the structure
is bounded on the left (there is a leftmost element).
>>>
null [1..]
False
Since: base-4.8.0.0
elem :: Eq a => a -> t a -> Bool infix 4 #
Does the element occur in the structure?
Note: elem
is often used in infix form.
Examples
Basic usage:
>>>
3 `elem` []
False
>>>
3 `elem` [1,2]
False
>>>
3 `elem` [1,2,3,4,5]
True
For infinite structures, the default implementation of elem
terminates if the sought-after value exists at a finite distance
from the left side of the structure:
>>>
3 `elem` [1..]
True
>>>
3 `elem` ([4..] ++ [3])
* Hangs forever *
Since: base-4.8.0.0
maximum :: Ord a => t a -> a #
The largest element of a non-empty structure.
This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the maximum in faster than linear time.
Examples
Basic usage:
>>>
maximum [1..10]
10
>>>
maximum []
*** Exception: Prelude.maximum: empty list
>>>
maximum Nothing
*** Exception: maximum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
Since: base-4.8.0.0
minimum :: Ord a => t a -> a #
The least element of a non-empty structure.
This function is non-total and will raise a runtime exception if the structure happens to be empty. A structure that supports random access and maintains its elements in order should provide a specialised implementation to return the minimum in faster than linear time.
Examples
Basic usage:
>>>
minimum [1..10]
1
>>>
minimum []
*** Exception: Prelude.minimum: empty list
>>>
minimum Nothing
*** Exception: minimum: empty structure
WARNING: This function is partial for possibly-empty structures like lists.
Since: base-4.8.0.0
The sum
function computes the sum of the numbers of a structure.
Examples
Basic usage:
>>>
sum []
0
>>>
sum [42]
42
>>>
sum [1..10]
55
>>>
sum [4.1, 2.0, 1.7]
7.8
>>>
sum [1..]
* Hangs forever *
Since: base-4.8.0.0
product :: Num a => t a -> a #
The product
function computes the product of the numbers of a
structure.
Examples
Basic usage:
>>>
product []
1
>>>
product [42]
42
>>>
product [1..10]
3628800
>>>
product [4.1, 2.0, 1.7]
13.939999999999998
>>>
product [1..]
* Hangs forever *
Since: base-4.8.0.0
Instances
Foldable ZipList | Since: base-4.9.0.0 |
Defined in Control.Applicative Methods fold :: Monoid m => ZipList m -> m # foldMap :: Monoid m => (a -> m) -> ZipList a -> m # foldMap' :: Monoid m => (a -> m) -> ZipList a -> m # foldr :: (a -> b -> b) -> b -> ZipList a -> b # foldr' :: (a -> b -> b) -> b -> ZipList a -> b # foldl :: (b -> a -> b) -> b -> ZipList a -> b # foldl' :: (b -> a -> b) -> b -> ZipList a -> b # foldr1 :: (a -> a -> a) -> ZipList a -> a # foldl1 :: (a -> a -> a) -> ZipList a -> a # elem :: Eq a => a -> ZipList a -> Bool # maximum :: Ord a => ZipList a -> a # minimum :: Ord a => ZipList a -> a # | |
Foldable First | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldMap' :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # | |
Foldable Last | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldMap' :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # | |
Foldable Down | Since: base-4.12.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Down m -> m # foldMap :: Monoid m => (a -> m) -> Down a -> m # foldMap' :: Monoid m => (a -> m) -> Down a -> m # foldr :: (a -> b -> b) -> b -> Down a -> b # foldr' :: (a -> b -> b) -> b -> Down a -> b # foldl :: (b -> a -> b) -> b -> Down a -> b # foldl' :: (b -> a -> b) -> b -> Down a -> b # foldr1 :: (a -> a -> a) -> Down a -> a # foldl1 :: (a -> a -> a) -> Down a -> a # elem :: Eq a => a -> Down a -> Bool # maximum :: Ord a => Down a -> a # | |
Foldable Dual | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Dual m -> m # foldMap :: Monoid m => (a -> m) -> Dual a -> m # foldMap' :: Monoid m => (a -> m) -> Dual a -> m # foldr :: (a -> b -> b) -> b -> Dual a -> b # foldr' :: (a -> b -> b) -> b -> Dual a -> b # foldl :: (b -> a -> b) -> b -> Dual a -> b # foldl' :: (b -> a -> b) -> b -> Dual a -> b # foldr1 :: (a -> a -> a) -> Dual a -> a # foldl1 :: (a -> a -> a) -> Dual a -> a # elem :: Eq a => a -> Dual a -> Bool # maximum :: Ord a => Dual a -> a # | |
Foldable Product | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Product m -> m # foldMap :: Monoid m => (a -> m) -> Product a -> m # foldMap' :: Monoid m => (a -> m) -> Product a -> m # foldr :: (a -> b -> b) -> b -> Product a -> b # foldr' :: (a -> b -> b) -> b -> Product a -> b # foldl :: (b -> a -> b) -> b -> Product a -> b # foldl' :: (b -> a -> b) -> b -> Product a -> b # foldr1 :: (a -> a -> a) -> Product a -> a # foldl1 :: (a -> a -> a) -> Product a -> a # elem :: Eq a => a -> Product a -> Bool # maximum :: Ord a => Product a -> a # minimum :: Ord a => Product a -> a # | |
Foldable Sum | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Sum m -> m # foldMap :: Monoid m => (a -> m) -> Sum a -> m # foldMap' :: Monoid m => (a -> m) -> Sum a -> m # foldr :: (a -> b -> b) -> b -> Sum a -> b # foldr' :: (a -> b -> b) -> b -> Sum a -> b # foldl :: (b -> a -> b) -> b -> Sum a -> b # foldl' :: (b -> a -> b) -> b -> Sum a -> b # foldr1 :: (a -> a -> a) -> Sum a -> a # foldl1 :: (a -> a -> a) -> Sum a -> a # elem :: Eq a => a -> Sum a -> Bool # maximum :: Ord a => Sum a -> a # | |
Foldable NonEmpty | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => NonEmpty m -> m # foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m # foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m # foldr :: (a -> b -> b) -> b -> NonEmpty a -> b # foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b # foldl :: (b -> a -> b) -> b -> NonEmpty a -> b # foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b # foldr1 :: (a -> a -> a) -> NonEmpty a -> a # foldl1 :: (a -> a -> a) -> NonEmpty a -> a # elem :: Eq a => a -> NonEmpty a -> Bool # maximum :: Ord a => NonEmpty a -> a # minimum :: Ord a => NonEmpty a -> a # | |
Foldable Par1 | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Par1 m -> m # foldMap :: Monoid m => (a -> m) -> Par1 a -> m # foldMap' :: Monoid m => (a -> m) -> Par1 a -> m # foldr :: (a -> b -> b) -> b -> Par1 a -> b # foldr' :: (a -> b -> b) -> b -> Par1 a -> b # foldl :: (b -> a -> b) -> b -> Par1 a -> b # foldl' :: (b -> a -> b) -> b -> Par1 a -> b # foldr1 :: (a -> a -> a) -> Par1 a -> a # foldl1 :: (a -> a -> a) -> Par1 a -> a # elem :: Eq a => a -> Par1 a -> Bool # maximum :: Ord a => Par1 a -> a # | |
Foldable IntMap | Folds in order of increasing key. |
Defined in Data.IntMap.Internal Methods fold :: Monoid m => IntMap m -> m # foldMap :: Monoid m => (a -> m) -> IntMap a -> m # foldMap' :: Monoid m => (a -> m) -> IntMap a -> m # foldr :: (a -> b -> b) -> b -> IntMap a -> b # foldr' :: (a -> b -> b) -> b -> IntMap a -> b # foldl :: (b -> a -> b) -> b -> IntMap a -> b # foldl' :: (b -> a -> b) -> b -> IntMap a -> b # foldr1 :: (a -> a -> a) -> IntMap a -> a # foldl1 :: (a -> a -> a) -> IntMap a -> a # elem :: Eq a => a -> IntMap a -> Bool # maximum :: Ord a => IntMap a -> a # minimum :: Ord a => IntMap a -> a # | |
Foldable Digit | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => Digit m -> m # foldMap :: Monoid m => (a -> m) -> Digit a -> m # foldMap' :: Monoid m => (a -> m) -> Digit a -> m # foldr :: (a -> b -> b) -> b -> Digit a -> b # foldr' :: (a -> b -> b) -> b -> Digit a -> b # foldl :: (b -> a -> b) -> b -> Digit a -> b # foldl' :: (b -> a -> b) -> b -> Digit a -> b # foldr1 :: (a -> a -> a) -> Digit a -> a # foldl1 :: (a -> a -> a) -> Digit a -> a # elem :: Eq a => a -> Digit a -> Bool # maximum :: Ord a => Digit a -> a # minimum :: Ord a => Digit a -> a # | |
Foldable Elem | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => Elem m -> m # foldMap :: Monoid m => (a -> m) -> Elem a -> m # foldMap' :: Monoid m => (a -> m) -> Elem a -> m # foldr :: (a -> b -> b) -> b -> Elem a -> b # foldr' :: (a -> b -> b) -> b -> Elem a -> b # foldl :: (b -> a -> b) -> b -> Elem a -> b # foldl' :: (b -> a -> b) -> b -> Elem a -> b # foldr1 :: (a -> a -> a) -> Elem a -> a # foldl1 :: (a -> a -> a) -> Elem a -> a # elem :: Eq a => a -> Elem a -> Bool # maximum :: Ord a => Elem a -> a # | |
Foldable FingerTree | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => FingerTree m -> m # foldMap :: Monoid m => (a -> m) -> FingerTree a -> m # foldMap' :: Monoid m => (a -> m) -> FingerTree a -> m # foldr :: (a -> b -> b) -> b -> FingerTree a -> b # foldr' :: (a -> b -> b) -> b -> FingerTree a -> b # foldl :: (b -> a -> b) -> b -> FingerTree a -> b # foldl' :: (b -> a -> b) -> b -> FingerTree a -> b # foldr1 :: (a -> a -> a) -> FingerTree a -> a # foldl1 :: (a -> a -> a) -> FingerTree a -> a # toList :: FingerTree a -> [a] # null :: FingerTree a -> Bool # length :: FingerTree a -> Int # elem :: Eq a => a -> FingerTree a -> Bool # maximum :: Ord a => FingerTree a -> a # minimum :: Ord a => FingerTree a -> a # sum :: Num a => FingerTree a -> a # product :: Num a => FingerTree a -> a # | |
Foldable Node | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => Node m -> m # foldMap :: Monoid m => (a -> m) -> Node a -> m # foldMap' :: Monoid m => (a -> m) -> Node a -> m # foldr :: (a -> b -> b) -> b -> Node a -> b # foldr' :: (a -> b -> b) -> b -> Node a -> b # foldl :: (b -> a -> b) -> b -> Node a -> b # foldl' :: (b -> a -> b) -> b -> Node a -> b # foldr1 :: (a -> a -> a) -> Node a -> a # foldl1 :: (a -> a -> a) -> Node a -> a # elem :: Eq a => a -> Node a -> Bool # maximum :: Ord a => Node a -> a # | |
Foldable Seq | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => Seq m -> m # foldMap :: Monoid m => (a -> m) -> Seq a -> m # foldMap' :: Monoid m => (a -> m) -> Seq a -> m # foldr :: (a -> b -> b) -> b -> Seq a -> b # foldr' :: (a -> b -> b) -> b -> Seq a -> b # foldl :: (b -> a -> b) -> b -> Seq a -> b # foldl' :: (b -> a -> b) -> b -> Seq a -> b # foldr1 :: (a -> a -> a) -> Seq a -> a # foldl1 :: (a -> a -> a) -> Seq a -> a # elem :: Eq a => a -> Seq a -> Bool # maximum :: Ord a => Seq a -> a # | |
Foldable ViewL | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => ViewL m -> m # foldMap :: Monoid m => (a -> m) -> ViewL a -> m # foldMap' :: Monoid m => (a -> m) -> ViewL a -> m # foldr :: (a -> b -> b) -> b -> ViewL a -> b # foldr' :: (a -> b -> b) -> b -> ViewL a -> b # foldl :: (b -> a -> b) -> b -> ViewL a -> b # foldl' :: (b -> a -> b) -> b -> ViewL a -> b # foldr1 :: (a -> a -> a) -> ViewL a -> a # foldl1 :: (a -> a -> a) -> ViewL a -> a # elem :: Eq a => a -> ViewL a -> Bool # maximum :: Ord a => ViewL a -> a # minimum :: Ord a => ViewL a -> a # | |
Foldable ViewR | |
Defined in Data.Sequence.Internal Methods fold :: Monoid m => ViewR m -> m # foldMap :: Monoid m => (a -> m) -> ViewR a -> m # foldMap' :: Monoid m => (a -> m) -> ViewR a -> m # foldr :: (a -> b -> b) -> b -> ViewR a -> b # foldr' :: (a -> b -> b) -> b -> ViewR a -> b # foldl :: (b -> a -> b) -> b -> ViewR a -> b # foldl' :: (b -> a -> b) -> b -> ViewR a -> b # foldr1 :: (a -> a -> a) -> ViewR a -> a # foldl1 :: (a -> a -> a) -> ViewR a -> a # elem :: Eq a => a -> ViewR a -> Bool # maximum :: Ord a => ViewR a -> a # minimum :: Ord a => ViewR a -> a # | |
Foldable Set | Folds in order of increasing key. |
Defined in Data.Set.Internal Methods fold :: Monoid m => Set m -> m # foldMap :: Monoid m => (a -> m) -> Set a -> m # foldMap' :: Monoid m => (a -> m) -> Set a -> m # foldr :: (a -> b -> b) -> b -> Set a -> b # foldr' :: (a -> b -> b) -> b -> Set a -> b # foldl :: (b -> a -> b) -> b -> Set a -> b # foldl' :: (b -> a -> b) -> b -> Set a -> b # foldr1 :: (a -> a -> a) -> Set a -> a # foldl1 :: (a -> a -> a) -> Set a -> a # elem :: Eq a => a -> Set a -> Bool # maximum :: Ord a => Set a -> a # | |
Foldable Tree | Folds in preorder |
Defined in Data.Tree Methods fold :: Monoid m => Tree m -> m # foldMap :: Monoid m => (a -> m) -> Tree a -> m # foldMap' :: Monoid m => (a -> m) -> Tree a -> m # foldr :: (a -> b -> b) -> b -> Tree a -> b # foldr' :: (a -> b -> b) -> b -> Tree a -> b # foldl :: (b -> a -> b) -> b -> Tree a -> b # foldl' :: (b -> a -> b) -> b -> Tree a -> b # foldr1 :: (a -> a -> a) -> Tree a -> a # foldl1 :: (a -> a -> a) -> Tree a -> a # elem :: Eq a => a -> Tree a -> Bool # maximum :: Ord a => Tree a -> a # | |
Foldable Array | |
Defined in Data.Primitive.Array Methods fold :: Monoid m => Array m -> m # foldMap :: Monoid m => (a -> m) -> Array a -> m # foldMap' :: Monoid m => (a -> m) -> Array a -> m # foldr :: (a -> b -> b) -> b -> Array a -> b # foldr' :: (a -> b -> b) -> b -> Array a -> b # foldl :: (b -> a -> b) -> b -> Array a -> b # foldl' :: (b -> a -> b) -> b -> Array a -> b # foldr1 :: (a -> a -> a) -> Array a -> a # foldl1 :: (a -> a -> a) -> Array a -> a # elem :: Eq a => a -> Array a -> Bool # maximum :: Ord a => Array a -> a # minimum :: Ord a => Array a -> a # | |
Foldable SmallArray | |
Defined in Data.Primitive.SmallArray Methods fold :: Monoid m => SmallArray m -> m # foldMap :: Monoid m => (a -> m) -> SmallArray a -> m # foldMap' :: Monoid m => (a -> m) -> SmallArray a -> m # foldr :: (a -> b -> b) -> b -> SmallArray a -> b # foldr' :: (a -> b -> b) -> b -> SmallArray a -> b # foldl :: (b -> a -> b) -> b -> SmallArray a -> b # foldl' :: (b -> a -> b) -> b -> SmallArray a -> b # foldr1 :: (a -> a -> a) -> SmallArray a -> a # foldl1 :: (a -> a -> a) -> SmallArray a -> a # toList :: SmallArray a -> [a] # null :: SmallArray a -> Bool # length :: SmallArray a -> Int # elem :: Eq a => a -> SmallArray a -> Bool # maximum :: Ord a => SmallArray a -> a # minimum :: Ord a => SmallArray a -> a # sum :: Num a => SmallArray a -> a # product :: Num a => SmallArray a -> a # | |
Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable Methods fold :: Monoid m => Maybe m -> m # foldMap :: Monoid m => (a -> m) -> Maybe a -> m # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m # foldr :: (a -> b -> b) -> b -> Maybe a -> b # foldr' :: (a -> b -> b) -> b -> Maybe a -> b # foldl :: (b -> a -> b) -> b -> Maybe a -> b # foldl' :: (b -> a -> b) -> b -> Maybe a -> b # foldr1 :: (a -> a -> a) -> Maybe a -> a # foldl1 :: (a -> a -> a) -> Maybe a -> a # elem :: Eq a => a -> Maybe a -> Bool # maximum :: Ord a => Maybe a -> a # minimum :: Ord a => Maybe a -> a # | |
Foldable Solo | Since: base-4.15 |
Defined in Data.Foldable Methods fold :: Monoid m => Solo m -> m # foldMap :: Monoid m => (a -> m) -> Solo a -> m # foldMap' :: Monoid m => (a -> m) -> Solo a -> m # foldr :: (a -> b -> b) -> b -> Solo a -> b # foldr' :: (a -> b -> b) -> b -> Solo a -> b # foldl :: (b -> a -> b) -> b -> Solo a -> b # foldl' :: (b -> a -> b) -> b -> Solo a -> b # foldr1 :: (a -> a -> a) -> Solo a -> a # foldl1 :: (a -> a -> a) -> Solo a -> a # elem :: Eq a => a -> Solo a -> Bool # maximum :: Ord a => Solo a -> a # | |
Foldable List | Since: base-2.1 |
Defined in Data.Foldable Methods fold :: Monoid m => [m] -> m # foldMap :: Monoid m => (a -> m) -> [a] -> m # foldMap' :: Monoid m => (a -> m) -> [a] -> m # foldr :: (a -> b -> b) -> b -> [a] -> b # foldr' :: (a -> b -> b) -> b -> [a] -> b # foldl :: (b -> a -> b) -> b -> [a] -> b # foldl' :: (b -> a -> b) -> b -> [a] -> b # foldr1 :: (a -> a -> a) -> [a] -> a # foldl1 :: (a -> a -> a) -> [a] -> a # elem :: Eq a => a -> [a] -> Bool # maximum :: Ord a => [a] -> a # | |
Foldable (Either a) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Either a m -> m # foldMap :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Either a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Either a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Either a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Either a a0 -> a0 # toList :: Either a a0 -> [a0] # length :: Either a a0 -> Int # elem :: Eq a0 => a0 -> Either a a0 -> Bool # maximum :: Ord a0 => Either a a0 -> a0 # minimum :: Ord a0 => Either a a0 -> a0 # | |
Foldable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # | |
Foldable (Array i) | Since: base-4.8.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Array i m -> m # foldMap :: Monoid m => (a -> m) -> Array i a -> m # foldMap' :: Monoid m => (a -> m) -> Array i a -> m # foldr :: (a -> b -> b) -> b -> Array i a -> b # foldr' :: (a -> b -> b) -> b -> Array i a -> b # foldl :: (b -> a -> b) -> b -> Array i a -> b # foldl' :: (b -> a -> b) -> b -> Array i a -> b # foldr1 :: (a -> a -> a) -> Array i a -> a # foldl1 :: (a -> a -> a) -> Array i a -> a # elem :: Eq a => a -> Array i a -> Bool # maximum :: Ord a => Array i a -> a # minimum :: Ord a => Array i a -> a # | |
Foldable (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => U1 m -> m # foldMap :: Monoid m => (a -> m) -> U1 a -> m # foldMap' :: Monoid m => (a -> m) -> U1 a -> m # foldr :: (a -> b -> b) -> b -> U1 a -> b # foldr' :: (a -> b -> b) -> b -> U1 a -> b # foldl :: (b -> a -> b) -> b -> U1 a -> b # foldl' :: (b -> a -> b) -> b -> U1 a -> b # foldr1 :: (a -> a -> a) -> U1 a -> a # foldl1 :: (a -> a -> a) -> U1 a -> a # elem :: Eq a => a -> U1 a -> Bool # maximum :: Ord a => U1 a -> a # | |
Foldable (UAddr :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => UAddr m -> m # foldMap :: Monoid m => (a -> m) -> UAddr a -> m # foldMap' :: Monoid m => (a -> m) -> UAddr a -> m # foldr :: (a -> b -> b) -> b -> UAddr a -> b # foldr' :: (a -> b -> b) -> b -> UAddr a -> b # foldl :: (b -> a -> b) -> b -> UAddr a -> b # foldl' :: (b -> a -> b) -> b -> UAddr a -> b # foldr1 :: (a -> a -> a) -> UAddr a -> a # foldl1 :: (a -> a -> a) -> UAddr a -> a # elem :: Eq a => a -> UAddr a -> Bool # maximum :: Ord a => UAddr a -> a # minimum :: Ord a => UAddr a -> a # | |
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 # | |
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 # | |
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 # | |
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 # | |
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 # | |
Foldable (V1 :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => V1 m -> m # foldMap :: Monoid m => (a -> m) -> V1 a -> m # foldMap' :: Monoid m => (a -> m) -> V1 a -> m # foldr :: (a -> b -> b) -> b -> V1 a -> b # foldr' :: (a -> b -> b) -> b -> V1 a -> b # foldl :: (b -> a -> b) -> b -> V1 a -> b # foldl' :: (b -> a -> b) -> b -> V1 a -> b # foldr1 :: (a -> a -> a) -> V1 a -> a # foldl1 :: (a -> a -> a) -> V1 a -> a # elem :: Eq a => a -> V1 a -> Bool # maximum :: Ord a => V1 a -> a # | |
Foldable (Map k) | Folds in order of increasing key. |
Defined in Data.Map.Internal Methods fold :: Monoid m => Map k m -> m # foldMap :: Monoid m => (a -> m) -> Map k a -> m # foldMap' :: Monoid m => (a -> m) -> Map k a -> m # foldr :: (a -> b -> b) -> b -> Map k a -> b # foldr' :: (a -> b -> b) -> b -> Map k a -> b # foldl :: (b -> a -> b) -> b -> Map k a -> b # foldl' :: (b -> a -> b) -> b -> Map k a -> b # foldr1 :: (a -> a -> a) -> Map k a -> a # foldl1 :: (a -> a -> a) -> Map k a -> a # elem :: Eq a => a -> Map k a -> Bool # maximum :: Ord a => Map k a -> a # minimum :: Ord a => Map k a -> a # | |
Foldable ((,) a) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => (a, m) -> m # foldMap :: Monoid m => (a0 -> m) -> (a, a0) -> m # foldMap' :: Monoid m => (a0 -> m) -> (a, a0) -> m # foldr :: (a0 -> b -> b) -> b -> (a, a0) -> b # foldr' :: (a0 -> b -> b) -> b -> (a, a0) -> b # foldl :: (b -> a0 -> b) -> b -> (a, a0) -> b # foldl' :: (b -> a0 -> b) -> b -> (a, a0) -> b # foldr1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 # foldl1 :: (a0 -> a0 -> a0) -> (a, a0) -> a0 # elem :: Eq a0 => a0 -> (a, a0) -> Bool # maximum :: Ord a0 => (a, a0) -> a0 # minimum :: Ord a0 => (a, a0) -> a0 # | |
Foldable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Functor.Const Methods fold :: Monoid m0 => Const m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldr :: (a -> b -> b) -> b -> Const m a -> b # foldr' :: (a -> b -> b) -> b -> Const m a -> b # foldl :: (b -> a -> b) -> b -> Const m a -> b # foldl' :: (b -> a -> b) -> b -> Const m a -> b # foldr1 :: (a -> a -> a) -> Const m a -> a # foldl1 :: (a -> a -> a) -> Const m a -> a # elem :: Eq a => a -> Const m a -> Bool # maximum :: Ord a => Const m a -> a # minimum :: Ord a => Const m a -> a # | |
Foldable f => Foldable (Ap f) | Since: base-4.12.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Ap f m -> m # foldMap :: Monoid m => (a -> m) -> Ap f a -> m # foldMap' :: Monoid m => (a -> m) -> Ap f a -> m # foldr :: (a -> b -> b) -> b -> Ap f a -> b # foldr' :: (a -> b -> b) -> b -> Ap f a -> b # foldl :: (b -> a -> b) -> b -> Ap f a -> b # foldl' :: (b -> a -> b) -> b -> Ap f a -> b # foldr1 :: (a -> a -> a) -> Ap f a -> a # foldl1 :: (a -> a -> a) -> Ap f a -> a # elem :: Eq a => a -> Ap f a -> Bool # maximum :: Ord a => Ap f a -> a # | |
Foldable f => Foldable (Alt f) | Since: base-4.12.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Alt f m -> m # foldMap :: Monoid m => (a -> m) -> Alt f a -> m # foldMap' :: Monoid m => (a -> m) -> Alt f a -> m # foldr :: (a -> b -> b) -> b -> Alt f a -> b # foldr' :: (a -> b -> b) -> b -> Alt f a -> b # foldl :: (b -> a -> b) -> b -> Alt f a -> b # foldl' :: (b -> a -> b) -> b -> Alt f a -> b # foldr1 :: (a -> a -> a) -> Alt f a -> a # foldl1 :: (a -> a -> a) -> Alt f a -> a # elem :: Eq a => a -> Alt f a -> Bool # maximum :: Ord a => Alt f a -> a # minimum :: Ord a => Alt f a -> a # | |
Foldable f => Foldable (Rec1 f) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Rec1 f m -> m # foldMap :: Monoid m => (a -> m) -> Rec1 f a -> m # foldMap' :: Monoid m => (a -> m) -> Rec1 f a -> m # foldr :: (a -> b -> b) -> b -> Rec1 f a -> b # foldr' :: (a -> b -> b) -> b -> Rec1 f a -> b # foldl :: (b -> a -> b) -> b -> Rec1 f a -> b # foldl' :: (b -> a -> b) -> b -> Rec1 f a -> b # foldr1 :: (a -> a -> a) -> Rec1 f a -> a # foldl1 :: (a -> a -> a) -> Rec1 f a -> a # elem :: Eq a => a -> Rec1 f a -> Bool # maximum :: Ord a => Rec1 f a -> a # minimum :: Ord a => Rec1 f a -> a # | |
Foldable (Constant a :: Type -> Type) | |
Defined in Data.Functor.Constant Methods fold :: Monoid m => Constant a m -> m # foldMap :: Monoid m => (a0 -> m) -> Constant a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Constant a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Constant a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Constant a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Constant a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Constant a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Constant a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Constant a a0 -> a0 # toList :: Constant a a0 -> [a0] # null :: Constant a a0 -> Bool # length :: Constant a a0 -> Int # elem :: Eq a0 => a0 -> Constant a a0 -> Bool # maximum :: Ord a0 => Constant a a0 -> a0 # minimum :: Ord a0 => Constant a a0 -> a0 # | |
(Foldable f, Foldable g) => Foldable (f :*: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => (f :*: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :*: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :*: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :*: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :*: g) a -> b # foldr1 :: (a -> a -> a) -> (f :*: g) a -> a # foldl1 :: (a -> a -> a) -> (f :*: g) a -> a # toList :: (f :*: g) a -> [a] # length :: (f :*: g) a -> Int # elem :: Eq a => a -> (f :*: g) a -> Bool # maximum :: Ord a => (f :*: g) a -> a # minimum :: Ord a => (f :*: g) a -> a # | |
(Foldable f, Foldable g) => Foldable (f :+: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => (f :+: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :+: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :+: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :+: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :+: g) a -> b # foldr1 :: (a -> a -> a) -> (f :+: g) a -> a # foldl1 :: (a -> a -> a) -> (f :+: g) a -> a # toList :: (f :+: g) a -> [a] # length :: (f :+: g) a -> Int # elem :: Eq a => a -> (f :+: g) a -> Bool # maximum :: Ord a => (f :+: g) a -> a # minimum :: Ord a => (f :+: g) a -> a # | |
Foldable (K1 i c :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => K1 i c m -> m # foldMap :: Monoid m => (a -> m) -> K1 i c a -> m # foldMap' :: Monoid m => (a -> m) -> K1 i c a -> m # foldr :: (a -> b -> b) -> b -> K1 i c a -> b # foldr' :: (a -> b -> b) -> b -> K1 i c a -> b # foldl :: (b -> a -> b) -> b -> K1 i c a -> b # foldl' :: (b -> a -> b) -> b -> K1 i c a -> b # foldr1 :: (a -> a -> a) -> K1 i c a -> a # foldl1 :: (a -> a -> a) -> K1 i c a -> a # elem :: Eq a => a -> K1 i c a -> Bool # maximum :: Ord a => K1 i c a -> a # minimum :: Ord a => K1 i c a -> a # | |
(Foldable f, Foldable g) => Foldable (f :.: g) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => (f :.: g) m -> m # foldMap :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldMap' :: Monoid m => (a -> m) -> (f :.: g) a -> m # foldr :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldr' :: (a -> b -> b) -> b -> (f :.: g) a -> b # foldl :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldl' :: (b -> a -> b) -> b -> (f :.: g) a -> b # foldr1 :: (a -> a -> a) -> (f :.: g) a -> a # foldl1 :: (a -> a -> a) -> (f :.: g) a -> a # toList :: (f :.: g) a -> [a] # length :: (f :.: g) a -> Int # elem :: Eq a => a -> (f :.: g) a -> Bool # maximum :: Ord a => (f :.: g) a -> a # minimum :: Ord a => (f :.: g) a -> a # | |
Foldable f => Foldable (M1 i c f) | Since: base-4.9.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => M1 i c f m -> m # foldMap :: Monoid m => (a -> m) -> M1 i c f a -> m # foldMap' :: Monoid m => (a -> m) -> M1 i c f a -> m # foldr :: (a -> b -> b) -> b -> M1 i c f a -> b # foldr' :: (a -> b -> b) -> b -> M1 i c f a -> b # foldl :: (b -> a -> b) -> b -> M1 i c f a -> b # foldl' :: (b -> a -> b) -> b -> M1 i c f a -> b # foldr1 :: (a -> a -> a) -> M1 i c f a -> a # foldl1 :: (a -> a -> a) -> M1 i c f a -> a # elem :: Eq a => a -> M1 i c f a -> Bool # maximum :: Ord a => M1 i c f a -> a # minimum :: Ord a => M1 i c f a -> a # |
class (Functor t, Foldable t) => Traversable (t :: Type -> Type) where #
Functors representing data structures that can be transformed to
structures of the same shape by performing an Applicative
(or,
therefore, Monad
) action on each element from left to right.
A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable.
For the class laws see the Laws section of Data.Traversable.
Methods
traverse :: Applicative f => (a -> f b) -> t a -> f (t b) #
Map each element of a structure to an action, evaluate these actions
from left to right, and collect the results. For a version that ignores
the results see traverse_
.
Examples
Basic usage:
In the first two examples we show each evaluated action mapping to the output structure.
>>>
traverse Just [1,2,3,4]
Just [1,2,3,4]
>>>
traverse id [Right 1, Right 2, Right 3, Right 4]
Right [1,2,3,4]
In the next examples, we show that Nothing
and Left
values short
circuit the created structure.
>>>
traverse (const Nothing) [1,2,3,4]
Nothing
>>>
traverse (\x -> if odd x then Just x else Nothing) [1,2,3,4]
Nothing
>>>
traverse id [Right 1, Right 2, Right 3, Right 4, Left 0]
Left 0
sequenceA :: Applicative f => t (f a) -> f (t a) #
Evaluate each action in the structure from left to right, and
collect the results. For a version that ignores the results
see sequenceA_
.
Examples
Basic usage:
For the first two examples we show sequenceA fully evaluating a a structure and collecting the results.
>>>
sequenceA [Just 1, Just 2, Just 3]
Just [1,2,3]
>>>
sequenceA [Right 1, Right 2, Right 3]
Right [1,2,3]
The next two example show Nothing
and Just
will short circuit
the resulting structure if present in the input. For more context,
check the Traversable
instances for Either
and Maybe
.
>>>
sequenceA [Just 1, Just 2, Just 3, Nothing]
Nothing
>>>
sequenceA [Right 1, Right 2, Right 3, Left 4]
Left 4
mapM :: Monad m => (a -> m b) -> t a -> m (t b) #
Map each element of a structure to a monadic action, evaluate
these actions from left to right, and collect the results. For
a version that ignores the results see mapM_
.
Examples
sequence :: Monad m => t (m a) -> m (t a) #
Evaluate each monadic action in the structure from left to
right, and collect the results. For a version that ignores the
results see sequence_
.
Examples
Basic usage:
The first two examples are instances where the input and
and output of sequence
are isomorphic.
>>>
sequence $ Right [1,2,3,4]
[Right 1,Right 2,Right 3,Right 4]
>>>
sequence $ [Right 1,Right 2,Right 3,Right 4]
Right [1,2,3,4]
The following examples demonstrate short circuit behavior
for sequence
.
>>>
sequence $ Left [1,2,3,4]
Left [1,2,3,4]
>>>
sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]
Left 0
Instances
Traversable ZipList | Since: base-4.9.0.0 |
Traversable Identity | Since: base-4.9.0.0 |
Traversable First | Since: base-4.8.0.0 |
Traversable Last | Since: base-4.8.0.0 |
Traversable Down | Since: base-4.12.0.0 |
Traversable Dual | Since: base-4.8.0.0 |
Traversable Product | Since: base-4.8.0.0 |
Traversable Sum | Since: base-4.8.0.0 |
Traversable NonEmpty | Since: base-4.9.0.0 |
Traversable Par1 | Since: base-4.9.0.0 |
Traversable IntMap | Traverses in order of increasing key. |
Traversable Digit | |
Traversable Elem | |
Traversable FingerTree | |
Defined in Data.Sequence.Internal Methods traverse :: Applicative f => (a -> f b) -> FingerTree a -> f (FingerTree b) # sequenceA :: Applicative f => FingerTree (f a) -> f (FingerTree a) # mapM :: Monad m => (a -> m b) -> FingerTree a -> m (FingerTree b) # sequence :: Monad m => FingerTree (m a) -> m (FingerTree a) # | |
Traversable Node | |
Traversable Seq | |
Traversable ViewL | |
Traversable ViewR | |
Traversable Tree | |
Traversable Array | |
Traversable SmallArray | |
Defined in Data.Primitive.SmallArray Methods traverse :: Applicative f => (a -> f b) -> SmallArray a -> f (SmallArray b) # sequenceA :: Applicative f => SmallArray (f a) -> f (SmallArray a) # mapM :: Monad m => (a -> m b) -> SmallArray a -> m (SmallArray b) # sequence :: Monad m => SmallArray (m a) -> m (SmallArray a) # | |
Traversable Maybe | Since: base-2.1 |
Traversable Solo | Since: base-4.15 |
Traversable List | Since: base-2.1 |
Defined in Data.Traversable | |
Traversable (Either a) | Since: base-4.7.0.0 |
Defined in Data.Traversable | |
Traversable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Ix i => Traversable (Array i) | Since: base-2.1 |
Traversable (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Traversable (UAddr :: Type -> Type) | Since: base-4.9.0.0 |
Traversable (UChar :: Type -> Type) | Since: base-4.9.0.0 |
Traversable (UDouble :: Type -> Type) | Since: base-4.9.0.0 |
Traversable (UFloat :: Type -> Type) | Since: base-4.9.0.0 |
Traversable (UInt :: Type -> Type) | Since: base-4.9.0.0 |
Traversable (UWord :: Type -> Type) | Since: base-4.9.0.0 |
Traversable (V1 :: Type -> Type) | Since: base-4.9.0.0 |
Traversable (Map k) | Traverses in order of increasing key. |
Traversable ((,) a) | Since: base-4.7.0.0 |
Defined in Data.Traversable | |
Traversable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
Traversable f => Traversable (Ap f) | Since: base-4.12.0.0 |
Traversable f => Traversable (Alt f) | Since: base-4.12.0.0 |
Traversable f => Traversable (Rec1 f) | Since: base-4.9.0.0 |
Traversable (Constant a :: Type -> Type) | |
Defined in Data.Functor.Constant | |
(Traversable f, Traversable g) => Traversable (f :*: g) | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
(Traversable f, Traversable g) => Traversable (f :+: g) | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
Traversable (K1 i c :: Type -> Type) | Since: base-4.9.0.0 |
(Traversable f, Traversable g) => Traversable (f :.: g) | Since: base-4.9.0.0 |
Defined in Data.Traversable | |
Traversable f => Traversable (M1 i c f) | Since: base-4.9.0.0 |
type HasCallStack = ?callStack :: CallStack #
Request a CallStack.
NOTE: The implicit parameter ?callStack :: CallStack
is an
implementation detail and should not be considered part of the
CallStack
API, we may decide to change the implementation in the
future.
Since: base-4.9.0.0
class Applicative f => Alternative (f :: Type -> Type) where #
A monoid on applicative functors.
If defined, some
and many
should be the least solutions
of the equations:
Methods
The identity of <|>
(<|>) :: f a -> f a -> f a infixl 3 #
An associative binary operation
One or more.
Zero or more.
Instances
Alternative ZipList | Since: base-4.11.0.0 |
Alternative P | Since: base-4.5.0.0 |
Alternative ReadP | Since: base-4.6.0.0 |
Alternative Seq | Since: containers-0.5.4 |
Alternative IO | Takes the first non-throwing Since: base-4.9.0.0 |
Alternative Array | |
Alternative SmallArray | |
Defined in Data.Primitive.SmallArray Methods empty :: SmallArray a # (<|>) :: SmallArray a -> SmallArray a -> SmallArray a # some :: SmallArray a -> SmallArray [a] # many :: SmallArray a -> SmallArray [a] # | |
Alternative Maybe | Picks the leftmost Since: base-2.1 |
Alternative List | Combines lists by concatenation, starting from the empty list. Since: base-2.1 |
MonadPlus m => Alternative (WrappedMonad m) | Since: base-2.1 |
Defined in Control.Applicative Methods empty :: WrappedMonad m a # (<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a # some :: WrappedMonad m a -> WrappedMonad m [a] # many :: WrappedMonad m a -> WrappedMonad m [a] # | |
Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Alternative (U1 :: Type -> Type) | Since: base-4.9.0.0 |
(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods empty :: WrappedArrow a b a0 # (<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 # some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] # many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] # | |
(Generic1 f, Alternative (Rep1 f)) => Alternative (Generically1 f) | Since: base-4.17.0.0 |
Defined in GHC.Generics Methods empty :: Generically1 f a # (<|>) :: Generically1 f a -> Generically1 f a -> Generically1 f a # some :: Generically1 f a -> Generically1 f [a] # many :: Generically1 f a -> Generically1 f [a] # | |
Alternative f => Alternative (Rec1 f) | Since: base-4.9.0.0 |
(Alternative f, Alternative g) => Alternative (f :*: g) | Since: base-4.9.0.0 |
(Alternative f, Applicative g) => Alternative (f :.: g) | Since: base-4.9.0.0 |
Alternative f => Alternative (M1 i c f) | Since: base-4.9.0.0 |
class Bits b => FiniteBits b where #
The FiniteBits
class denotes types with a finite, fixed number of bits.
Since: base-4.7.0.0
Minimal complete definition
Methods
finiteBitSize :: b -> Int #
Return the number of bits in the type of the argument.
The actual value of the argument is ignored. Moreover, finiteBitSize
is total, in contrast to the deprecated bitSize
function it replaces.
finiteBitSize
=bitSize
bitSizeMaybe
=Just
.finiteBitSize
Since: base-4.7.0.0
countLeadingZeros :: b -> Int #
Count number of zero bits preceding the most significant set bit.
countLeadingZeros
(zeroBits
:: a) = finiteBitSize (zeroBits
:: a)
countLeadingZeros
can be used to compute log base 2 via
logBase2 x =finiteBitSize
x - 1 -countLeadingZeros
x
Note: The default implementation for this method is intentionally naive. However, the instances provided for the primitive integral types are implemented using CPU specific machine instructions.
Since: base-4.8.0.0
countTrailingZeros :: b -> Int #
Count number of zero bits following the least significant set bit.
countTrailingZeros
(zeroBits
:: a) = finiteBitSize (zeroBits
:: a)countTrailingZeros
.negate
=countTrailingZeros
The related
find-first-set operation
can be expressed in terms of countTrailingZeros
as follows
findFirstSet x = 1 + countTrailingZeros
x
Note: The default implementation for this method is intentionally naive. However, the instances provided for the primitive integral types are implemented using CPU specific machine instructions.
Since: base-4.8.0.0
Instances
The Bits
class defines bitwise operations over integral types.
- Bits are numbered from 0 with bit 0 being the least significant bit.
Minimal complete definition
(.&.), (.|.), xor, complement, (shift | shiftL, shiftR), (rotate | rotateL, rotateR), bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount
Methods
(.|.) :: a -> a -> a infixl 5 #
Bitwise "or"
Bitwise "xor"
complement :: a -> a #
Reverse all the bits in the argument
shift :: a -> Int -> a infixl 8 #
shifts shift
x ix
left by i
bits if i
is positive,
or right by -i
bits otherwise.
Right shifts perform sign extension on signed number types;
i.e. they fill the top bits with 1 if the x
is negative
and with 0 otherwise.
An instance can define either this unified shift
or shiftL
and
shiftR
, depending on which is more convenient for the type in
question.
rotate :: a -> Int -> a infixl 8 #
rotates rotate
x ix
left by i
bits if i
is positive,
or right by -i
bits otherwise.
For unbounded types like Integer
, rotate
is equivalent to shift
.
An instance can define either this unified rotate
or rotateL
and
rotateR
, depending on which is more convenient for the type in
question.
zeroBits
is the value with all bits unset.
The following laws ought to hold (for all valid bit indices n
):
clearBit
zeroBits
n ==zeroBits
setBit
zeroBits
n ==bit
ntestBit
zeroBits
n == FalsepopCount
zeroBits
== 0
This method uses
as its default
implementation (which ought to be equivalent to clearBit
(bit
0) 0zeroBits
for
types which possess a 0th bit).
Since: base-4.7.0.0
bit i
is a value with the i
th bit set and all other bits clear.
Can be implemented using bitDefault
if a
is also an
instance of Num
.
See also zeroBits
.
x `setBit` i
is the same as x .|. bit i
x `clearBit` i
is the same as x .&. complement (bit i)
complementBit :: a -> Int -> a #
x `complementBit` i
is the same as x `xor` bit i
x `testBit` i
is the same as x .&. bit n /= 0
In other words it returns True if the bit at offset @n is set.
Can be implemented using testBitDefault
if a
is also an
instance of Num
.
bitSizeMaybe :: a -> Maybe Int #
Return the number of bits in the type of the argument. The actual
value of the argument is ignored. Returns Nothing
for types that do not have a fixed bitsize, like Integer
.
Since: base-4.7.0.0
Return the number of bits in the type of the argument. The actual
value of the argument is ignored. The function bitSize
is
undefined for types that do not have a fixed bitsize, like Integer
.
Default implementation based upon bitSizeMaybe
provided since
4.12.0.0.
Return True
if the argument is a signed type. The actual
value of the argument is ignored
shiftL :: a -> Int -> a infixl 8 #
Shift the argument left by the specified number of bits
(which must be non-negative). Some instances may throw an
Overflow
exception if given a negative input.
An instance can define either this and shiftR
or the unified
shift
, depending on which is more convenient for the type in
question.
unsafeShiftL :: a -> Int -> a #
Shift the argument left by the specified number of bits. The
result is undefined for negative shift amounts and shift amounts
greater or equal to the bitSize
.
Defaults to shiftL
unless defined explicitly by an instance.
Since: base-4.5.0.0
shiftR :: a -> Int -> a infixl 8 #
Shift the first argument right by the specified number of bits. The
result is undefined for negative shift amounts and shift amounts
greater or equal to the bitSize
. Some instances may throw an
Overflow
exception if given a negative input.
Right shifts perform sign extension on signed number types;
i.e. they fill the top bits with 1 if the x
is negative
and with 0 otherwise.
An instance can define either this and shiftL
or the unified
shift
, depending on which is more convenient for the type in
question.
unsafeShiftR :: a -> Int -> a #
Shift the first argument right by the specified number of bits, which must be non-negative and smaller than the number of bits in the type.
Right shifts perform sign extension on signed number types;
i.e. they fill the top bits with 1 if the x
is negative
and with 0 otherwise.
Defaults to shiftR
unless defined explicitly by an instance.
Since: base-4.5.0.0
rotateL :: a -> Int -> a infixl 8 #
Rotate the argument left by the specified number of bits (which must be non-negative).
An instance can define either this and rotateR
or the unified
rotate
, depending on which is more convenient for the type in
question.
rotateR :: a -> Int -> a infixl 8 #
Rotate the argument right by the specified number of bits (which must be non-negative).
An instance can define either this and rotateL
or the unified
rotate
, depending on which is more convenient for the type in
question.
Return the number of set bits in the argument. This number is known as the population count or the Hamming weight.
Can be implemented using popCountDefault
if a
is also an
instance of Num
.
Since: base-4.5.0.0
Instances
class (IsString fmt, Show fmt, Encodable fmt) => Format fmt where #
Instances
Format ByteString | |
Defined in Raaz.Core.Encode.Internal | |
Format Base16 | |
Defined in Raaz.Core.Encode.Base16 | |
Format Base64 | |
Defined in Raaz.Core.Encode.Base64 |
Monoid under bitwise 'equality'; defined as 1
if the corresponding
bits match, and 0
otherwise.
>>>
getIff (Iff 0xab <> Iff 0x12) :: Word8
70
Since: base-4.16
Instances
FiniteBits a => Monoid (Iff a) | This constraint is arguably
too strong. However, as some types (such as Since: base-4.16 |
FiniteBits a => Semigroup (Iff a) | This constraint is arguably
too strong. However, as some types (such as Since: base-4.16 |
Bits a => Bits (Iff a) | Since: base-4.16 |
Defined in Data.Bits Methods (.&.) :: Iff a -> Iff a -> Iff a # (.|.) :: Iff a -> Iff a -> Iff a # xor :: Iff a -> Iff a -> Iff a # complement :: Iff a -> Iff a # shift :: Iff a -> Int -> Iff a # rotate :: Iff a -> Int -> Iff a # setBit :: Iff a -> Int -> Iff a # clearBit :: Iff a -> Int -> Iff a # complementBit :: Iff a -> Int -> Iff a # testBit :: Iff a -> Int -> Bool # bitSizeMaybe :: Iff a -> Maybe Int # shiftL :: Iff a -> Int -> Iff a # unsafeShiftL :: Iff a -> Int -> Iff a # shiftR :: Iff a -> Int -> Iff a # unsafeShiftR :: Iff a -> Int -> Iff a # rotateL :: Iff a -> Int -> Iff a # | |
FiniteBits a => FiniteBits (Iff a) | Since: base-4.16 |
Defined in Data.Bits Methods finiteBitSize :: Iff a -> Int # countLeadingZeros :: Iff a -> Int # countTrailingZeros :: Iff a -> Int # | |
Bounded a => Bounded (Iff a) | Since: base-4.16 |
Enum a => Enum (Iff a) | Since: base-4.16 |
Read a => Read (Iff a) | Since: base-4.16 |
Show a => Show (Iff a) | Since: base-4.16 |
Eq a => Eq (Iff a) | Since: base-4.16 |
Monoid under bitwise XOR.
>>>
getXor (Xor 0xab <> Xor 0x12) :: Word8
185
Since: base-4.16
Instances
Bits a => Monoid (Xor a) | Since: base-4.16 |
Bits a => Semigroup (Xor a) | Since: base-4.16 |
Bits a => Bits (Xor a) | Since: base-4.16 |
Defined in Data.Bits Methods (.&.) :: Xor a -> Xor a -> Xor a # (.|.) :: Xor a -> Xor a -> Xor a # xor :: Xor a -> Xor a -> Xor a # complement :: Xor a -> Xor a # shift :: Xor a -> Int -> Xor a # rotate :: Xor a -> Int -> Xor a # setBit :: Xor a -> Int -> Xor a # clearBit :: Xor a -> Int -> Xor a # complementBit :: Xor a -> Int -> Xor a # testBit :: Xor a -> Int -> Bool # bitSizeMaybe :: Xor a -> Maybe Int # shiftL :: Xor a -> Int -> Xor a # unsafeShiftL :: Xor a -> Int -> Xor a # shiftR :: Xor a -> Int -> Xor a # unsafeShiftR :: Xor a -> Int -> Xor a # rotateL :: Xor a -> Int -> Xor a # | |
FiniteBits a => FiniteBits (Xor a) | Since: base-4.16 |
Defined in Data.Bits Methods finiteBitSize :: Xor a -> Int # countLeadingZeros :: Xor a -> Int # countTrailingZeros :: Xor a -> Int # | |
Bounded a => Bounded (Xor a) | Since: base-4.16 |
Enum a => Enum (Xor a) | Since: base-4.16 |
Read a => Read (Xor a) | Since: base-4.16 |
Show a => Show (Xor a) | Since: base-4.16 |
Eq a => Eq (Xor a) | Since: base-4.16 |
Monoid under bitwise inclusive OR.
>>>
getIor (Ior 0xab <> Ior 0x12) :: Word8
187
Since: base-4.16
Instances
Bits a => Monoid (Ior a) | Since: base-4.16 |
Bits a => Semigroup (Ior a) | Since: base-4.16 |
Bits a => Bits (Ior a) | Since: base-4.16 |
Defined in Data.Bits Methods (.&.) :: Ior a -> Ior a -> Ior a # (.|.) :: Ior a -> Ior a -> Ior a # xor :: Ior a -> Ior a -> Ior a # complement :: Ior a -> Ior a # shift :: Ior a -> Int -> Ior a # rotate :: Ior a -> Int -> Ior a # setBit :: Ior a -> Int -> Ior a # clearBit :: Ior a -> Int -> Ior a # complementBit :: Ior a -> Int -> Ior a # testBit :: Ior a -> Int -> Bool # bitSizeMaybe :: Ior a -> Maybe Int # shiftL :: Ior a -> Int -> Ior a # unsafeShiftL :: Ior a -> Int -> Ior a # shiftR :: Ior a -> Int -> Ior a # unsafeShiftR :: Ior a -> Int -> Ior a # rotateL :: Ior a -> Int -> Ior a # | |
FiniteBits a => FiniteBits (Ior a) | Since: base-4.16 |
Defined in Data.Bits Methods finiteBitSize :: Ior a -> Int # countLeadingZeros :: Ior a -> Int # countTrailingZeros :: Ior a -> Int # | |
Bounded a => Bounded (Ior a) | Since: base-4.16 |
Enum a => Enum (Ior a) | Since: base-4.16 |
Read a => Read (Ior a) | Since: base-4.16 |
Show a => Show (Ior a) | Since: base-4.16 |
Eq a => Eq (Ior a) | Since: base-4.16 |
Monoid under bitwise AND.
>>>
getAnd (And 0xab <> And 0x12) :: Word8
2
Since: base-4.16
Instances
FiniteBits a => Monoid (And a) | This constraint is arguably too strong. However,
as some types (such as Since: base-4.16 |
Bits a => Semigroup (And a) | Since: base-4.16 |
Bits a => Bits (And a) | Since: base-4.16 |
Defined in Data.Bits Methods (.&.) :: And a -> And a -> And a # (.|.) :: And a -> And a -> And a # xor :: And a -> And a -> And a # complement :: And a -> And a # shift :: And a -> Int -> And a # rotate :: And a -> Int -> And a # setBit :: And a -> Int -> And a # clearBit :: And a -> Int -> And a # complementBit :: And a -> Int -> And a # testBit :: And a -> Int -> Bool # bitSizeMaybe :: And a -> Maybe Int # shiftL :: And a -> Int -> And a # unsafeShiftL :: And a -> Int -> And a # shiftR :: And a -> Int -> And a # unsafeShiftR :: And a -> Int -> And a # rotateL :: And a -> Int -> And a # | |
FiniteBits a => FiniteBits (And a) | Since: base-4.16 |
Defined in Data.Bits Methods finiteBitSize :: And a -> Int # countLeadingZeros :: And a -> Int # countTrailingZeros :: And a -> Int # | |
Bounded a => Bounded (And a) | Since: base-4.16 |
Enum a => Enum (And a) | Since: base-4.16 |
Read a => Read (And a) | Since: base-4.16 |
Show a => Show (And a) | Since: base-4.16 |
Eq a => Eq (And a) | Since: base-4.16 |
A concrete, promotable proxy type, for use at the kind level. There are no instances for this because it is intended at the kind level only
Constructors
KProxy |
Proxy
is a type that holds no data, but has a phantom parameter of
arbitrary type (or even kind). Its use is to provide type information, even
though there is no value available of that type (or it may be too costly to
create one).
Historically,
is a safer alternative to the
Proxy
:: Proxy
a
idiom.undefined
:: a
>>>
Proxy :: Proxy (Void, Int -> Int)
Proxy
Proxy can even hold types of higher kinds,
>>>
Proxy :: Proxy Either
Proxy
>>>
Proxy :: Proxy Functor
Proxy
>>>
Proxy :: Proxy complicatedStructure
Proxy
Constructors
Proxy |
Instances
Generic1 (Proxy :: k -> Type) | |
Foldable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable Methods fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # | |
Traversable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
NFData1 (Proxy :: Type -> Type) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Monoid (Proxy s) | Since: base-4.7.0.0 |
Semigroup (Proxy s) | Since: base-4.9.0.0 |
Bounded (Proxy t) | Since: base-4.7.0.0 |
Enum (Proxy s) | Since: base-4.7.0.0 |
Generic (Proxy t) | |
Ix (Proxy s) | Since: base-4.7.0.0 |
Defined in Data.Proxy | |
Read (Proxy t) | Since: base-4.7.0.0 |
Show (Proxy s) | Since: base-4.7.0.0 |
NFData (Proxy a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
Eq (Proxy s) | Since: base-4.7.0.0 |
Ord (Proxy s) | Since: base-4.7.0.0 |
type Rep1 (Proxy :: k -> Type) | Since: base-4.6.0.0 |
type Rep (Proxy t) | Since: base-4.6.0.0 |
See openFile
Constructors
ReadMode | |
WriteMode | |
AppendMode | |
ReadWriteMode |
The Const
functor.
Instances
Generic1 (Const a :: k -> Type) | |
Unbox a => Vector Vector (Const a b) | |
Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: Mutable Vector s (Const a b) -> ST s (Vector (Const a b)) # basicUnsafeThaw :: Vector (Const a b) -> ST s (Mutable Vector s (Const a b)) # basicLength :: Vector (Const a b) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (Const a b) -> Vector (Const a b) # basicUnsafeIndexM :: Vector (Const a b) -> Int -> Box (Const a b) # basicUnsafeCopy :: Mutable Vector s (Const a b) -> Vector (Const a b) -> ST s () # | |
Unbox a => MVector MVector (Const a b) | |
Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s (Const a b) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (Const a b) -> MVector s (Const a b) # basicOverlaps :: MVector s (Const a b) -> MVector s (Const a b) -> Bool # basicUnsafeNew :: Int -> ST s (MVector s (Const a b)) # basicInitialize :: MVector s (Const a b) -> ST s () # basicUnsafeReplicate :: Int -> Const a b -> ST s (MVector s (Const a b)) # basicUnsafeRead :: MVector s (Const a b) -> Int -> ST s (Const a b) # basicUnsafeWrite :: MVector s (Const a b) -> Int -> Const a b -> ST s () # basicClear :: MVector s (Const a b) -> ST s () # basicSet :: MVector s (Const a b) -> Const a b -> ST s () # basicUnsafeCopy :: MVector s (Const a b) -> MVector s (Const a b) -> ST s () # basicUnsafeMove :: MVector s (Const a b) -> MVector s (Const a b) -> ST s () # basicUnsafeGrow :: MVector s (Const a b) -> Int -> ST s (MVector s (Const a b)) # | |
Arbitrary2 (Const :: Type -> Type -> Type) | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary2 :: Gen a -> Gen b -> Gen (Const a b) # liftShrink2 :: (a -> [a]) -> (b -> [b]) -> Const a b -> [Const a b] # | |
NFData2 (Const :: Type -> Type -> Type) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Arbitrary a => Arbitrary1 (Const a :: Type -> Type) | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary :: Gen a0 -> Gen (Const a a0) # liftShrink :: (a0 -> [a0]) -> Const a a0 -> [Const a a0] # | |
Foldable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Functor.Const Methods fold :: Monoid m0 => Const m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldr :: (a -> b -> b) -> b -> Const m a -> b # foldr' :: (a -> b -> b) -> b -> Const m a -> b # foldl :: (b -> a -> b) -> b -> Const m a -> b # foldl' :: (b -> a -> b) -> b -> Const m a -> b # foldr1 :: (a -> a -> a) -> Const m a -> a # foldl1 :: (a -> a -> a) -> Const m a -> a # elem :: Eq a => a -> Const m a -> Bool # maximum :: Ord a => Const m a -> a # minimum :: Ord a => Const m a -> a # | |
Traversable (Const m :: Type -> Type) | Since: base-4.7.0.0 |
Monoid m => Applicative (Const m :: Type -> Type) | Since: base-2.0.1 |
Functor (Const m :: Type -> Type) | Since: base-2.1 |
NFData a => NFData1 (Const a :: Type -> Type) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Arbitrary a => Arbitrary (Const a b) | |
CoArbitrary a => CoArbitrary (Const a b) | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: Const a b -> Gen b0 -> Gen b0 # | |
Function a => Function (Const a b) | |
IsString a => IsString (Const a b) | Since: base-4.9.0.0 |
Defined in Data.String Methods fromString :: String -> Const a b # | |
Storable a => Storable (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
Monoid a => Monoid (Const a b) | Since: base-4.9.0.0 |
Semigroup a => Semigroup (Const a b) | Since: base-4.9.0.0 |
Bits a => Bits (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods (.&.) :: Const a b -> Const a b -> Const a b # (.|.) :: Const a b -> Const a b -> Const a b # xor :: Const a b -> Const a b -> Const a b # complement :: Const a b -> Const a b # shift :: Const a b -> Int -> Const a b # rotate :: Const a b -> Int -> Const a b # setBit :: Const a b -> Int -> Const a b # clearBit :: Const a b -> Int -> Const a b # complementBit :: Const a b -> Int -> Const a b # testBit :: Const a b -> Int -> Bool # bitSizeMaybe :: Const a b -> Maybe Int # isSigned :: Const a b -> Bool # shiftL :: Const a b -> Int -> Const a b # unsafeShiftL :: Const a b -> Int -> Const a b # shiftR :: Const a b -> Int -> Const a b # unsafeShiftR :: Const a b -> Int -> Const a b # rotateL :: Const a b -> Int -> Const a b # | |
FiniteBits a => FiniteBits (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods finiteBitSize :: Const a b -> Int # countLeadingZeros :: Const a b -> Int # countTrailingZeros :: Const a b -> Int # | |
Bounded a => Bounded (Const a b) | Since: base-4.9.0.0 |
Enum a => Enum (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods succ :: Const a b -> Const a b # pred :: Const a b -> Const a b # fromEnum :: Const a b -> Int # enumFrom :: Const a b -> [Const a b] # enumFromThen :: Const a b -> Const a b -> [Const a b] # enumFromTo :: Const a b -> Const a b -> [Const a b] # enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] # | |
Floating a => Floating (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods exp :: Const a b -> Const a b # log :: Const a b -> Const a b # sqrt :: Const a b -> Const a b # (**) :: Const a b -> Const a b -> Const a b # logBase :: Const a b -> Const a b -> Const a b # sin :: Const a b -> Const a b # cos :: Const a b -> Const a b # tan :: Const a b -> Const a b # asin :: Const a b -> Const a b # acos :: Const a b -> Const a b # atan :: Const a b -> Const a b # sinh :: Const a b -> Const a b # cosh :: Const a b -> Const a b # tanh :: Const a b -> Const a b # asinh :: Const a b -> Const a b # acosh :: Const a b -> Const a b # atanh :: Const a b -> Const a b # log1p :: Const a b -> Const a b # expm1 :: Const a b -> Const a b # | |
RealFloat a => RealFloat (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods floatRadix :: Const a b -> Integer # floatDigits :: Const a b -> Int # floatRange :: Const a b -> (Int, Int) # decodeFloat :: Const a b -> (Integer, Int) # encodeFloat :: Integer -> Int -> Const a b # exponent :: Const a b -> Int # significand :: Const a b -> Const a b # scaleFloat :: Int -> Const a b -> Const a b # isInfinite :: Const a b -> Bool # isDenormalized :: Const a b -> Bool # isNegativeZero :: Const a b -> Bool # | |
Generic (Const a b) | |
Ix a => Ix (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods range :: (Const a b, Const a b) -> [Const a b] # index :: (Const a b, Const a b) -> Const a b -> Int # unsafeIndex :: (Const a b, Const a b) -> Const a b -> Int # inRange :: (Const a b, Const a b) -> Const a b -> Bool # rangeSize :: (Const a b, Const a b) -> Int # unsafeRangeSize :: (Const a b, Const a b) -> Int # | |
Num a => Num (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
Read a => Read (Const a b) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
Fractional a => Fractional (Const a b) | Since: base-4.9.0.0 |
Integral a => Integral (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods quot :: Const a b -> Const a b -> Const a b # rem :: Const a b -> Const a b -> Const a b # div :: Const a b -> Const a b -> Const a b # mod :: Const a b -> Const a b -> Const a b # quotRem :: Const a b -> Const a b -> (Const a b, Const a b) # divMod :: Const a b -> Const a b -> (Const a b, Const a b) # | |
Real a => Real (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const Methods toRational :: Const a b -> Rational # | |
RealFrac a => RealFrac (Const a b) | Since: base-4.9.0.0 |
Show a => Show (Const a b) | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
NFData a => NFData (Const a b) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
Eq a => Eq (Const a b) | Since: base-4.9.0.0 |
Ord a => Ord (Const a b) | Since: base-4.9.0.0 |
Unbox a => Unbox (Const a b) | |
Defined in Data.Vector.Unboxed.Base | |
type Rep1 (Const a :: k -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
newtype MVector s (Const a b) | |
Defined in Data.Vector.Unboxed.Base | |
type Rep (Const a b) | Since: base-4.9.0.0 |
Defined in Data.Functor.Const | |
newtype Vector (Const a b) | |
Defined in Data.Vector.Unboxed.Base |
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.
A mode that determines the effect of hSeek
hdl mode i
.
Constructors
AbsoluteSeek | the position of |
RelativeSeek | the position of |
SeekFromEnd | the position of |
Instances
Enum SeekMode | Since: base-4.2.0.0 |
Ix SeekMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Device Methods range :: (SeekMode, SeekMode) -> [SeekMode] # index :: (SeekMode, SeekMode) -> SeekMode -> Int # unsafeIndex :: (SeekMode, SeekMode) -> SeekMode -> Int # inRange :: (SeekMode, SeekMode) -> SeekMode -> Bool # rangeSize :: (SeekMode, SeekMode) -> Int # unsafeRangeSize :: (SeekMode, SeekMode) -> Int # | |
Read SeekMode | Since: base-4.2.0.0 |
Show SeekMode | Since: base-4.2.0.0 |
Eq SeekMode | Since: base-4.2.0.0 |
Ord SeekMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Device |
data NewlineMode #
Specifies the translation, if any, of newline characters between
internal Strings and the external file or stream. Haskell Strings
are assumed to represent newlines with the '\n'
character; the
newline mode specifies how to translate '\n'
on output, and what to
translate into '\n'
on input.
Constructors
NewlineMode | |
Instances
The representation of a newline in the external file or stream.
data BufferMode #
Three kinds of buffering are supported: line-buffering, block-buffering or no-buffering. These modes have the following effects. For output, items are written out, or flushed, from the internal buffer according to the buffer mode:
- line-buffering: the entire output buffer is flushed
whenever a newline is output, the buffer overflows,
a
hFlush
is issued, or the handle is closed. - block-buffering: the entire buffer is written out whenever it
overflows, a
hFlush
is issued, or the handle is closed. - no-buffering: output is written immediately, and never stored in the buffer.
An implementation is free to flush the buffer more frequently, but not less frequently, than specified above. The output buffer is emptied as soon as it has been written out.
Similarly, input occurs according to the buffer mode for the handle:
- line-buffering: when the buffer for the handle is not empty, the next item is obtained from the buffer; otherwise, when the buffer is empty, characters up to and including the next newline character are read into the buffer. No characters are available until the newline character is available or the buffer is full.
- block-buffering: when the buffer for the handle becomes empty, the next block of data is read into the buffer.
- no-buffering: the next input item is read and returned.
The
hLookAhead
operation implies that even a no-buffered handle may require a one-character buffer.
The default buffering mode when a handle is opened is implementation-dependent and may depend on the file system object which is attached to that handle. For most implementations, physical files will normally be block-buffered and terminals will normally be line-buffered.
Constructors
NoBuffering | buffering is disabled if possible. |
LineBuffering | line-buffering should be enabled if possible. |
BlockBuffering (Maybe Int) | block-buffering should be enabled if possible.
The size of the buffer is |
Instances
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] # | |
Show BufferMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methods showsPrec :: Int -> BufferMode -> ShowS # show :: BufferMode -> String # showList :: [BufferMode] -> ShowS # | |
Eq BufferMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types | |
Ord BufferMode | Since: base-4.2.0.0 |
Defined in GHC.IO.Handle.Types Methods compare :: BufferMode -> BufferMode -> Ordering # (<) :: BufferMode -> BufferMode -> Bool # (<=) :: BufferMode -> BufferMode -> Bool # (>) :: BufferMode -> BufferMode -> Bool # (>=) :: BufferMode -> BufferMode -> Bool # max :: BufferMode -> BufferMode -> BufferMode # min :: BufferMode -> BufferMode -> BufferMode # |
data HandlePosn #
Instances
Show HandlePosn | Since: base-4.1.0.0 |
Defined in GHC.IO.Handle Methods showsPrec :: Int -> HandlePosn -> ShowS # show :: HandlePosn -> String # showList :: [HandlePosn] -> ShowS # | |
Eq HandlePosn | Since: base-4.1.0.0 |
Defined in GHC.IO.Handle |
Lists, but with an Applicative
functor based on zipping.
Constructors
ZipList | |
Fields
|
Instances
Arbitrary1 ZipList | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary :: Gen a -> Gen (ZipList a) # liftShrink :: (a -> [a]) -> ZipList a -> [ZipList a] # | |
Foldable ZipList | Since: base-4.9.0.0 |
Defined in Control.Applicative Methods fold :: Monoid m => ZipList m -> m # foldMap :: Monoid m => (a -> m) -> ZipList a -> m # foldMap' :: Monoid m => (a -> m) -> ZipList a -> m # foldr :: (a -> b -> b) -> b -> ZipList a -> b # foldr' :: (a -> b -> b) -> b -> ZipList a -> b # foldl :: (b -> a -> b) -> b -> ZipList a -> b # foldl' :: (b -> a -> b) -> b -> ZipList a -> b # foldr1 :: (a -> a -> a) -> ZipList a -> a # foldl1 :: (a -> a -> a) -> ZipList a -> a # elem :: Eq a => a -> ZipList a -> Bool # maximum :: Ord a => ZipList a -> a # minimum :: Ord a => ZipList a -> a # | |
Traversable ZipList | Since: base-4.9.0.0 |
Alternative ZipList | Since: base-4.11.0.0 |
Applicative ZipList | f <$> ZipList xs1 <*> ... <*> ZipList xsN = ZipList (zipWithN f xs1 ... xsN) where (\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..] = ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..]) = ZipList {getZipList = ["a5","b6b6","c7c7c7"]} Since: base-2.1 |
Functor ZipList | Since: base-2.1 |
NFData1 ZipList | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Generic1 ZipList | |
Arbitrary a => Arbitrary (ZipList a) | |
CoArbitrary a => CoArbitrary (ZipList a) | |
Defined in Test.QuickCheck.Arbitrary Methods coarbitrary :: ZipList a -> Gen b -> Gen b # | |
Generic (ZipList a) | |
IsList (ZipList a) | Since: base-4.15.0.0 |
Read a => Read (ZipList a) | Since: base-4.7.0.0 |
Show a => Show (ZipList a) | Since: base-4.7.0.0 |
NFData a => NFData (ZipList a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
Eq a => Eq (ZipList a) | Since: base-4.7.0.0 |
Ord a => Ord (ZipList a) | Since: base-4.7.0.0 |
type Rep1 ZipList | Since: base-4.7.0.0 |
Defined in Control.Applicative | |
type Rep (ZipList a) | Since: base-4.7.0.0 |
Defined in Control.Applicative | |
type Item (ZipList a) | |
Defined in GHC.IsList |
newtype WrappedArrow (a :: Type -> Type -> Type) b c #
Constructors
WrapArrow | |
Fields
|
Instances
Generic1 (WrappedArrow a b :: Type -> Type) | |
Defined in Control.Applicative Associated Types type Rep1 (WrappedArrow a b) :: k -> Type # Methods from1 :: forall (a0 :: k). WrappedArrow a b a0 -> Rep1 (WrappedArrow a b) a0 # to1 :: forall (a0 :: k). Rep1 (WrappedArrow a b) a0 -> WrappedArrow a b a0 # | |
(ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods empty :: WrappedArrow a b a0 # (<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 # some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] # many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] # | |
Arrow a => Applicative (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods pure :: a0 -> WrappedArrow a b a0 # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
Arrow a => Functor (WrappedArrow a b) | Since: base-2.1 |
Defined in Control.Applicative Methods fmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # (<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
Arbitrary (a b c) => Arbitrary (WrappedArrow a b c) | |
Defined in Test.QuickCheck.Arbitrary Methods arbitrary :: Gen (WrappedArrow a b c) # shrink :: WrappedArrow a b c -> [WrappedArrow a b c] # | |
Generic (WrappedArrow a b c) | |
Defined in Control.Applicative Associated Types type Rep (WrappedArrow a b c) :: Type -> Type # Methods from :: WrappedArrow a b c -> Rep (WrappedArrow a b c) x # to :: Rep (WrappedArrow a b c) x -> WrappedArrow a b c # | |
type Rep1 (WrappedArrow a b :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Control.Applicative type Rep1 (WrappedArrow a b :: Type -> Type) = D1 ('MetaData "WrappedArrow" "Control.Applicative" "base" 'True) (C1 ('MetaCons "WrapArrow" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapArrow") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 (a b)))) | |
type Rep (WrappedArrow a b c) | Since: base-4.7.0.0 |
Defined in Control.Applicative type Rep (WrappedArrow a b c) = D1 ('MetaData "WrappedArrow" "Control.Applicative" "base" 'True) (C1 ('MetaCons "WrapArrow" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrapArrow") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a b c)))) |
newtype WrappedMonad (m :: Type -> Type) a #
Constructors
WrapMonad | |
Fields
|
Instances
A type class for examples
Minimal complete definition
Instances
Instances
type Arg Property | |
Defined in Test.Hspec.Core.QuickCheck | |
type Arg Result | |
Defined in Test.Hspec.Core.Example | |
type Arg Expectation | |
Defined in Test.Hspec.Core.Example | |
type Arg Bool | |
Defined in Test.Hspec.Core.Example | |
type Arg (a -> Property) | |
Defined in Test.Hspec.Core.QuickCheck | |
type Arg (a -> Result) | |
Defined in Test.Hspec.Core.Example | |
type Arg (a -> Expectation) | |
Defined in Test.Hspec.Core.Example | |
type Arg (a -> Bool) | |
Defined in Test.Hspec.Core.Example |
Instances
data ByteString #
A space-efficient representation of a Word8
vector, supporting many
efficient operations.
A ByteString
contains 8-bit bytes, or by using the operations from
Data.ByteString.Char8 it can be interpreted as containing 8-bit
characters.
Instances
type ActionWith a = a -> IO () #
An IO
action that expects an argument of type a
type Expectation = Assertion #
Instances
(Unbox a, Storable a, Dimension dim) => Storable (Tuple dim a) | |
Defined in Raaz.Core.Types.Tuple Methods sizeOf :: Tuple dim a -> Int # alignment :: Tuple dim a -> Int # peekElemOff :: Ptr (Tuple dim a) -> Int -> IO (Tuple dim a) # pokeElemOff :: Ptr (Tuple dim a) -> Int -> Tuple dim a -> IO () # peekByteOff :: Ptr b -> Int -> IO (Tuple dim a) # pokeByteOff :: Ptr b -> Int -> Tuple dim a -> IO () # | |
(Show a, Unbox a) => Show (Tuple dim a) | |
(Unbox a, Equality a) => Eq (Tuple dim a) | |
(Unbox a, EndianStore a, Dimension dim) => EndianStore (Tuple dim a) | |
(Unbox a, Equality a) => Equality (Tuple dim a) | |
Defined in Raaz.Core.Types.Tuple |
class (Unbox (WordType p), EndianStore (WordType p), KnownNat (WordsPerBlock p)) => Primitive p #
Instances
Primitive ChaCha20 | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
Primitive XChaCha20 | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
Primitive Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal | |
(Unbox w, EndianStore w) => Primitive (Blake2 w) | |
Defined in Raaz.Primitive.Blake2.Internal | |
Primitive prim => Primitive (Keyed prim) | |
Defined in Raaz.Primitive.Keyed.Internal | |
(Unbox w, EndianStore w) => Primitive (Sha2 w) | |
Defined in Raaz.Primitive.Sha2.Internal |
Instances
Arbitrary Poly1305 Source # | |
IsString Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal Methods fromString :: String -> Poly1305 # | |
Storable Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal | |
Show Poly1305 | |
Eq Poly1305 | |
Encodable Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal | |
Primitive Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal | |
EndianStore Poly1305 | |
Equality Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal | |
Arbitrary (Key Poly1305) Source # | |
Show (Key Poly1305) | |
data Key Poly1305 | |
type WordType Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal | |
type WordsPerBlock Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal |
Instances
class ByteSource src where #
Instances
ByteSource Handle | |
Defined in Raaz.Core.ByteSource | |
ByteSource ByteString | |
Defined in Raaz.Core.ByteSource Methods fillBytes :: BYTES Int -> ByteString -> Ptr a -> IO (FillResult ByteString) # | |
ByteSource ByteString | |
Defined in Raaz.Core.ByteSource Methods fillBytes :: BYTES Int -> ByteString -> Ptr a -> IO (FillResult ByteString) # | |
ByteSource src => ByteSource (Maybe src) | |
Defined in Raaz.Core.ByteSource | |
ByteSource src => ByteSource [src] | |
Defined in Raaz.Core.ByteSource |
data FillResult a #
Instances
Functor FillResult | |
Defined in Raaz.Core.ByteSource Methods fmap :: (a -> b) -> FillResult a -> FillResult b # (<$) :: a -> FillResult b -> FillResult a # | |
Show a => Show (FillResult a) | |
Defined in Raaz.Core.ByteSource Methods showsPrec :: Int -> FillResult a -> ShowS # show :: FillResult a -> String # showList :: [FillResult a] -> ShowS # | |
Eq a => Eq (FillResult a) | |
Defined in Raaz.Core.ByteSource |
class ByteSource src => PureByteSource src #
Instances
PureByteSource ByteString | |
Defined in Raaz.Core.ByteSource | |
PureByteSource ByteString | |
Defined in Raaz.Core.ByteSource | |
PureByteSource src => PureByteSource (Maybe src) | |
Defined in Raaz.Core.ByteSource | |
PureByteSource src => PureByteSource [src] | |
Defined in Raaz.Core.ByteSource |
Instances
Arbitrary Base16 Source # | |
IsString Base16 | |
Defined in Raaz.Core.Encode.Base16 Methods fromString :: String -> Base16 # | |
Monoid Base16 | |
Semigroup Base16 | |
Show Base16 | |
Eq Base16 | |
Encodable Base16 | |
Defined in Raaz.Core.Encode.Base16 | |
Format Base16 | |
Defined in Raaz.Core.Encode.Base16 |
Instances
Arbitrary Base64 Source # | |
IsString Base64 | |
Defined in Raaz.Core.Encode.Base64 Methods fromString :: String -> Base64 # | |
Monoid Base64 | |
Semigroup Base64 | |
Show Base64 | |
Eq Base64 | |
Encodable Base64 | |
Defined in Raaz.Core.Encode.Base64 | |
Format Base64 | |
Defined in Raaz.Core.Encode.Base64 |
Minimal complete definition
Nothing
Methods
toByteString :: a -> ByteString #
fromByteString :: ByteString -> Maybe a #
unsafeFromByteString :: ByteString -> a #
Instances
class Memory m => Extractable m v where #
Instances
Extractable ChaCha20Mem (BlockCount ChaCha20) | |
Defined in Raaz.Primitive.ChaCha20.Internal Methods extract :: ChaCha20Mem -> IO (BlockCount ChaCha20) # | |
Storable a => Extractable (MemoryCell a) a | |
Defined in Raaz.Core.Memory Methods extract :: MemoryCell a -> IO a # |
class Memory m => Initialisable m v where #
Methods
initialise :: v -> m -> IO () #
Instances
Instances
Memory VoidMemory | |
Defined in Raaz.Core.Memory | |
Memory ChaCha20Mem | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
Storable a => Memory (MemoryCell a) | |
Defined in Raaz.Core.Memory | |
(Memory ma, Memory mb) => Memory (ma, mb) | |
Defined in Raaz.Core.Memory | |
(Memory ma, Memory mb, Memory mc) => Memory (ma, mb, mc) | |
Defined in Raaz.Core.Memory | |
(Memory ma, Memory mb, Memory mc, Memory md) => Memory (ma, mb, mc, md) | |
Defined in Raaz.Core.Memory |
data MemoryCell a #
Instances
Storable a => Memory (MemoryCell a) | |
Defined in Raaz.Core.Memory | |
EndianStore a => ReadAccessible (MemoryCell a) | |
Defined in Raaz.Core.Memory | |
EndianStore a => WriteAccessible (MemoryCell a) | |
Defined in Raaz.Core.Memory | |
Storable a => Extractable (MemoryCell a) a | |
Defined in Raaz.Core.Memory Methods extract :: MemoryCell a -> IO a # | |
Storable a => Initialisable (MemoryCell a) a | |
Defined in Raaz.Core.Memory Methods initialise :: a -> MemoryCell a -> IO () # | |
Initialisable (MemoryCell (Key ChaCha20)) (Key XChaCha20) | |
Defined in Raaz.Primitive.ChaCha20.Internal Methods initialise :: Key XChaCha20 -> MemoryCell (Key ChaCha20) -> IO () # |
class Memory mem => ReadAccessible mem where #
Instances
EndianStore a => ReadAccessible (MemoryCell a) | |
Defined in Raaz.Core.Memory |
data VoidMemory #
Instances
Memory VoidMemory | |
Defined in Raaz.Core.Memory |
class Memory mem => WriteAccessible mem where #
Instances
WriteAccessible ChaCha20Mem | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
EndianStore a => WriteAccessible (MemoryCell a) | |
Defined in Raaz.Core.Memory |
type AlignedBlockPtr (n :: Nat) p = AlignedPtr n (Block p) #
type Block p = Tuple (WordsPerBlock p) (WordType p) #
newtype BlockCount p #
Constructors
BlockCount | |
Fields
|
Instances
Instances
Instances
type WordType ChaCha20 | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
type WordType XChaCha20 | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
type WordType Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal | |
type WordType (Blake2 w) | |
Defined in Raaz.Primitive.Blake2.Internal type WordType (Blake2 w) = w | |
type WordType (Keyed prim) | |
Defined in Raaz.Primitive.Keyed.Internal | |
type WordType (Sha2 w) | |
Defined in Raaz.Primitive.Sha2.Internal type WordType (Sha2 w) = w |
type family WordsPerBlock p :: Nat #
Instances
type WordsPerBlock ChaCha20 | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
type WordsPerBlock XChaCha20 | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
type WordsPerBlock Poly1305 | |
Defined in Raaz.Primitive.Poly1305.Internal | |
type WordsPerBlock (Blake2 w) | |
Defined in Raaz.Primitive.Blake2.Internal type WordsPerBlock (Blake2 w) = 16 | |
type WordsPerBlock (Keyed prim) | |
Defined in Raaz.Primitive.Keyed.Internal | |
type WordsPerBlock (Sha2 w) | |
Defined in Raaz.Primitive.Sha2.Internal type WordsPerBlock (Sha2 w) = 16 |
Instances
class Storable w => EndianStore w where #
Instances
EndianStore Word8 | |
EndianStore Poly1305 | |
EndianStore R | |
EndianStore S | |
EndianStore () | |
EndianStore (Key ChaCha20) | |
EndianStore (Key XChaCha20) | |
EndianStore (Nounce ChaCha20) | |
EndianStore (Nounce XChaCha20) | |
EndianStore (BE Word32) | |
EndianStore (BE Word64) | |
EndianStore (LE Word32) | |
EndianStore (LE Word64) | |
EndianStore w => EndianStore (BYTES w) | |
(Unbox w, EndianStore w) => EndianStore (Blake2 w) | |
EndianStore prim => EndianStore (Keyed prim) | |
(Unbox w, EndianStore w) => EndianStore (Sha2 w) | |
(Unbox a, EndianStore a, Dimension dim) => EndianStore (Tuple dim a) | |
Instances
Instances
data AlignedPtr (n :: Nat) a #
Instances
KnownNat n => Pointer (AlignedPtr n) | |
Defined in Raaz.Core.Types.Pointer Methods castPointer :: AlignedPtr n a -> AlignedPtr n b # allocaPointer :: BYTES Int -> (AlignedPtr n a -> IO b) -> IO b # unsafeRawPtr :: AlignedPtr n a -> Ptr a # |
class (Enum u, Monoid u) => LengthUnit u where #
Instances
Primitive p => LengthUnit (BlockCount p) | |
Defined in Raaz.Core.Primitive Methods inBytes :: BlockCount p -> BYTES Int # | |
LengthUnit (BYTES Int) | |
class Pointer (ptr :: Type -> Type) where #
Methods
castPointer :: ptr a -> ptr b #
allocaPointer :: BYTES Int -> (ptr a -> IO b) -> IO b #
unsafeRawPtr :: ptr a -> Ptr a #
Instances
Pointer Ptr | |
Defined in Raaz.Core.Types.Pointer Methods castPointer :: Ptr a -> Ptr b # allocaPointer :: BYTES Int -> (Ptr a -> IO b) -> IO b # unsafeRawPtr :: Ptr a -> Ptr a # | |
KnownNat n => Pointer (AlignedPtr n) | |
Defined in Raaz.Core.Types.Pointer Methods castPointer :: AlignedPtr n a -> AlignedPtr n b # allocaPointer :: BYTES Int -> (AlignedPtr n a -> IO b) -> IO b # unsafeRawPtr :: AlignedPtr n a -> Ptr a # |
type Blake2bMem = HashMemory128 Blake2b #
type Blake2sMem = HashMemory64 Blake2s #
Constructors
ChaCha20 |
Instances
Constructors
XChaCha20 |
Instances
data ChaCha20Mem #
Constructors
ChaCha20Mem | |
Fields
|
Instances
Memory ChaCha20Mem | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
WriteAccessible ChaCha20Mem | |
Defined in Raaz.Primitive.ChaCha20.Internal | |
Extractable ChaCha20Mem (BlockCount ChaCha20) | |
Defined in Raaz.Primitive.ChaCha20.Internal Methods extract :: ChaCha20Mem -> IO (BlockCount ChaCha20) # | |
Initialisable ChaCha20Mem (BlockCount ChaCha20) | |
Defined in Raaz.Primitive.ChaCha20.Internal Methods initialise :: BlockCount ChaCha20 -> ChaCha20Mem -> IO () # | |
Initialisable ChaCha20Mem (Key ChaCha20) | |
Defined in Raaz.Primitive.ChaCha20.Internal Methods initialise :: Key ChaCha20 -> ChaCha20Mem -> IO () # | |
Initialisable ChaCha20Mem (Nounce ChaCha20) | |
Defined in Raaz.Primitive.ChaCha20.Internal Methods initialise :: Nounce ChaCha20 -> ChaCha20Mem -> IO () # |
pattern Fn2 :: (a -> b -> c) -> Fun (a, b) c #
A modifier for testing binary functions.
prop_zipWith :: Fun (Int, Bool) Char -> [Int] -> [Bool] -> Bool prop_zipWith (Fn2 f) xs ys = zipWith f xs ys == [ f x y | (x, y) <- zip xs ys]
pattern Fn :: (a -> b) -> Fun a b #
A modifier for testing functions.
prop :: Fun String Integer -> Bool prop (Fn f) = f "banana" == f "monkey" || f "banana" == f "elephant"
Run a given spec and write a report to stdout
.
Exit with exitFailure
if at least one spec item fails.
Note: hspec
handles command-line options and reads config files. This
is not always desirable. Use evalSpec
and runSpecForest
if you need
more control over these aspects.
assert :: forall (m :: Type -> Type). Monad m => Bool -> PropertyM m () #
Allows embedding non-monadic properties into monadic ones.
(==>) :: Testable prop => Bool -> prop -> Property infixr 0 #
Implication for properties: The resulting property holds if
the first argument is False
(in which case the test case is discarded),
or if the given property holds. Note that using implication carelessly can
severely skew test case distribution: consider using cover
to make sure
that your test data is still good quality.
($) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 #
Application operator. This operator is redundant, since ordinary
application (f x)
means the same as (f
. However, $
x)$
has
low, right-associative binding precedence, so it sometimes allows
parentheses to be omitted; for example:
f $ g $ h x = f (g (h x))
It is also useful in higher-order situations, such as
,
or map
($
0) xs
.zipWith
($
) fs xs
Note that (
is representation-polymorphic in its result type, so that
$
)foo
where $
Truefoo :: Bool -> Int#
is well-typed.
(++) :: [a] -> [a] -> [a] infixr 5 #
Append two lists, i.e.,
[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
If the first list is not finite, the result is the first list.
WARNING: This function takes linear time in the number of elements of the first list.
map :: (a -> b) -> [a] -> [b] #
O(n). map
f xs
is the list obtained by applying f
to
each element of xs
, i.e.,
map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]
>>>
map (+1) [1, 2, 3]
[2,3,4]
join :: Monad m => m (m a) -> m a #
The join
function is the conventional monad join operator. It
is used to remove one level of monadic structure, projecting its
bound argument into the outer level.
'
' can be understood as the join
bssdo
expression
do bs <- bss bs
Examples
A common use of join
is to run an IO
computation returned from
an STM
transaction, since STM
transactions
can't perform IO
directly. Recall that
atomically
:: STM a -> IO a
is used to run STM
transactions atomically. So, by
specializing the types of atomically
and join
to
atomically
:: STM (IO b) -> IO (IO b)join
:: IO (IO b) -> IO b
we can compose them as
join
.atomically
:: STM (IO b) -> IO b
sized :: (Int -> Gen a) -> Gen a #
Used to construct generators that depend on the size parameter.
For example, listOf
, which uses the size parameter as an upper bound on
length of lists it generates, can be defined like this:
listOf :: Gen a -> Gen [a] listOf gen = sized $ \n -> do k <- choose (0,n) vectorOf k gen
You can also do this using getSize
.
Returns the size parameter. Used to construct generators that depend on the size parameter.
For example, listOf
, which uses the size parameter as an upper bound on
length of lists it generates, can be defined like this:
listOf :: Gen a -> Gen [a] listOf gen = do n <- getSize k <- choose (0,n) vectorOf k gen
You can also do this using sized
.
resize :: HasCallStack => Int -> Gen a -> Gen a #
Overrides the size parameter. Returns a generator which uses the given size instead of the runtime-size parameter.
scale :: (Int -> Int) -> Gen a -> Gen a #
Adjust the size parameter, by transforming it with the given function.
choose :: Random a => (a, a) -> Gen a #
Generates a random element in the given inclusive range.
For integral and enumerated types, the specialised variants of
choose
below run much quicker.
chooseEnum :: Enum a => (a, a) -> Gen a #
A fast implementation of choose
for enumerated types.
chooseBoundedIntegral :: (Bounded a, Integral a) => (a, a) -> Gen a #
A fast implementation of choose
for bounded integral types.
Run a generator. The size passed to the generator is always 30;
if you want another size then you should explicitly use resize
.
suchThatMap :: Gen a -> (a -> Maybe b) -> Gen b #
Generates a value for which the given function returns a Just
, and then
applies the function.
suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a) #
Tries to generate a value that satisfies a predicate.
If it fails to do so after enough attempts, returns Nothing
.
oneof :: HasCallStack => [Gen a] -> Gen a #
Randomly uses one of the given generators. The input list must be non-empty.
frequency :: HasCallStack => [(Int, Gen a)] -> Gen a #
Chooses one of the given generators, with a weighted random distribution. The input list must be non-empty.
elements :: HasCallStack => [a] -> Gen a #
Generates one of the given values. The input list must be non-empty.
growingElements :: HasCallStack => [a] -> Gen a #
Takes a list of elements of increasing size, and chooses among an initial segment of the list. The size of this initial segment increases with the size parameter. The input list must be non-empty.
Generates a list of random length. The maximum length depends on the size parameter.
Generates a non-empty list of random length. The maximum length depends on the size parameter.
infiniteListOf :: Gen a -> Gen [a] #
Generates an infinite list.
arbitrary1 :: (Arbitrary1 f, Arbitrary a) => Gen (f a) #
shrink1 :: (Arbitrary1 f, Arbitrary a) => f a -> [f a] #
arbitrary2 :: (Arbitrary2 f, Arbitrary a, Arbitrary b) => Gen (f a b) #
shrink2 :: (Arbitrary2 f, Arbitrary a, Arbitrary b) => f a b -> [f a b] #
genericShrink :: (Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) => a -> [a] #
Shrink a term to any of its immediate subterms, and also recursively shrink all subterms.
recursivelyShrink :: (Generic a, RecursivelyShrink (Rep a)) => a -> [a] #
Recursively shrink all immediate subterms.
shrinkList :: (a -> [a]) -> [a] -> [[a]] #
Shrink a list of values given a shrinking function for individual values.
applyArbitrary2 :: (Arbitrary a, Arbitrary b) => (a -> b -> r) -> Gen r #
Apply a binary function to random arguments.
applyArbitrary3 :: (Arbitrary a, Arbitrary b, Arbitrary c) => (a -> b -> c -> r) -> Gen r #
Apply a ternary function to random arguments.
applyArbitrary4 :: (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d) => (a -> b -> c -> d -> r) -> Gen r #
Apply a function of arity 4 to random arguments.
arbitrarySizedIntegral :: Integral a => Gen a #
Generates an integral number. The number can be positive or negative and its maximum absolute value depends on the size parameter.
arbitrarySizedNatural :: Integral a => Gen a #
Generates a natural number. The number's maximum value depends on the size parameter.
arbitrarySizedFractional :: Fractional a => Gen a #
Uniformly generates a fractional number. The number can be positive or negative and its maximum absolute value depends on the size parameter.
arbitraryBoundedIntegral :: (Bounded a, Integral a) => Gen a #
Generates an integral number. The number is chosen uniformly from
the entire range of the type. You may want to use
arbitrarySizedBoundedIntegral
instead.
arbitraryBoundedRandom :: (Bounded a, Random a) => Gen a #
Generates an element of a bounded type. The element is chosen from the entire range of the type.
arbitraryBoundedEnum :: (Bounded a, Enum a) => Gen a #
Generates an element of a bounded enumeration.
arbitrarySizedBoundedIntegral :: (Bounded a, Integral a) => Gen a #
Generates an integral number from a bounded domain. The number is chosen from the entire range of the type, but small numbers are generated more often than big numbers. Inspired by demands from Phil Wadler.
arbitraryUnicodeChar :: Gen Char #
Generates any Unicode character (but not a surrogate)
arbitraryASCIIChar :: Gen Char #
Generates a random ASCII character (0-127).
arbitraryPrintableChar :: Gen Char #
Generates a printable Unicode character.
shrinkNothing :: a -> [a] #
Returns no shrinking alternatives.
shrinkMap :: Arbitrary a => (a -> b) -> (b -> a) -> b -> [b] #
Map a shrink function to another domain. This is handy if your data type has special invariants, but is almost isomorphic to some other type.
shrinkOrderedList :: (Ord a, Arbitrary a) => [a] -> [[a]] shrinkOrderedList = shrinkMap sort id shrinkSet :: (Ord a, Arbitrary a) => Set a -> [Set a] shrinkSet = shrinkMap fromList toList
shrinkMapBy :: (a -> b) -> (b -> a) -> (a -> [a]) -> b -> [b] #
Non-overloaded version of shrinkMap
.
shrinkIntegral :: Integral a => a -> [a] #
Shrink an integral number.
shrinkBoundedEnum :: (Bounded a, Enum a, Eq a) => a -> [a] #
Shrink an element of a bounded enumeration.
Example
data MyEnum = E0 | E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9 deriving (Bounded, Enum, Eq, Ord, Show)
>>>
shrinkBoundedEnum E9
[E0,E5,E7,E8]
>>>
shrinkBoundedEnum E5
[E0,E3,E4]
>>>
shrinkBoundedEnum E0
[]
shrinkRealFrac :: RealFrac a => a -> [a] #
Shrink a fraction, preferring numbers with smaller
numerators or denominators. See also shrinkDecimal
.
shrinkDecimal :: RealFrac a => a -> [a] #
Shrink a real number, preferring numbers with shorter
decimal representations. See also shrinkRealFrac
.
genericCoarbitrary :: (Generic a, GCoArbitrary (Rep a)) => a -> Gen b -> Gen b #
Generic CoArbitrary implementation.
(><) :: (Gen a -> Gen a) -> (Gen a -> Gen a) -> Gen a -> Gen a #
Combine two generator perturbing functions, for example the
results of calls to variant
or coarbitrary
.
coarbitraryIntegral :: Integral a => a -> Gen b -> Gen b #
A coarbitrary
implementation for integral numbers.
coarbitraryReal :: Real a => a -> Gen b -> Gen b #
A coarbitrary
implementation for real numbers.
coarbitraryShow :: Show a => a -> Gen b -> Gen b #
coarbitrary
helper for lazy people :-).
coarbitraryEnum :: Enum a => a -> Gen b -> Gen b #
A coarbitrary
implementation for enums.
orderedList :: (Ord a, Arbitrary a) => Gen [a] #
Generates an ordered list.
infiniteList :: Arbitrary a => Gen [a] #
Generates an infinite list.
functionRealFrac :: RealFrac a => (a -> b) -> a :-> b #
functionIntegral :: Integral a => (a -> b) -> a :-> b #
functionShow :: (Show a, Read a) => (a -> c) -> a :-> c #
functionVoid :: (forall b. void -> b) -> void :-> c #
functionMap :: Function b => (a -> b) -> (b -> a) -> (a -> c) -> a :-> c #
applyFun :: Fun a b -> a -> b #
Extracts the value of a function.
Fn
is the pattern equivalent of this function.
prop :: Fun String Integer -> Bool prop f = applyFun f "banana" == applyFun f "monkey" || applyFun f "banana" == applyFun f "elephant"
applyFun2 :: Fun (a, b) c -> a -> b -> c #
Extracts the value of a binary function.
Fn2
is the pattern equivalent of this function.
prop_zipWith :: Fun (Int, Bool) Char -> [Int] -> [Bool] -> Bool prop_zipWith f xs ys = zipWith (applyFun2 f) xs ys == [ applyFun2 f x y | (x, y) <- zip xs ys]
applyFun3 :: Fun (a, b, c) d -> a -> b -> c -> d #
Extracts the value of a ternary function. Fn3
is the
pattern equivalent of this function.
ioProperty :: Testable prop => IO prop -> Property #
Do I/O inside a property.
Warning: any random values generated inside of the argument to ioProperty
will not currently be shrunk. For best results, generate all random values
before calling ioProperty
, or use idempotentIOProperty
if that is safe.
idempotentIOProperty :: Testable prop => IO prop -> Property #
Do I/O inside a property.
Warning: during shrinking, the I/O may not always be re-executed.
Instead, the I/O may be executed once and then its result retained.
If this is not acceptable, use ioProperty
instead.
coerceWitness :: Typeable a => Witness -> a #
castWitness :: Typeable a => Witness -> Maybe a #
mapSize :: Testable prop => (Int -> Int) -> prop -> Property #
Adjust the test case size for a property, by transforming it with the given function.
Arguments
:: Testable prop | |
=> (a -> [a]) |
|
-> a | The original argument |
-> (a -> prop) | |
-> Property |
Shrinks the argument to a property if it fails. Shrinking is done automatically for most types. This function is only needed when you want to override the default behavior.
noShrinking :: Testable prop => prop -> Property #
Disables shrinking for a property altogether.
Only quantification inside the call to noShrinking
is affected.
counterexample :: Testable prop => String -> prop -> Property #
Adds the given string to the counterexample if the property fails.
printTestCase :: Testable prop => String -> prop -> Property #
Adds the given string to the counterexample if the property fails.
whenFail :: Testable prop => IO () -> prop -> Property #
Performs an IO
action after the last failure of a property.
whenFail' :: Testable prop => IO () -> prop -> Property #
Performs an IO
action every time a property fails. Thus,
if shrinking is done, this can be used to keep track of the
failures along the way.
verbose :: Testable prop => prop -> Property #
Prints out the generated test case every time the property is tested.
Only variables quantified over inside the verbose
are printed.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within
to add a timeout instead.
verboseShrinking :: Testable prop => prop -> Property #
Prints out the generated test case every time the property fails, including during shrinking.
Only variables quantified over inside the verboseShrinking
are printed.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within
to add a timeout instead.
expectFailure :: Testable prop => prop -> Property #
Indicates that a property is supposed to fail. QuickCheck will report an error if it does not fail.
once :: Testable prop => prop -> Property #
Modifies a property so that it only will be tested once.
Opposite of again
.
again :: Testable prop => prop -> Property #
Modifies a property so that it will be tested repeatedly.
Opposite of once
.
withMaxSuccess :: Testable prop => Int -> prop -> Property #
Configures how many times a property will be tested.
For example,
quickCheck (withMaxSuccess 1000 p)
will test p
up to 1000 times.
withDiscardRatio :: Testable prop => Int -> prop -> Property #
Configures how many times a property is allowed to be discarded before failing.
For example,
quickCheck (withDiscardRatio 10 p)
will allow p
to fail up to 10 times per successful test.
withMaxShrinks :: Testable prop => Int -> prop -> Property #
Configure the maximum number of times a property will be shrunk.
For example,
quickCheck (withMaxShrinks 100 p)
will cause p
to only attempt 100 shrinks on failure.
withMaxSize :: Testable prop => Int -> prop -> Property #
Configure the maximum size a property will be tested at.
witness :: (Typeable a, Show a, Testable prop) => a -> prop -> Property #
Return a value in the witnesses
field of the Result
returned by quickCheckResult
. Witnesses
are returned outer-most first.
In ghci, for example:
>>>
[Wit x] <- fmap witnesses . quickCheckResult $ \ x -> witness x $ x == (0 :: Int)
*** Failed! Falsified (after 2 tests): 1>>>
x
1>>>
:t x
x :: Int
checkCoverage :: Testable prop => prop -> Property #
Check that all coverage requirements defined by cover
and coverTable
are met, using a statistically sound test, and fail if they are not met.
Ordinarily, a failed coverage check does not cause the property to fail.
This is because the coverage requirement is not tested in a statistically
sound way. If you use cover
to express that a certain value must appear 20%
of the time, QuickCheck will warn you if the value only appears in 19 out of
100 test cases - but since the coverage varies randomly, you may have just
been unlucky, and there may not be any real problem with your test
generation.
When you use checkCoverage
, QuickCheck uses a statistical test to account
for the role of luck in coverage failures. It will run as many tests as
needed until it is sure about whether the coverage requirements are met. If a
coverage requirement is not met, the property fails.
Example:
quickCheck (checkCoverage prop_foo)
checkCoverageWith :: Testable prop => Confidence -> prop -> Property #
Check coverage requirements using a custom confidence level.
See stdConfidence
.
An example of making the statistical test less stringent in order to improve performance:
quickCheck (checkCoverageWith stdConfidence{certainty = 10^6} prop_foo)
The standard parameters used by checkCoverage
: certainty = 10^9
,
tolerance = 0.9
. See Confidence
for the meaning of the parameters.
label :: Testable prop => String -> prop -> Property #
Attaches a label to a test case. This is used for reporting test case distribution.
For example:
prop_reverse_reverse :: [Int] -> Property prop_reverse_reverse xs = label ("length of input is " ++ show (length xs)) $ reverse (reverse xs) === xs
>>>
quickCheck prop_reverse_reverse
+++ OK, passed 100 tests: 7% length of input is 7 6% length of input is 3 5% length of input is 4 4% length of input is 6 ...
Each use of label
in your property results in a separate
table of test case distribution in the output. If this is
not what you want, use tabulate
.
collect :: (Show a, Testable prop) => a -> prop -> Property #
Attaches a label to a test case. This is used for reporting test case distribution.
collect x = label (show x)
For example:
prop_reverse_reverse :: [Int] -> Property prop_reverse_reverse xs = collect (length xs) $ reverse (reverse xs) === xs
>>>
quickCheck prop_reverse_reverse
+++ OK, passed 100 tests: 7% 7 6% 3 5% 4 4% 6 ...
Each use of collect
in your property results in a separate
table of test case distribution in the output. If this is
not what you want, use tabulate
.
Arguments
:: Testable prop | |
=> Bool |
|
-> String | Label. |
-> prop | |
-> Property |
Reports how many test cases satisfy a given condition.
For example:
prop_sorted_sort :: [Int] -> Property prop_sorted_sort xs = sorted xs ==> classify (length xs > 1) "non-trivial" $ sort xs === xs
>>>
quickCheck prop_sorted_sort
+++ OK, passed 100 tests (22% non-trivial).
Arguments
:: Testable prop | |
=> Double | The required percentage (0-100) of test cases. |
-> Bool |
|
-> String | Label for the test case class. |
-> prop | |
-> Property |
Checks that at least the given proportion of successful test cases belong to the given class. Discarded tests (i.e. ones with a false precondition) do not affect coverage.
Note: If the coverage check fails, QuickCheck prints out a warning, but
the property does not fail. To make the property fail, use checkCoverage
.
For example:
prop_sorted_sort :: [Int] -> Property prop_sorted_sort xs = sorted xs ==> cover 50 (length xs > 1) "non-trivial" $ sort xs === xs
>>>
quickCheck prop_sorted_sort
+++ OK, passed 100 tests; 135 discarded (26% non-trivial). Only 26% non-trivial, but expected 50%
tabulate :: Testable prop => String -> [String] -> prop -> Property #
Collects information about test case distribution into a table.
The arguments to tabulate
are the table's name and a list of values
associated with the current test case. After testing, QuickCheck prints the
frequency of all collected values. The frequencies are expressed as a
percentage of the total number of values collected.
You should prefer tabulate
to label
when each test case is associated
with a varying number of values. Here is a (not terribly useful) example,
where the test data is a list of integers and we record all values that
occur in the list:
prop_sorted_sort :: [Int] -> Property prop_sorted_sort xs = sorted xs ==> tabulate "List elements" (map show xs) $ sort xs === xs
>>>
quickCheck prop_sorted_sort
+++ OK, passed 100 tests; 1684 discarded. List elements (109 in total): 3.7% 0 3.7% 17 3.7% 2 3.7% 6 2.8% -6 2.8% -7
Here is a more useful example. We are testing a chatroom, where the user can log in, log out, or send a message:
data Command = LogIn | LogOut | SendMessage String deriving (Data, Show) instance Arbitrary Command where ...
There are some restrictions on command sequences; for example, the user must
log in before doing anything else. The function valid :: [Command] -> Bool
checks that a command sequence is allowed. Our property then has the form:
prop_chatroom :: [Command] -> Property prop_chatroom cmds = valid cmds ==> ...
The use of ==>
may skew test case distribution. We use collect
to see the
length of the command sequences, and tabulate
to get the frequencies of the
individual commands:
prop_chatroom :: [Command] -> Property prop_chatroom cmds = wellFormed cmds LoggedOut ==> 'collect' (length cmds) $ 'tabulate' "Commands" (map (show . 'Data.Data.toConstr') cmds) $ ...
>>>
quickCheckWith stdArgs{maxDiscardRatio = 1000} prop_chatroom
+++ OK, passed 100 tests; 2775 discarded: 60% 0 20% 1 15% 2 3% 3 1% 4 1% 5 Commands (68 in total): 62% LogIn 22% SendMessage 16% LogOut
coverTable :: Testable prop => String -> [(String, Double)] -> prop -> Property #
Checks that the values in a given table
appear a certain proportion of
the time. A call to coverTable
table
[(x1, p1), ..., (xn, pn)]
asserts
that of the values in table
, x1
should appear at least p1
percent of
the time that table
appears, x2
at least p2
percent of the time that
table
appears, and so on.
Note: If the coverage check fails, QuickCheck prints out a warning, but
the property does not fail. To make the property fail, use checkCoverage
.
Continuing the example from the tabular
combinator...
data Command = LogIn | LogOut | SendMessage String deriving (Data, Show) prop_chatroom :: [Command] -> Property prop_chatroom cmds = wellFormed cmds LoggedOut ==> 'tabulate' "Commands" (map (show . 'Data.Data.toConstr') cmds) $ ...
...we can add a coverage requirement as follows, which checks that LogIn
,
LogOut
and SendMessage
each occur at least 25% of the time:
prop_chatroom :: [Command] -> Property prop_chatroom cmds = wellFormed cmds LoggedOut ==> coverTable "Commands" [("LogIn", 25), ("LogOut", 25), ("SendMessage", 25)] $ 'tabulate' "Commands" (map (show . 'Data.Data.toConstr') cmds) $ ... property goes here ...
>>>
quickCheck prop_chatroom
+++ OK, passed 100 tests; 2909 discarded: 56% 0 17% 1 10% 2 6% 3 5% 4 3% 5 3% 7 Commands (111 in total): 51.4% LogIn 30.6% SendMessage 18.0% LogOut Table 'Commands' had only 18.0% LogOut, but expected 25.0%
within :: Testable prop => Int -> prop -> Property #
Considers a property failed if it does not complete within the given number of microseconds.
Note: if the property times out, variables quantified inside the
within
will not be printed. Therefore, you should use within
only in the body of your property.
Good: prop_foo a b c = within 1000000 ...
Bad: prop_foo = within 1000000 $ \a b c -> ...
Bad: prop_foo a b c = ...; main = quickCheck (within 1000000 prop_foo)
discardAfter :: Testable prop => Int -> prop -> Property #
Discards the test case if it does not complete within the given number of microseconds. This can be useful when testing algorithms that have pathological cases where they run extremely slowly.
forAll :: (Show a, Testable prop) => Gen a -> (a -> prop) -> Property #
Explicit universal quantification: uses an explicitly given test case generator.
forAllShow :: Testable prop => Gen a -> (a -> String) -> (a -> prop) -> Property #
Like forAll
, but with an explicitly given show function.
forAllBlind :: Testable prop => Gen a -> (a -> prop) -> Property #
Like forAll
, but without printing the generated value.
forAllShrink :: (Show a, Testable prop) => Gen a -> (a -> [a]) -> (a -> prop) -> Property #
Like forAll
, but tries to shrink the argument for failing test cases.
forAllShrinkShow :: Testable prop => Gen a -> (a -> [a]) -> (a -> String) -> (a -> prop) -> Property #
Like forAllShrink
, but with an explicitly given show function.
forAllShrinkBlind :: Testable prop => Gen a -> (a -> [a]) -> (a -> prop) -> Property #
Like forAllShrink
, but without printing the generated value.
(.&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property infixr 1 #
Nondeterministic choice: p1
.&.
p2
picks randomly one of
p1
and p2
to test. If you test the property 100 times it
makes 100 random choices.
(.&&.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property infixr 1 #
Conjunction: p1
.&&.
p2
passes if both p1
and p2
pass.
(.||.) :: (Testable prop1, Testable prop2) => prop1 -> prop2 -> Property infixr 1 #
Disjunction: p1
.||.
p2
passes unless p1
and p2
simultaneously fail.
(===) :: (Eq a, Show a) => a -> a -> Property infix 4 #
Like ==
, but prints a counterexample when it fails.
(=/=) :: (Eq a, Show a) => a -> a -> Property infix 4 #
Like /=
, but prints a counterexample when it fails.
total :: NFData a => a -> Property #
Checks that a value is total, i.e., doesn't crash when evaluated.
quickCheck :: Testable prop => prop -> IO () #
Tests a property and prints the results to stdout
.
By default up to 100 tests are performed, which may not be enough
to find all bugs. To run more tests, use withMaxSuccess
.
If you want to get the counterexample as a Haskell value, rather than just printing it, try the quickcheck-with-counterexamples package.
quickCheckWith :: Testable prop => Args -> prop -> IO () #
Tests a property, using test arguments, and prints the results to stdout
.
quickCheckResult :: Testable prop => prop -> IO Result #
Tests a property, produces a test result, and prints the results to stdout
.
quickCheckWithResult :: Testable prop => Args -> prop -> IO Result #
Tests a property, using test arguments, produces a test result, and prints the results to stdout
.
recheck :: Testable prop => Result -> prop -> IO () #
Re-run a property with the seed and size that failed in a run of quickCheckResult
.
verboseCheck :: Testable prop => prop -> IO () #
Tests a property and prints the results and all test cases generated to stdout
.
This is just a convenience function that means the same as
.quickCheck
. verbose
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within
to add a timeout instead.
verboseCheckWith :: Testable prop => Args -> prop -> IO () #
Tests a property, using test arguments, and prints the results and all test cases generated to stdout
.
This is just a convenience function that combines quickCheckWith
and verbose
.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within
to add a timeout instead.
verboseCheckResult :: Testable prop => prop -> IO Result #
Tests a property, produces a test result, and prints the results and all test cases generated to stdout
.
This is just a convenience function that combines quickCheckResult
and verbose
.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within
to add a timeout instead.
verboseCheckWithResult :: Testable prop => Args -> prop -> IO Result #
Tests a property, using test arguments, produces a test result, and prints the results and all test cases generated to stdout
.
This is just a convenience function that combines quickCheckWithResult
and verbose
.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within
to add a timeout instead.
assertWith :: forall (m :: Type -> Type). Monad m => Bool -> String -> PropertyM m () #
Like assert
but allows caller to specify an explicit message to show on failure.
Example:
do assertWith True "My first predicate." assertWith False "My other predicate." ...
Assertion failed (after 2 tests): Passed: My first predicate Failed: My other predicate
pre :: forall (m :: Type -> Type). Monad m => Bool -> PropertyM m () #
Tests preconditions. Unlike assert
this does not cause the
property to fail, rather it discards them just like using the
implication combinator ==>
.
This allows representing the Hoare triple
{p} x ← e{q}
as
pre p x <- run e assert q
run :: Monad m => m a -> PropertyM m a #
The lifting operation of the property monad. Allows embedding
monadic/IO
-actions in properties:
log :: Int -> IO () prop_foo n = monadicIO $ do run (log n) -- ...
forAllM :: forall (m :: Type -> Type) a b. (Monad m, Show a) => Gen a -> (a -> PropertyM m b) -> PropertyM m b #
monitor :: forall (m :: Type -> Type). Monad m => (Property -> Property) -> PropertyM m () #
Allows making observations about the test data:
monitor (collect
e)
collects the distribution of value of e
.
monitor (counterexample
"Failure!")
Adds "Failure!"
to the counterexamples.
monadicIO :: Testable a => PropertyM IO a -> Property #
Runs the property monad for IO
-computations.
prop_cat msg = monadicIO $ do (exitCode, stdout, _) <- run (readProcessWithExitCode
"cat" [] msg) pre (ExitSuccess
== exitCode) assert (stdout == msg)
>>>
quickCheck prop_cat
+++ OK, passed 100 tests.
monadicST :: Testable a => (forall s. PropertyM (ST s) a) -> Property #
Runs the property monad for ST
-computations.
-- Your mutable sorting algorithm here sortST :: Ord a => [a] ->ST
s (MVector s a) sortST =thaw
.fromList
.sort
prop_sortST xs = monadicST $ do sorted <- run (freeze
=<< sortST xs) assert (toList
sorted == sort xs)
>>>
quickCheck prop_sortST
+++ OK, passed 100 tests.
Arguments
:: Exception exc | |
=> (exc -> Bool) | Return |
-> a | Value that should result in an exception, when evaluated to WHNF |
-> Property |
Evaluate the value to Weak Head Normal Form (WHNF) and fail if it does not result in an expected exception being thrown.
Arguments
:: Exception exc | |
=> (exc -> Bool) | Return |
-> IO a | An action that should throw the expected exception |
-> Property |
Make sure that a specific exception is thrown during an IO action. The result is evaluated to WHNF.
Arguments
:: (NFData a, Exception exc) | |
=> (exc -> Bool) | Return True if that is the exception that was expected |
-> a | Value that should result in an exception, when fully evaluated to NF |
-> Property |
Same as assertException
, but evaluate the value to Normal Form (NF) and fail if it
does not result in an expected exception being thrown.
Arguments
:: (NFData a, Exception exc) | |
=> (exc -> Bool) | Return True if that is the exception that was expected |
-> IO a | An action that should throw the expected exception |
-> Property |
Make sure that a specific exception is thrown during an IO action. The result is evaluated to NF.
polyQuickCheck :: Name -> ExpQ #
Test a polymorphic property, defaulting all type variables to Integer
.
Invoke as $(
, where polyQuickCheck
'prop)prop
is a property.
Note that just evaluating
in GHCi will seem to
work, but will silently default all type variables to quickCheck
prop()
!
$(
means the same as
polyQuickCheck
'prop)
.
If you want to supply custom arguments to quickCheck
$(monomorphic
'prop)polyQuickCheck
,
you will have to combine quickCheckWith
and monomorphic
yourself.
If you want to use polyQuickCheck
in the same file where you defined the
property, the same scoping problems pop up as in quickCheckAll
:
see the note there about return []
.
polyVerboseCheck :: Name -> ExpQ #
Test a polymorphic property, defaulting all type variables to Integer
.
This is just a convenience function that combines verboseCheck
and monomorphic
.
If you want to use polyVerboseCheck
in the same file where you defined the
property, the same scoping problems pop up as in quickCheckAll
:
see the note there about return []
.
monomorphic :: Name -> ExpQ #
Monomorphise an arbitrary property by defaulting all type variables to Integer
.
For example, if f
has type
then Ord
a => [a] -> [a]$(
has type monomorphic
'f)[
.Integer
] -> [Integer
]
If you want to use monomorphic
in the same file where you defined the
property, the same scoping problems pop up as in quickCheckAll
:
see the note there about return []
.
forAllProperties :: Q Exp #
Test all properties in the current module, using a custom
quickCheck
function. The same caveats as with quickCheckAll
apply.
$
has type forAllProperties
(
.
An example invocation is Property
-> IO
Result
) -> IO
Bool
$
,
which does the same thing as forAllProperties
quickCheckResult
$
.quickCheckAll
forAllProperties
has the same issue with scoping as quickCheckAll
:
see the note there about return []
.
allProperties :: Q Exp #
List all properties in the current module.
$
has type allProperties
[(
.String
, Property
)]
allProperties
has the same issue with scoping as quickCheckAll
:
see the note there about return []
.
quickCheckAll :: Q Exp #
Test all properties in the current module.
The name of the property must begin with prop_
.
Polymorphic properties will be defaulted to Integer
.
Returns True
if all tests succeeded, False
otherwise.
To use quickCheckAll
, add a definition to your module along
the lines of
return [] runTests = $quickCheckAll
and then execute runTests
.
Note: the bizarre return []
in the example above is needed on
GHC 7.8 and later; without it, quickCheckAll
will not be able to find
any of the properties. For the curious, the return []
is a
Template Haskell splice that makes GHC insert the empty list
of declarations at that point in the program; GHC typechecks
everything before the return []
before it starts on the rest
of the module, which means that the later call to quickCheckAll
can see everything that was defined before the return []
. Yikes!
verboseCheckAll :: Q Exp #
Test all properties in the current module.
This is just a convenience function that combines quickCheckAll
and verbose
.
verboseCheckAll
has the same issue with scoping as quickCheckAll
:
see the note there about return []
.
labelledExamples :: Testable prop => prop -> IO () #
Given a property, which must use label
, collect
, classify
or cover
to associate labels with test cases, find an example test case for each possible label.
The example test cases are minimised using shrinking.
For example, suppose we test
and record the number
of times that delete
x xsx
occurs in xs
:
prop_delete :: Int -> [Int] -> Property prop_delete x xs = classify (count x xs == 0) "count x xs == 0" $ classify (count x xs == 1) "count x xs == 1" $ classify (count x xs >= 2) "count x xs >= 2" $ counterexample (show (delete x xs)) $ count x (delete x xs) == max 0 (count x xs-1) where count x xs = length (filter (== x) xs)
labelledExamples
generates three example test cases, one for each label:
>>>
labelledExamples prop_delete
*** Found example of count x xs == 0 0 [] [] *** Found example of count x xs == 1 0 [0] [] *** Found example of count x xs >= 2 5 [5,5] [5] +++ OK, passed 100 tests: 78% count x xs == 0 21% count x xs == 1 1% count x xs >= 2
labelledExamplesWith :: Testable prop => Args -> prop -> IO () #
A variant of labelledExamples
that takes test arguments.
labelledExamplesResult :: Testable prop => prop -> IO Result #
A variant of labelledExamples
that returns a result.
labelledExamplesWithResult :: Testable prop => Args -> prop -> IO Result #
A variant of labelledExamples
that takes test arguments and returns a result.
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
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.
hIsTerminalDevice :: Handle -> IO Bool #
Is the handle connected to a terminal?
On Windows the result of hIsTerminalDevide
might be misleading,
because non-native terminals, such as MinTTY used in MSYS and Cygwin environments,
are implemented via redirection.
Use System.Win32.Types.withHandleToHANDLE System.Win32.MinTTY.isMinTTYHandle
to recognise it. Also consider ansi-terminal
package for crossplatform terminal
support.
error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a #
error
stops execution and displays an error message.
zipWith :: forall a b c (dim :: Nat). (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Tuple dim a -> Tuple dim b -> Tuple dim c #
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #
An infix synonym for fmap
.
The name of this operator is an allusion to $
.
Note the similarities between their types:
($) :: (a -> b) -> a -> b (<$>) :: Functor f => (a -> b) -> f a -> f b
Whereas $
is function application, <$>
is function
application lifted over a Functor
.
Examples
Convert from a
to a Maybe
Int
using Maybe
String
show
:
>>>
show <$> Nothing
Nothing>>>
show <$> Just 3
Just "3"
Convert from an
to an
Either
Int
Int
Either
Int
String
using show
:
>>>
show <$> Left 17
Left 17>>>
show <$> Right 17
Right "17"
Double each element of a list:
>>>
(*2) <$> [1,2,3]
[2,4,6]
Apply even
to the second element of a pair:
>>>
even <$> (2,2)
(2,True)
hGetContents :: Handle -> IO String #
Computation hGetContents
hdl
returns the list of characters
corresponding to the unread portion of the channel or file managed
by hdl
, which is put into an intermediate state, semi-closed.
In this state, hdl
is effectively closed,
but items are read from hdl
on demand and accumulated in a special
list returned by hGetContents
hdl
.
Any operation that fails because a handle is closed,
also fails if a handle is semi-closed. The only exception is
hClose
. A semi-closed handle becomes closed:
- if
hClose
is applied to it; - if an I/O error occurs when reading an item from the handle;
- or once the entire contents of the handle has been read.
Once a semi-closed handle becomes closed, the contents of the associated list becomes fixed. The contents of this final list is only partially specified: it will contain at least all the items of the stream that were evaluated prior to the handle becoming closed.
Any I/O errors encountered while a handle is semi-closed are simply discarded.
This operation may fail with:
isEOFError
if the end of file has been reached.
uncurry :: (a -> b -> c) -> (a, b) -> c #
uncurry
converts a curried function to a function on pairs.
Examples
>>>
uncurry (+) (1,2)
3
>>>
uncurry ($) (show, 1)
"1"
>>>
map (uncurry max) [(1,2), (3,4), (6,8)]
[2,4,8]
length :: ByteString -> BYTES Int #
head :: HasCallStack => [a] -> a #
O(1). Extract the first element of a list, which must be non-empty.
>>>
head [1, 2, 3]
1>>>
head [1..]
1>>>
head []
*** Exception: Prelude.head: empty list
WARNING: This function is partial. You can use case-matching, uncons
or
listToMaybe
instead.
forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b) #
forever :: Applicative f => f a -> f b #
Repeat an action indefinitely.
Examples
A common use of forever
is to process input from network sockets,
Handle
s, and channels
(e.g. MVar
and
Chan
).
For example, here is how we might implement an echo
server, using
forever
both to listen for client connections on a network socket
and to echo client input on client connection handles:
echoServer :: Socket -> IO () echoServer socket =forever
$ do client <- accept socketforkFinally
(echo client) (\_ -> hClose client) where echo :: Handle -> IO () echo client =forever
$ hGetLine client >>= hPutStrLn client
Note that "forever" isn't necessarily non-terminating.
If the action is in a
and short-circuits after some number of iterations.
then MonadPlus
actually returns forever
mzero
, effectively short-circuiting its caller.
utf8 :: TextEncoding #
The UTF-8 Unicode encoding
mkTextEncoding :: String -> IO TextEncoding #
Look up the named Unicode encoding. May fail with
isDoesNotExistError
if the encoding is unknown
The set of known encodings is system-dependent, but includes at least:
UTF-8
UTF-16
,UTF-16BE
,UTF-16LE
UTF-32
,UTF-32BE
,UTF-32LE
There is additional notation (borrowed from GNU iconv) for specifying how illegal characters are handled:
- a suffix of
//IGNORE
, e.g.UTF-8//IGNORE
, will cause all illegal sequences on input to be ignored, and on output will drop all code points that have no representation in the target encoding. - a suffix of
//TRANSLIT
will choose a replacement character for illegal sequences or code points. - a suffix of
//ROUNDTRIP
will use a PEP383-style escape mechanism to represent any invalid bytes in the input as Unicode codepoints (specifically, as lone surrogates, which are normally invalid in UTF-32). Upon output, these special codepoints are detected and turned back into the corresponding original byte.
In theory, this mechanism allows arbitrary data to be roundtripped via
a String
with no loss of data. In practice, there are two limitations
to be aware of:
- This only stands a chance of working for an encoding which is an ASCII superset, as for security reasons we refuse to escape any bytes smaller than 128. Many encodings of interest are ASCII supersets (in particular, you can assume that the locale encoding is an ASCII superset) but many (such as UTF-16) are not.
- If the underlying encoding is not itself roundtrippable, this mechanism can fail. Roundtrippable encodings are those which have an injective mapping into Unicode. Almost all encodings meet this criteria, but some do not. Notably, Shift-JIS (CP932) and Big5 contain several different encodings of the same Unicode codepoint.
On Windows, you can access supported code pages with the prefix
CP
; for example, "CP1250"
.
hSeek :: Handle -> SeekMode -> Integer -> IO () #
Computation hSeek
hdl mode i
sets the position of handle
hdl
depending on mode
.
The offset i
is given in terms of 8-bit bytes.
If hdl
is block- or line-buffered, then seeking to a position which is not
in the current buffer will first cause any items in the output buffer to be
written to the device, and then cause the input buffer to be discarded.
Some handles may not be seekable (see hIsSeekable
), or only support a
subset of the possible positioning operations (for instance, it may only
be possible to seek to the end of a tape, or to a positive offset from
the beginning or current position).
It is not possible to set a negative I/O position, or for
a physical file, an I/O position beyond the current end-of-file.
This operation may fail with:
isIllegalOperationError
if the Handle is not seekable, or does not support the requested seek mode.isPermissionError
if a system resource limit would be exceeded.
The action hFlush
hdl
causes any items buffered for output
in handle hdl
to be sent immediately to the operating system.
This operation may fail with:
isFullError
if the device is full;isPermissionError
if a system resource limit would be exceeded. It is unspecified whether the characters in the buffer are discarded or retained under these circumstances.
hLookAhead :: Handle -> IO Char #
Computation hLookAhead
returns the next character from the handle
without removing it from the input buffer, blocking until a character
is available.
This operation may fail with:
isEOFError
if the end of file has been reached.
fixIO :: (a -> IO a) -> IO a #
The implementation of mfix
for IO
. If the function
passed to fixIO
inspects its argument, the resulting action will throw
FixIOException
.
readFile' :: FilePath -> IO String #
The readFile'
function reads a file and
returns the contents of the file as a string.
The file is fully read before being returned, as with getContents'
.
Since: base-4.15.0.0
writeFile :: FilePath -> String -> IO () #
The computation writeFile
file str
function writes the string str
,
to the file file
.
Computation hClose
hdl
makes handle hdl
closed. Before the
computation finishes, if hdl
is writable its buffer is flushed as
for hFlush
.
Performing hClose
on a handle that has already been closed has no effect;
doing so is not an error. All other operations on a closed handle will fail.
If hClose
fails for any reason, any further operations (apart from
hClose
) on the handle will still fail as if hdl
had been successfully
closed.
hClose
is an interruptible operation in the sense described in
Control.Exception. If hClose
is interrupted by an asynchronous
exception in the process of flushing its buffers, then the I/O device
(e.g., file) will be closed anyway.
hSetBinaryMode :: Handle -> Bool -> IO () #
Select binary mode (True
) or text mode (False
) on a open handle.
(See also openBinaryFile
.)
This has the same effect as calling hSetEncoding
with char8
, together
with hSetNewlineMode
with noNewlineTranslation
.
localeEncoding :: TextEncoding #
The Unicode encoding of the current locale
This is the initial locale encoding: if it has been subsequently changed by
setLocaleEncoding
this value will not reflect that change.
filter :: (a -> Bool) -> [a] -> [a] #
O(n). filter
, applied to a predicate and a list, returns
the list of those elements that satisfy the predicate; i.e.,
filter p xs = [ x | x <- xs, p x]
>>>
filter odd [1, 2, 3]
[1,3]
hGetBuf :: Handle -> Ptr a -> Int -> IO Int #
hGetBuf
hdl buf count
reads data from the handle hdl
into the buffer buf
until either EOF is reached or
count
8-bit bytes have been read.
It returns the number of bytes actually read. This may be zero if
EOF was reached before any data was read (or if count
is zero).
hGetBuf
never raises an EOF exception, instead it returns a value
smaller than count
.
If the handle is a pipe or socket, and the writing end
is closed, hGetBuf
will behave as if EOF was reached.
hGetBuf
ignores the prevailing TextEncoding
and NewlineMode
on the Handle
, and reads bytes directly.
hPutBuf :: Handle -> Ptr a -> Int -> IO () #
hPutBuf
hdl buf count
writes count
8-bit bytes from the
buffer buf
to the handle hdl
. It returns ().
hPutBuf
ignores any text encoding that applies to the Handle
,
writing the bytes directly to the underlying file or device.
hPutBuf
ignores the prevailing TextEncoding
and
NewlineMode
on the Handle
, and writes bytes directly.
This operation may fail with:
ResourceVanished
if the handle is a pipe or socket, and the reading end is closed. (If this is a POSIX system, and the program has not asked to ignore SIGPIPE, then a SIGPIPE may be delivered instead, whose default action is to terminate the program).
hWaitForInput :: Handle -> Int -> IO Bool #
Computation hWaitForInput
hdl t
waits until input is available on handle hdl
.
It returns True
as soon as input is available on hdl
,
or False
if no input is available within t
milliseconds. Note that
hWaitForInput
waits until one or more full characters are available,
which means that it needs to do decoding, and hence may fail
with a decoding error.
If t
is less than zero, then hWaitForInput
waits indefinitely.
This operation may fail with:
isEOFError
if the end of file has been reached.- a decoding error, if the input begins with an invalid byte sequence in this Handle's encoding.
NOTE for GHC users: unless you use the -threaded
flag,
hWaitForInput hdl t
where t >= 0
will block all other Haskell
threads for the duration of the call. It behaves like a
safe
foreign call in this respect.
cycle :: HasCallStack => [a] -> [a] #
cycle
ties a finite list into a circular one, or equivalently,
the infinite repetition of the original list. It is the identity
on infinite lists.
>>>
cycle []
*** Exception: Prelude.cycle: empty list>>>
cycle [42]
[42,42,42,42,42,42,42,42,42,42...>>>
cycle [2, 5, 7]
[2,5,7,2,5,7,2,5,7,2,5,7...
seq :: forall {r :: RuntimeRep} a (b :: TYPE r). a -> b -> b infixr 0 #
The value of
is bottom if seq
a ba
is bottom, and
otherwise equal to b
. In other words, it evaluates the first
argument a
to weak head normal form (WHNF). seq
is usually
introduced to improve performance by avoiding unneeded laziness.
A note on evaluation order: the expression
does
not guarantee that seq
a ba
will be evaluated before b
.
The only guarantee given by seq
is that the both a
and b
will be evaluated before seq
returns a value.
In particular, this means that b
may be evaluated before
a
. If you need to guarantee a specific order of evaluation,
you must use the function pseq
from the "parallel" package.
concat :: Foldable t => t [a] -> [a] #
The concatenation of all the elements of a container of lists.
Examples
Basic usage:
>>>
concat (Just [1, 2, 3])
[1,2,3]
>>>
concat (Left 42)
[]
>>>
concat [[1, 2, 3], [4, 5], [6], []]
[1,2,3,4,5,6]
zip :: [a] -> [b] -> [(a, b)] #
O(min. zip
takes two lists and returns a list of
corresponding pairs.
>>>
zip [1, 2] ['a', 'b']
[(1,'a'),(2,'b')]
If one input list is shorter than the other, excess elements of the longer list are discarded, even if one of the lists is infinite:
>>>
zip [1] ['a', 'b']
[(1,'a')]>>>
zip [1, 2] ['a']
[(1,'a')]>>>
zip [] [1..]
[]>>>
zip [1..] []
[]
zip
is right-lazy:
>>>
zip [] undefined
[]>>>
zip undefined []
*** Exception: Prelude.undefined ...
zip
is capable of list fusion, but it is restricted to its
first list argument and its resulting list.
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]])
guard :: Alternative f => Bool -> f () #
Conditional failure of Alternative
computations. Defined by
guard True =pure
() guard False =empty
Examples
Common uses of guard
include conditionally signaling an error in
an error monad and conditionally rejecting the current choice in an
Alternative
-based parser.
As an example of signaling an error in the error monad Maybe
,
consider a safe division function safeDiv x y
that returns
Nothing
when the denominator y
is zero and
otherwise. For example:Just
(x `div`
y)
>>>
safeDiv 4 0
Nothing
>>>
safeDiv 4 2
Just 2
A definition of safeDiv
using guards, but not guard
:
safeDiv :: Int -> Int -> Maybe Int safeDiv x y | y /= 0 = Just (x `div` y) | otherwise = Nothing
A definition of safeDiv
using guard
and Monad
do
-notation:
safeDiv :: Int -> Int -> Maybe Int safeDiv x y = do guard (y /= 0) return (x `div` y)
errorWithoutStackTrace :: forall (r :: RuntimeRep) (a :: TYPE r). [Char] -> a #
A variant of error
that does not produce a stack trace.
Since: base-4.9.0.0
undefined :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => a #
(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 #
A variant of <*>
with the arguments reversed.
liftA :: Applicative f => (a -> b) -> f a -> f b #
Lift a function to actions.
Equivalent to Functor's fmap
but implemented using only Applicative
's methods:
liftA
f a = pure
f <*>
a
As such this function may be used to implement a Functor
instance from an Applicative
one.
Examples
Using the Applicative instance for Lists:
>>>
liftA (+1) [1, 2]
[2,3]
Or the Applicative instance for Maybe
>>>
liftA (+1) (Just 3)
Just 4
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d #
Lift a ternary function to actions.
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 #
Same as >>=
, but with the arguments interchanged.
when :: Applicative f => Bool -> f () -> f () #
Conditional execution of Applicative
expressions. For example,
when debug (putStrLn "Debugging")
will output the string Debugging
if the Boolean value debug
is True
, and otherwise do nothing.
liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r #
Promote a function to a monad, scanning the monadic arguments from left to right. For example,
liftM2 (+) [0,1] [0,2] = [0,2,1,3] liftM2 (+) (Just 1) Nothing = Nothing
liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r #
Promote a function to a monad, scanning the monadic arguments from
left to right (cf. liftM2
).
liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r #
Promote a function to a monad, scanning the monadic arguments from
left to right (cf. liftM2
).
liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r #
Promote a function to a monad, scanning the monadic arguments from
left to right (cf. liftM2
).
const x y
always evaluates to x
, ignoring its second argument.
>>>
const 42 "hello"
42
>>>
map (const 42) [0..3]
[42,42,42,42]
flip :: (a -> b -> c) -> b -> a -> c #
takes its (first) two arguments in the reverse order of flip
ff
.
>>>
flip (++) "hello" "world"
"worldhello"
($!) :: forall (r :: RuntimeRep) a (b :: TYPE r). (a -> b) -> a -> b infixr 0 #
Strict (call-by-value) application operator. It takes a function and an argument, evaluates the argument to weak head normal form (WHNF), then calls the function with that value.
until :: (a -> Bool) -> (a -> a) -> a -> a #
yields the result of applying until
p ff
until p
holds.
maybe :: b -> (a -> b) -> Maybe a -> b #
The maybe
function takes a default value, a function, and a Maybe
value. If the Maybe
value is Nothing
, the function returns the
default value. Otherwise, it applies the function to the value inside
the Just
and returns the result.
Examples
Basic usage:
>>>
maybe False odd (Just 3)
True
>>>
maybe False odd Nothing
False
Read an integer from a string using readMaybe
. If we succeed,
return twice the integer; that is, apply (*2)
to it. If instead
we fail to parse an integer, return 0
by default:
>>>
import Text.Read ( readMaybe )
>>>
maybe 0 (*2) (readMaybe "5")
10>>>
maybe 0 (*2) (readMaybe "")
0
Apply show
to a Maybe Int
. If we have Just n
, we want to show
the underlying Int
n
. But if we have Nothing
, we return the
empty string instead of (for example) "Nothing":
>>>
maybe "" show (Just 5)
"5">>>
maybe "" show Nothing
""
fromJust :: HasCallStack => Maybe a -> a #
The fromJust
function extracts the element out of a Just
and
throws an error if its argument is Nothing
.
Examples
Basic usage:
>>>
fromJust (Just 1)
1
>>>
2 * (fromJust (Just 10))
20
>>>
2 * (fromJust Nothing)
*** Exception: Maybe.fromJust: Nothing ...
WARNING: This function is partial. You can use case-matching instead.
fromMaybe :: a -> Maybe a -> a #
The fromMaybe
function takes a default value and a Maybe
value. If the Maybe
is Nothing
, it returns the default value;
otherwise, it returns the value contained in the Maybe
.
Examples
Basic usage:
>>>
fromMaybe "" (Just "Hello, World!")
"Hello, World!"
>>>
fromMaybe "" Nothing
""
Read an integer from a string using readMaybe
. If we fail to
parse an integer, we want to return 0
by default:
>>>
import Text.Read ( readMaybe )
>>>
fromMaybe 0 (readMaybe "5")
5>>>
fromMaybe 0 (readMaybe "")
0
maybeToList :: Maybe a -> [a] #
The maybeToList
function returns an empty list when given
Nothing
or a singleton list when given Just
.
Examples
Basic usage:
>>>
maybeToList (Just 7)
[7]
>>>
maybeToList Nothing
[]
One can use maybeToList
to avoid pattern matching when combined
with a function that (safely) works on lists:
>>>
import Text.Read ( readMaybe )
>>>
sum $ maybeToList (readMaybe "3")
3>>>
sum $ maybeToList (readMaybe "")
0
listToMaybe :: [a] -> Maybe a #
The listToMaybe
function returns Nothing
on an empty list
or
where Just
aa
is the first element of the list.
Examples
Basic usage:
>>>
listToMaybe []
Nothing
>>>
listToMaybe [9]
Just 9
>>>
listToMaybe [1,2,3]
Just 1
Composing maybeToList
with listToMaybe
should be the identity
on singleton/empty lists:
>>>
maybeToList $ listToMaybe [5]
[5]>>>
maybeToList $ listToMaybe []
[]
But not on lists with more than one element:
>>>
maybeToList $ listToMaybe [1,2,3]
[1]
catMaybes :: [Maybe a] -> [a] #
The catMaybes
function takes a list of Maybe
s and returns
a list of all the Just
values.
Examples
Basic usage:
>>>
catMaybes [Just 1, Nothing, Just 3]
[1,3]
When constructing a list of Maybe
values, catMaybes
can be used
to return all of the "success" results (if the list is the result
of a map
, then mapMaybe
would be more appropriate):
>>>
import Text.Read ( readMaybe )
>>>
[readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
[Just 1,Nothing,Just 3]>>>
catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
[1,3]
mapMaybe :: (a -> Maybe b) -> [a] -> [b] #
The mapMaybe
function is a version of map
which can throw
out elements. In particular, the functional argument returns
something of type
. If this is Maybe
bNothing
, no element
is added on to the result list. If it is
, then Just
bb
is
included in the result list.
Examples
Using
is a shortcut for mapMaybe
f x
in most cases:catMaybes
$ map
f x
>>>
import Text.Read ( readMaybe )
>>>
let readMaybeInt = readMaybe :: String -> Maybe Int
>>>
mapMaybe readMaybeInt ["1", "Foo", "3"]
[1,3]>>>
catMaybes $ map readMaybeInt ["1", "Foo", "3"]
[1,3]
If we map the Just
constructor, the entire list should be returned:
>>>
mapMaybe Just [1,2,3]
[1,2,3]
tail :: HasCallStack => [a] -> [a] #
\mathcal{O}(1). Extract the elements after the head of a list, which must be non-empty.
>>>
tail [1, 2, 3]
[2,3]>>>
tail [1]
[]>>>
tail []
*** Exception: Prelude.tail: empty list
WARNING: This function is partial. You can use case-matching or uncons
instead.
last :: HasCallStack => [a] -> a #
\mathcal{O}(n). Extract the last element of a list, which must be finite and non-empty.
>>>
last [1, 2, 3]
3>>>
last [1..]
* Hangs forever *>>>
last []
*** Exception: Prelude.last: empty list
WARNING: This function is partial. You can use reverse
with case-matching,
uncons
or listToMaybe
instead.
init :: HasCallStack => [a] -> [a] #
scanl :: (b -> a -> b) -> b -> [a] -> [b] #
\mathcal{O}(n). scanl
is similar to foldl
, but returns a list of
successive reduced values from the left:
scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
Note that
last (scanl f z xs) == foldl f z xs
>>>
scanl (+) 0 [1..4]
[0,1,3,6,10]>>>
scanl (+) 42 []
[42]>>>
scanl (-) 100 [1..4]
[100,99,97,94,90]>>>
scanl (\reversedString nextChar -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']
["foo","afoo","bafoo","cbafoo","dcbafoo"]>>>
scanl (+) 0 [1..]
* Hangs forever *
scanl1 :: (a -> a -> a) -> [a] -> [a] #
\mathcal{O}(n). scanl1
is a variant of scanl
that has no starting
value argument:
scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
>>>
scanl1 (+) [1..4]
[1,3,6,10]>>>
scanl1 (+) []
[]>>>
scanl1 (-) [1..4]
[1,-1,-4,-8]>>>
scanl1 (&&) [True, False, True, True]
[True,False,False,False]>>>
scanl1 (||) [False, False, True, True]
[False,False,True,True]>>>
scanl1 (+) [1..]
* Hangs forever *
scanr :: (a -> b -> b) -> b -> [a] -> [b] #
\mathcal{O}(n). scanr
is the right-to-left dual of scanl
. Note that the order of parameters on the accumulating function are reversed compared to scanl
.
Also note that
head (scanr f z xs) == foldr f z xs.
>>>
scanr (+) 0 [1..4]
[10,9,7,4,0]>>>
scanr (+) 42 []
[42]>>>
scanr (-) 100 [1..4]
[98,-97,99,-96,100]>>>
scanr (\nextChar reversedString -> nextChar : reversedString) "foo" ['a', 'b', 'c', 'd']
["abcdfoo","bcdfoo","cdfoo","dfoo","foo"]>>>
force $ scanr (+) 0 [1..]
*** Exception: stack overflow
scanr1 :: (a -> a -> a) -> [a] -> [a] #
\mathcal{O}(n). scanr1
is a variant of scanr
that has no starting
value argument.
>>>
scanr1 (+) [1..4]
[10,9,7,4]>>>
scanr1 (+) []
[]>>>
scanr1 (-) [1..4]
[-2,3,-1,4]>>>
scanr1 (&&) [True, False, True, True]
[False,False,True,True]>>>
scanr1 (||) [True, True, False, False]
[True,True,False,False]>>>
force $ scanr1 (+) [1..]
*** Exception: stack overflow
iterate :: (a -> a) -> a -> [a] #
iterate
f x
returns an infinite list of repeated applications
of f
to x
:
iterate f x == [x, f x, f (f x), ...]
Note that iterate
is lazy, potentially leading to thunk build-up if
the consumer doesn't force each iterate. See iterate'
for a strict
variant of this function.
>>>
take 10 $ iterate not True
[True,False,True,False...>>>
take 10 $ iterate (+3) 42
[42,45,48,51,54,57,60,63...
repeat
x
is an infinite list, with x
the value of every element.
>>>
repeat 17
[17,17,17,17,17,17,17,17,17...
replicate :: LengthUnit l => l -> Word8 -> ByteString #
takeWhile :: (a -> Bool) -> [a] -> [a] #
takeWhile
, applied to a predicate p
and a list xs
, returns the
longest prefix (possibly empty) of xs
of elements that satisfy p
.
>>>
takeWhile (< 3) [1,2,3,4,1,2,3,4]
[1,2]>>>
takeWhile (< 9) [1,2,3]
[1,2,3]>>>
takeWhile (< 0) [1,2,3]
[]
take
n
, applied to a list xs
, returns the prefix of xs
of length n
, or xs
itself if n >=
.length
xs
>>>
take 5 "Hello World!"
"Hello">>>
take 3 [1,2,3,4,5]
[1,2,3]>>>
take 3 [1,2]
[1,2]>>>
take 3 []
[]>>>
take (-1) [1,2]
[]>>>
take 0 [1,2]
[]
It is an instance of the more general genericTake
,
in which n
may be of any integral type.
drop
n xs
returns the suffix of xs
after the first n
elements, or []
if n >=
.length
xs
>>>
drop 6 "Hello World!"
"World!">>>
drop 3 [1,2,3,4,5]
[4,5]>>>
drop 3 [1,2]
[]>>>
drop 3 []
[]>>>
drop (-1) [1,2]
[1,2]>>>
drop 0 [1,2]
[1,2]
It is an instance of the more general genericDrop
,
in which n
may be of any integral type.
splitAt :: Int -> [a] -> ([a], [a]) #
splitAt
n xs
returns a tuple where first element is xs
prefix of
length n
and second element is the remainder of the list:
>>>
splitAt 6 "Hello World!"
("Hello ","World!")>>>
splitAt 3 [1,2,3,4,5]
([1,2,3],[4,5])>>>
splitAt 1 [1,2,3]
([1],[2,3])>>>
splitAt 3 [1,2,3]
([1,2,3],[])>>>
splitAt 4 [1,2,3]
([1,2,3],[])>>>
splitAt 0 [1,2,3]
([],[1,2,3])>>>
splitAt (-1) [1,2,3]
([],[1,2,3])
It is equivalent to (
when take
n xs, drop
n xs)n
is not _|_
(splitAt _|_ xs = _|_
).
splitAt
is an instance of the more general genericSplitAt
,
in which n
may be of any integral type.
span :: (a -> Bool) -> [a] -> ([a], [a]) #
span
, applied to a predicate p
and a list xs
, returns a tuple where
first element is longest prefix (possibly empty) of xs
of elements that
satisfy p
and second element is the remainder of the list:
>>>
span (< 3) [1,2,3,4,1,2,3,4]
([1,2],[3,4,1,2,3,4])>>>
span (< 9) [1,2,3]
([1,2,3],[])>>>
span (< 0) [1,2,3]
([],[1,2,3])
break :: (a -> Bool) -> [a] -> ([a], [a]) #
break
, applied to a predicate p
and a list xs
, returns a tuple where
first element is longest prefix (possibly empty) of xs
of elements that
do not satisfy p
and second element is the remainder of the list:
>>>
break (> 3) [1,2,3,4,1,2,3,4]
([1,2,3],[4,1,2,3,4])>>>
break (< 9) [1,2,3]
([],[1,2,3])>>>
break (> 9) [1,2,3]
([1,2,3],[])
reverse
xs
returns the elements of xs
in reverse order.
xs
must be finite.
>>>
reverse []
[]>>>
reverse [42]
[42]>>>
reverse [2,5,7]
[7,5,2]>>>
reverse [1..]
* Hangs forever *
and :: Foldable t => t Bool -> Bool #
and
returns the conjunction of a container of Bools. For the
result to be True
, the container must be finite; False
, however,
results from a False
value finitely far from the left end.
Examples
Basic usage:
>>>
and []
True
>>>
and [True]
True
>>>
and [False]
False
>>>
and [True, True, False]
False
>>>
and (False : repeat True) -- Infinite list [False,True,True,True,...
False
>>>
and (repeat True)
* Hangs forever *
or :: Foldable t => t Bool -> Bool #
or
returns the disjunction of a container of Bools. For the
result to be False
, the container must be finite; True
, however,
results from a True
value finitely far from the left end.
Examples
Basic usage:
>>>
or []
False
>>>
or [True]
True
>>>
or [False]
False
>>>
or [True, True, False]
True
>>>
or (True : repeat False) -- Infinite list [True,False,False,False,...
True
>>>
or (repeat False)
* Hangs forever *
any :: Foldable t => (a -> Bool) -> t a -> Bool #
Determines whether any element of the structure satisfies the predicate.
Examples
Basic usage:
>>>
any (> 3) []
False
>>>
any (> 3) [1,2]
False
>>>
any (> 3) [1,2,3,4,5]
True
>>>
any (> 3) [1..]
True
>>>
any (> 3) [0, -1..]
* Hangs forever *
all :: Foldable t => (a -> Bool) -> t a -> Bool #
Determines whether all elements of the structure satisfy the predicate.
Examples
Basic usage:
>>>
all (> 3) []
True
>>>
all (> 3) [1,2]
False
>>>
all (> 3) [1,2,3,4,5]
False
>>>
all (> 3) [1..]
False
>>>
all (> 3) [4..]
* Hangs forever *
notElem :: (Foldable t, Eq a) => a -> t a -> Bool infix 4 #
notElem
is the negation of elem
.
Examples
Basic usage:
>>>
3 `notElem` []
True
>>>
3 `notElem` [1,2]
True
>>>
3 `notElem` [1,2,3,4,5]
False
For infinite structures, notElem
terminates if the value exists at a
finite distance from the left side of the structure:
>>>
3 `notElem` [1..]
False
>>>
3 `notElem` ([4..] ++ [3])
* Hangs forever *
concatMap :: Foldable t => (a -> [b]) -> t a -> [b] #
Map a function over all the elements of a container and concatenate the resulting lists.
Examples
Basic usage:
>>>
concatMap (take 3) [[1..], [10..], [100..], [1000..]]
[1,2,3,10,11,12,100,101,102,1000,1001,1002]
>>>
concatMap (take 3) (Just [1..])
[1,2,3]
(!!) :: HasCallStack => [a] -> Int -> a infixl 9 #
List index (subscript) operator, starting from 0.
It is an instance of the more general genericIndex
,
which takes an index of any integral type.
>>>
['a', 'b', 'c'] !! 0
'a'>>>
['a', 'b', 'c'] !! 2
'c'>>>
['a', 'b', 'c'] !! 3
*** Exception: Prelude.!!: index too large>>>
['a', 'b', 'c'] !! (-1)
*** Exception: Prelude.!!: negative index
WARNING: This function is partial. You can use atMay instead.
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] #
The zipWith3
function takes a function which combines three
elements, as well as three lists and returns a list of the function applied
to corresponding elements, analogous to zipWith
.
It is capable of list fusion, but it is restricted to its
first list argument and its resulting list.
zipWith3 (,,) xs ys zs == zip3 xs ys zs zipWith3 f [x1,x2,x3..] [y1,y2,y3..] [z1,z2,z3..] == [f x1 y1 z1, f x2 y2 z2, f x3 y3 z3..]
unzip :: [(a, b)] -> ([a], [b]) #
unzip
transforms a list of pairs into a list of first components
and a list of second components.
>>>
unzip []
([],[])>>>
unzip [(1, 'a'), (2, 'b')]
([1,2],"ab")
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.
(^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8 #
raise a number to an integral power
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 minBound
0
or
) for such types.minBound
lcm :: Integral a => a -> a -> a #
is the smallest positive integer that both lcm
x yx
and y
divide.
bitDefault :: (Bits a, Num a) => Int -> a #
testBitDefault :: (Bits a, Num a) => a -> Int -> Bool #
Default implementation for testBit
.
Note that: testBitDefault x i = (x .&. bit i) /= 0
Since: base-4.6.0.0
popCountDefault :: (Bits a, Num a) => a -> Int #
Default implementation for popCount
.
This implementation is intentionally naive. Instances are expected to provide an optimized implementation for their size.
Since: base-4.6.0.0
toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b #
Attempt to convert an Integral
type a
to an Integral
type b
using
the size of the types as measured by Bits
methods.
A simpler version of this function is:
toIntegral :: (Integral a, Integral b) => a -> Maybe b toIntegral x | toInteger x == toInteger y = Just y | otherwise = Nothing where y = fromIntegral x
This version requires going through Integer
, which can be inefficient.
However, toIntegralSized
is optimized to allow GHC to statically determine
the relative type sizes (as measured by bitSizeMaybe
and isSigned
) and
avoid going through Integer
for many types. (The implementation uses
fromIntegral
, which is itself optimized with rules for base
types but may
go through Integer
for some type pairs.)
Since: base-4.8.0.0
byteSwap16 :: Word16 -> Word16 #
Reverse order of bytes in Word16
.
Since: base-4.7.0.0
byteSwap32 :: Word32 -> Word32 #
Reverse order of bytes in Word32
.
Since: base-4.7.0.0
byteSwap64 :: Word64 -> Word64 #
Reverse order of bytes in Word64
.
Since: base-4.7.0.0
bitReverse8 :: Word8 -> Word8 #
Reverse the order of the bits in a Word8
.
Since: base-4.14.0.0
bitReverse16 :: Word16 -> Word16 #
Reverse the order of the bits in a Word16
.
Since: base-4.14.0.0
bitReverse32 :: Word32 -> Word32 #
Reverse the order of the bits in a Word32
.
Since: base-4.14.0.0
bitReverse64 :: Word64 -> Word64 #
Reverse the order of the bits in a Word64
.
Since: base-4.14.0.0
fill :: (Pointer ptr, LengthUnit len, ByteSource src) => len -> src -> ptr a -> IO (FillResult src) #
void :: Functor f => f a -> f () #
discards or ignores the result of evaluation, such
as the return value of an void
valueIO
action.
Examples
Replace the contents of a
with unit:Maybe
Int
>>>
void Nothing
Nothing>>>
void (Just 3)
Just ()
Replace the contents of an
with unit, resulting in an Either
Int
Int
:Either
Int
()
>>>
void (Left 8675309)
Left 8675309>>>
void (Right 8675309)
Right ()
Replace every element of a list with unit:
>>>
void [1,2,3]
[(),(),()]
Replace the second element of a pair with unit:
>>>
void (1,2)
(1,())
Discard the result of an IO
action:
>>>
mapM print [1,2]
1 2 [(),()]>>>
void $ mapM print [1,2]
1 2
optional :: Alternative f => f a -> f (Maybe a) #
One or none.
It is useful for modelling any computation that is allowed to fail.
Examples
Using the Alternative
instance of Control.Monad.Except, the following functions:
>>>
import Control.Monad.Except
>>>
canFail = throwError "it failed" :: Except String Int
>>>
final = return 42 :: Except String Int
Can be combined by allowing the first function to fail:
>>>
runExcept $ canFail *> final
Left "it failed">>>
runExcept $ optional canFail *> final
Right 42
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
either :: (a -> c) -> (b -> c) -> Either a b -> c #
Case analysis for the Either
type.
If the value is
, apply the first function to Left
aa
;
if it is
, apply the second function to Right
bb
.
Examples
We create two values of type
, one using the
Either
String
Int
Left
constructor and another using the Right
constructor. Then
we apply "either" the length
function (if we have a String
)
or the "times-two" function (if we have an Int
):
>>>
let s = Left "foo" :: Either String Int
>>>
let n = Right 3 :: Either String Int
>>>
either length (*2) s
3>>>
either length (*2) n
6
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" :: Int
123
>>>
read "hello" :: Int
*** Exception: Prelude.read: no parse
oneBits :: FiniteBits a => a #
A more concise version of complement zeroBits
.
>>>
complement (zeroBits :: Word) == (oneBits :: Word)
True
>>>
complement (oneBits :: Word) == (zeroBits :: Word)
True
Note
The constraint on oneBits
is arguably too strong. However, as some types
(such as Natural
) have undefined complement
, this is the only safe
choice.
Since: base-4.16
(!>>.) :: Bits a => a -> Int -> a infixl 8 #
Infix version of unsafeShiftR
.
Since: base-4.17
(!<<.) :: Bits a => a -> Int -> a infixl 8 #
Infix version of unsafeShiftL
.
Since: base-4.17
asProxyTypeOf :: a -> proxy a -> a #
asProxyTypeOf
is a type-restricted version of const
.
It is usually used as an infix operator, and its typing forces its first
argument (which is usually overloaded) to have the same type as the tag
of the second.
>>>
import Data.Word
>>>
:type asProxyTypeOf 123 (Proxy :: Proxy Word8)
asProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8
Note the lower-case proxy
in the definition. This allows any type
constructor with just one argument to be passed to the function, for example
we could also write
>>>
import Data.Word
>>>
:type asProxyTypeOf 123 (Just (undefined :: Word8))
asProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8
sequence_ :: (Foldable t, Monad m) => t (m a) -> m () #
Evaluate each monadic action in the structure from left to right,
and ignore the results. For a version that doesn't ignore the
results see sequence
.
sequence_
is just like sequenceA_
, but specialised to monadic
actions.
asum :: (Foldable t, Alternative f) => t (f a) -> f a #
The sum of a collection of actions using (<|>)
, generalizing concat
.
asum
is just like msum
, but generalised to Alternative
.
Examples
Basic usage:
>>>
asum [Just "Hello", Nothing, Just "World"]
Just "Hello"
Splits the argument into a list of lines stripped of their terminating
\n
characters. The \n
terminator is optional in a final non-empty
line of the argument string.
For example:
>>>
lines "" -- empty input contains no lines
[]>>>
lines "\n" -- single empty line
[""]>>>
lines "one" -- single unterminated line
["one"]>>>
lines "one\n" -- single non-empty line
["one"]>>>
lines "one\n\n" -- second line is empty
["one",""]>>>
lines "one\ntwo" -- second line is unterminated
["one","two"]>>>
lines "one\ntwo\n" -- two non-empty lines
["one","two"]
When the argument string is empty, or ends in a \n
character, it can be
recovered by passing the result of lines
to the unlines
function.
Otherwise, unlines
appends the missing terminating \n
. This makes
unlines . lines
idempotent:
(unlines . lines) . (unlines . lines) = (unlines . lines)
userError :: String -> IOError #
Construct an IOException
value with a string describing the error.
The fail
method of the IO
instance of the Monad
class raises a
userError
, thus:
instance Monad IO where ... fail s = ioError (userError s)
write :: EndianStore a => a -> WriteTo #
universalNewlineMode :: NewlineMode #
Map '\r\n'
into '\n'
on input, and '\n'
to the native newline
representation on output. This mode can be used on any platform, and
works with text files using any newline convention. The downside is
that readFile >>= writeFile
might yield a different file.
universalNewlineMode = NewlineMode { inputNL = CRLF, outputNL = nativeNewline }
nativeNewlineMode :: NewlineMode #
Use the native newline representation on both input and output
nativeNewlineMode = NewlineMode { inputNL = nativeNewline outputNL = nativeNewline }
noNewlineTranslation :: NewlineMode #
Do no newline translation at all.
noNewlineTranslation = NewlineMode { inputNL = LF, outputNL = LF }
The UTF-8 Unicode encoding, with a byte-order-mark (BOM; the byte
sequence 0xEF 0xBB 0xBF). This encoding behaves like utf8
,
except that on input, the BOM sequence is ignored at the beginning
of the stream, and on output, the BOM sequence is prepended.
The byte-order-mark is strictly unnecessary in UTF-8, but is sometimes used to identify the encoding of a file.
utf32 :: TextEncoding #
The UTF-32 Unicode encoding (a byte-order-mark should be used to indicate endianness).
utf32be :: TextEncoding #
The UTF-32 Unicode encoding (big-endian)
utf32le :: TextEncoding #
The UTF-32 Unicode encoding (little-endian)
utf16 :: TextEncoding #
The UTF-16 Unicode encoding (a byte-order-mark should be used to indicate endianness).
utf16be :: TextEncoding #
The UTF-16 Unicode encoding (big-endian)
utf16le :: TextEncoding #
The UTF-16 Unicode encoding (little-endian)
latin1 :: TextEncoding #
char8 :: TextEncoding #
An encoding in which Unicode code points are translated to bytes by taking the code point modulo 256. When decoding, bytes are translated directly into the equivalent code point.
This encoding never fails in either direction. However, encoding discards information, so encode followed by decode is not the identity.
Since: base-4.4.0.0
memcpy :: (LengthUnit l, Pointer ptrS, Pointer ptrD) => Dest (ptrD dest) -> Src (ptrS src) -> l -> IO () #
hGetChar :: Handle -> IO Char #
Computation hGetChar
hdl
reads a character from the file or
channel managed by hdl
, blocking until a character is available.
This operation may fail with:
isEOFError
if the end of file has been reached.
hGetLine :: Handle -> IO String #
Computation hGetLine
hdl
reads a line from the file or
channel managed by hdl
.
This operation may fail with:
isEOFError
if the end of file is encountered when reading the first character of the line.
If hGetLine
encounters end-of-file at any other point while reading
in a line, it is treated as a line terminator and the (partial)
line is returned.
hGetContents' :: Handle -> IO String #
The hGetContents'
operation reads all input on the given handle
before returning it as a String
and closing the handle.
Since: base-4.15.0.0
hPutChar :: Handle -> Char -> IO () #
Computation hPutChar
hdl ch
writes the character ch
to the
file or channel managed by hdl
. Characters may be buffered if
buffering is enabled for hdl
.
This operation may fail with:
isFullError
if the device is full; orisPermissionError
if another system resource limit would be exceeded.
hPutStr :: Handle -> String -> IO () #
Computation hPutStr
hdl s
writes the string
s
to the file or channel managed by hdl
.
This operation may fail with:
isFullError
if the device is full; orisPermissionError
if another system resource limit would be exceeded.
hGetBufSome :: Handle -> Ptr a -> Int -> IO Int #
hGetBufSome
hdl buf count
reads data from the handle hdl
into the buffer buf
. If there is any data available to read,
then hGetBufSome
returns it immediately; it only blocks if there
is no data to be read.
It returns the number of bytes actually read. This may be zero if
EOF was reached before any data was read (or if count
is zero).
hGetBufSome
never raises an EOF exception, instead it returns a value
smaller than count
.
If the handle is a pipe or socket, and the writing end
is closed, hGetBufSome
will behave as if EOF was reached.
hGetBufSome
ignores the prevailing TextEncoding
and
NewlineMode
on the Handle
, and reads bytes directly.
hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int #
hGetBufNonBlocking
hdl buf count
reads data from the handle hdl
into the buffer buf
until either EOF is reached, or
count
8-bit bytes have been read, or there is no more data available
to read immediately.
hGetBufNonBlocking
is identical to hGetBuf
, except that it will
never block waiting for data to become available, instead it returns
only whatever data is available. To wait for data to arrive before
calling hGetBufNonBlocking
, use hWaitForInput
.
If the handle is a pipe or socket, and the writing end
is closed, hGetBufNonBlocking
will behave as if EOF was reached.
hGetBufNonBlocking
ignores the prevailing TextEncoding
and
NewlineMode
on the Handle
, and reads bytes directly.
NOTE: on Windows, this function does not work correctly; it
behaves identically to hGetBuf
.
hFileSize :: Handle -> IO Integer #
For a handle hdl
which attached to a physical file,
hFileSize
hdl
returns the size of that file in 8-bit bytes.
hSetFileSize :: Handle -> Integer -> IO () #
hSetFileSize
hdl
size
truncates the physical file with handle hdl
to size
bytes.
For a readable handle hdl
, hIsEOF
hdl
returns
True
if no further input can be taken from hdl
or for a
physical file, if the current I/O position is equal to the length of
the file. Otherwise, it returns False
.
NOTE: hIsEOF
may block, because it has to attempt to read from
the stream to determine whether there is any more data to be read.
hSetBuffering :: Handle -> BufferMode -> IO () #
Computation hSetBuffering
hdl mode
sets the mode of buffering for
handle hdl
on subsequent reads and writes.
If the buffer mode is changed from BlockBuffering
or
LineBuffering
to NoBuffering
, then
- if
hdl
is writable, the buffer is flushed as forhFlush
; - if
hdl
is not writable, the contents of the buffer is discarded.
This operation may fail with:
isPermissionError
if the handle has already been used for reading or writing and the implementation does not allow the buffering mode to be changed.
hSetEncoding :: Handle -> TextEncoding -> IO () #
The action hSetEncoding
hdl
encoding
changes the text encoding
for the handle hdl
to encoding
. The default encoding when a Handle
is
created is localeEncoding
, namely the default encoding for the
current locale.
To create a Handle
with no encoding at all, use openBinaryFile
. To
stop further encoding or decoding on an existing Handle
, use
hSetBinaryMode
.
hSetEncoding
may need to flush buffered data in order to change
the encoding.
hGetEncoding :: Handle -> IO (Maybe TextEncoding) #
Return the current TextEncoding
for the specified Handle
, or
Nothing
if the Handle
is in binary mode.
Note that the TextEncoding
remembers nothing about the state of
the encoder/decoder in use on this Handle
. For example, if the
encoding in use is UTF-16, then using hGetEncoding
and
hSetEncoding
to save and restore the encoding may result in an
extra byte-order-mark being written to the file.
hGetPosn :: Handle -> IO HandlePosn #
Computation hGetPosn
hdl
returns the current I/O position of
hdl
as a value of the abstract type HandlePosn
.
hSetPosn :: HandlePosn -> IO () #
If a call to hGetPosn
hdl
returns a position p
,
then computation hSetPosn
p
sets the position of hdl
to the position it held at the time of the call to hGetPosn
.
This operation may fail with:
isPermissionError
if a system resource limit would be exceeded.
hTell :: Handle -> IO Integer #
Computation hTell
hdl
returns the current position of the
handle hdl
, as the number of bytes from the beginning of
the file. The value returned may be subsequently passed to
hSeek
to reposition the handle to the current position.
This operation may fail with:
isIllegalOperationError
if the Handle is not seekable.
hIsReadable :: Handle -> IO Bool #
hIsWritable :: Handle -> IO Bool #
hGetBuffering :: Handle -> IO BufferMode #
Computation hGetBuffering
hdl
returns the current buffering mode
for hdl
.
hIsSeekable :: Handle -> IO Bool #
hSetNewlineMode :: Handle -> NewlineMode -> IO () #
Set the NewlineMode
on the specified Handle
. All buffered
data is flushed first.
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
).
getContents' :: IO String #
The getContents'
operation returns all user input as a single string,
which is fully read before being returned
(same as hGetContents'
stdin
).
Since: base-4.15.0.0
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.
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
.
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]])
Computation hReady
hdl
indicates whether at least one item is
available for input from handle hdl
.
This operation may fail with:
isEOFError
if the end of file has been reached.
hPrint :: Show a => Handle -> a -> IO () #
Computation hPrint
hdl t
writes the string representation of t
given by the shows
function to the file or channel managed by hdl
and appends a newline.
This operation may fail with:
isFullError
if the device is full; orisPermissionError
if another system resource limit would be exceeded.
Arguments
:: FilePath | Directory in which to create the file |
-> String | File name template. If the template is "foo.ext" then the created file will be "fooXXX.ext" where XXX is some random number. Note that this should not contain any path separator characters. On Windows, the template prefix may be truncated to 3 chars, e.g. "foobar.ext" will be "fooXXX.ext". |
-> IO (FilePath, Handle) |
The function creates a temporary file in ReadWrite mode. The created file isn't deleted automatically, so you need to delete it manually.
The file is created with permissions such that only the current user can read/write it.
With some exceptions (see below), the file will be created securely
in the sense that an attacker should not be able to cause
openTempFile to overwrite another file on the filesystem using your
credentials, by putting symbolic links (on Unix) in the place where
the temporary file is to be created. On Unix the O_CREAT
and
O_EXCL
flags are used to prevent this attack, but note that
O_EXCL
is sometimes not supported on NFS filesystems, so if you
rely on this behaviour it is best to use local filesystems only.
openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle) #
Like openTempFile
, but opens the file in binary mode. See openBinaryFile
for more comments.
openTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle) #
Like openTempFile
, but uses the default file permissions
openBinaryTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle) #
Like openBinaryTempFile
, but uses the default file permissions
filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a] #
This generalizes the list-based filter
function.
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 #
Left-to-right composition of Kleisli arrows.
'(bs
' can be understood as the >=>
cs) ado
expression
do b <- bs a cs b
mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) #
The mapAndUnzipM
function maps its first argument over a list, returning
the result as a pair of lists. This function is mainly used with complicated
data structures or a state monad.
zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c] #
zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m () #
foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b #
The foldM
function is analogous to foldl
, except that its result is
encapsulated in a monad. Note that foldM
works from left-to-right over
the list arguments. This could be an issue where (
and the `folded
function' are not commutative.>>
)
foldM f a1 [x1, x2, ..., xm] == do a2 <- f a1 x1 a3 <- f a2 x2 ... f am xm
If right-to-left evaluation is required, the input list should be reversed.
foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m () #
Like foldM
, but discards the result.
replicateM :: Applicative m => Int -> m a -> m [a] #
performs the action replicateM
n actact
n
times,
and then returns the list of results:
Examples
>>>
import Control.Monad.State
>>>
runState (replicateM 3 $ state $ \s -> (s, s + 1)) 1
([1,2,3],4)
replicateM_ :: Applicative m => Int -> m a -> m () #
unless :: Applicative f => Bool -> f () -> f () #
The reverse of when
.
Run an IO action while constructing the spec tree.
SpecM
is a monad to construct a spec tree, without executing any spec
items. runIO
allows you to run IO actions during this construction phase.
The IO action is always run when the spec tree is constructed (e.g. even
when --dry-run
is specified).
If you do not need the result of the IO action to construct the spec tree,
beforeAll
may be more suitable for your use case.
atMost :: (LengthUnit src, LengthUnit dest) => src -> dest #
create :: LengthUnit l => l -> (Ptr a -> IO ()) -> IO ByteString #
pack :: [Word8] -> ByteString #
O(n) Convert a [
into a Word8
]ByteString
.
For applications with large numbers of string literals, pack
can be a
bottleneck. In such cases, consider using unsafePackAddress
(GHC only).
modifyMaxSuccess :: (Int -> Int) -> SpecWith a -> SpecWith a #
Use a modified maxSuccess
for given spec.
modifyMaxDiscardRatio :: (Int -> Int) -> SpecWith a -> SpecWith a #
Use a modified maxDiscardRatio
for given spec.
modifyMaxShrinks :: (Int -> Int) -> SpecWith a -> SpecWith a #
Use a modified maxShrinks
for given spec.
beforeWith :: (b -> IO a) -> SpecWith a -> SpecWith b #
Run a custom action before every spec item.
beforeAll :: HasCallStack => IO a -> SpecWith a -> Spec #
Run a custom action before the first spec item.
beforeAll_ :: HasCallStack => IO () -> SpecWith a -> SpecWith a #
Run a custom action before the first spec item.
beforeAllWith :: HasCallStack => (b -> IO a) -> SpecWith a -> SpecWith b #
Run a custom action with an argument before the first spec item.
after :: ActionWith a -> SpecWith a -> SpecWith a #
Run a custom action after every spec item.
around :: (ActionWith a -> IO ()) -> SpecWith a -> Spec #
Run a custom action before and/or after every spec item.
afterAll :: HasCallStack => ActionWith a -> SpecWith a -> SpecWith a #
Run a custom action after the last spec item.
afterAll_ :: HasCallStack => IO () -> SpecWith a -> SpecWith a #
Run a custom action after the last spec item.
around_ :: (IO () -> IO ()) -> SpecWith a -> SpecWith a #
Run a custom action before and/or after every spec item.
aroundWith :: (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b #
Run a custom action before and/or after every spec item.
aroundAll :: HasCallStack => (ActionWith a -> IO ()) -> SpecWith a -> Spec #
Wrap an action around the given spec.
aroundAll_ :: HasCallStack => (IO () -> IO ()) -> SpecWith a -> SpecWith a #
Wrap an action around the given spec.
aroundAllWith :: HasCallStack => (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b #
Wrap an action around the given spec. Changes the arg type inside.
mapSubject :: (b -> a) -> SpecWith a -> SpecWith b #
Modify the subject under test.
Note that this resembles a contravariant functor on the first type parameter
of SpecM
. This is because the subject is passed inwards, as an argument
to the spec item.
ignoreSubject :: SpecWith () -> SpecWith a #
Ignore the subject under test for a given spec.
describe :: HasCallStack => String -> SpecWith a -> SpecWith a #
The describe
function combines a list of specs into a larger spec.
it :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) #
The it
function creates a spec item.
A spec item consists of:
- a textual description of a desired behavior
- an example for that behavior
describe "absolute" $ do it "returns a positive number when given a negative number" $ absolute (-1) == 1
specify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) #
specify
is an alias for it
.
xspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) #
xspecify
is an alias for xit
.
fit :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) #
fit
is an alias for fmap focus . it
fspecify :: (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) #
fspecify
is an alias for fit
.
fdescribe :: HasCallStack => String -> SpecWith a -> SpecWith a #
fdescribe
is an alias for fmap focus . describe
parallel :: SpecWith a -> SpecWith a #
parallel
marks all spec items of the given spec to be safe for parallel
evaluation.
sequential :: SpecWith a -> SpecWith a #
sequential
marks all spec items of the given spec to be evaluated sequentially.
pending :: HasCallStack => Expectation #
pending
can be used to mark a spec item as pending.
If you want to textually specify a behavior but do not have an example yet, use this:
describe "fancyFormatter" $ do it "can format text in a way that everyone likes" $ pending
pendingWith :: HasCallStack => String -> Expectation #
pendingWith
is similar to pending
, but it takes an additional string
argument that can be used to specify the reason for why the spec item is pending.
example :: Expectation -> Expectation #
example
is a type restricted version of id
. It can be used to get better
error messages on type mismatches.
Compare e.g.
it "exposes some behavior" $ example $ do putStrLn
with
it "exposes some behavior" $ do putStrLn
expectationFailure :: HasCallStack => String -> Expectation #
shouldBe :: (HasCallStack, Show a, Eq a) => a -> a -> Expectation infix 1 #
actual `shouldBe` expected
sets the expectation that actual
is equal
to expected
.
shouldSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> Expectation infix 1 #
v `shouldSatisfy` p
sets the expectation that p v
is True
.
shouldStartWith :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation infix 1 #
list `shouldStartWith` prefix
sets the expectation that list
starts with prefix
,
shouldEndWith :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation infix 1 #
list `shouldEndWith` suffix
sets the expectation that list
ends with suffix
,
shouldContain :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation infix 1 #
list `shouldContain` sublist
sets the expectation that sublist
is contained,
wholly and intact, anywhere in list
.
shouldMatchList :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation infix 1 #
xs `shouldMatchList` ys
sets the expectation that xs
has the same
elements that ys
has, possibly in another order
shouldReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> Expectation infix 1 #
action `shouldReturn` expected
sets the expectation that action
returns expected
.
shouldNotBe :: (HasCallStack, Show a, Eq a) => a -> a -> Expectation infix 1 #
actual `shouldNotBe` notExpected
sets the expectation that actual
is not
equal to notExpected
shouldNotSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> Expectation infix 1 #
v `shouldNotSatisfy` p
sets the expectation that p v
is False
.
shouldNotContain :: (HasCallStack, Show a, Eq a) => [a] -> [a] -> Expectation infix 1 #
list `shouldNotContain` sublist
sets the expectation that sublist
is not
contained anywhere in list
.
shouldNotReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> Expectation infix 1 #
action `shouldNotReturn` notExpected
sets the expectation that action
does not return notExpected
.
shouldThrow :: (HasCallStack, Exception e) => IO a -> Selector e -> Expectation infix 1 #
action `shouldThrow` selector
sets the expectation that action
throws
an exception. The precise nature of the expected exception is described
with a Selector
.
movePtr :: LengthUnit l => Ptr a -> l -> Ptr a #
processChunks :: (Pointer ptr, MonadIO m, LengthUnit chunkSize, ByteSource src) => m a -> (BYTES Int -> m b) -> src -> ptr something -> chunkSize -> m b #
withFillResult :: (a -> b) -> (BYTES Int -> b) -> FillResult a -> b #
unsafeDecode :: (Format fmt, Encodable a) => fmt -> a #
fromBase16 :: Encodable a => String -> a #
showBase16 :: Encodable a => a -> String #
copyCell :: Storable a => Dest (MemoryCell a) -> Src (MemoryCell a) -> IO () #
memTransfer :: (ReadAccessible src, WriteAccessible dest) => Dest dest -> Src src -> IO () #
modifyMem :: (Initialisable mem a, Extractable mem b) => (b -> a) -> mem -> IO () #
pointerAlloc :: LengthUnit l => l -> Alloc (Ptr Word8) #
unsafeGetCellPointer :: Storable a => MemoryCell a -> Ptr a #
withCellPointer :: Storable a => (Ptr a -> IO b) -> MemoryCell a -> IO b #
withMemory :: Memory mem => (mem -> IO a) -> IO a #
withSecureMemory :: Memory mem => (mem -> IO a) -> IO a #
blocksOf :: Int -> Proxy p -> BlockCount p #
consume :: EndianStore a => (a -> IO b) -> ReadFrom #
consumeParse :: Parser a -> (a -> IO b) -> ReadFrom #
consumeStorable :: Storable a => (a -> IO b) -> ReadFrom #
glueWrites :: LengthUnit n => Word8 -> n -> WriteTo -> WriteTo -> WriteTo #
prependWrite :: LengthUnit n => Word8 -> n -> WriteTo -> WriteTo #
skip :: forall l (t :: Mode). LengthUnit l => l -> Transfer t #
writeBytes :: LengthUnit n => Word8 -> n -> WriteTo #
writeEncodable :: Encodable a => a -> WriteTo #
writeStorable :: Storable a => a -> WriteTo #
writeStorableVector :: (Storable a, Vector v a) => v a -> WriteTo #
writeVector :: (EndianStore a, Vector v a) => v a -> WriteTo #
transferSize :: forall (t :: Mode). Transfer t -> BYTES Int #
writeByteString :: ByteString -> WriteTo #
destination :: a -> Dest a #
copyFromBytes :: EndianStore w => Dest (Ptr w) -> Src (Ptr Word8) -> Int -> IO () #
copyToBytes :: EndianStore w => Dest (Ptr Word8) -> Src (Ptr w) -> Int -> IO () #
littleEndian :: w -> LE w #
loadFrom :: (EndianStore w, LengthUnit offset) => Ptr w -> offset -> IO w #
loadFromIndex :: EndianStore w => Ptr w -> Int -> IO w #
storeAt :: (EndianStore w, LengthUnit offset) => Ptr w -> offset -> w -> IO () #
storeAtIndex :: EndianStore w => Ptr w -> Int -> w -> IO () #
allocaBuffer :: (LengthUnit l, Pointer ptr) => l -> (ptr something -> IO b) -> IO b #
allocaSecure :: (LengthUnit l, Pointer ptr) => l -> (ptr a -> IO b) -> IO b #
atLeast :: (LengthUnit src, LengthUnit dest) => src -> dest #
atLeastAligned :: LengthUnit l => l -> Alignment -> BYTES Int #
nextAlignedPtr :: forall a (n :: Nat). (Storable a, KnownNat n) => Ptr a -> AlignedPtr n a #
nextLocation :: Storable a => Ptr a -> Ptr a #
peekAligned :: Storable a => Ptr a -> IO a #
pokeAligned :: Storable a => Ptr a -> a -> IO () #
ptrAlignment :: forall (n :: Nat) a. KnownNat n => Proxy (AlignedPtr n a) -> Alignment #
unsafeWithPointer :: Pointer ptr => (Ptr a -> b) -> ptr a -> b #
unsafeWithPointerCast :: Pointer ptr => (Ptr a -> b) -> ptr something -> b #
wipeMemory :: (LengthUnit l, Pointer ptr) => ptr a -> l -> IO () #
initial :: forall a (dim0 :: Nat) (dim1 :: Nat). (Unbox a, Dimension dim0) => Tuple dim1 a -> Tuple dim0 a #
unsafeFromVector :: forall a (dim :: Nat). Vector a -> Tuple dim a #
unsafeToVector :: forall (dim :: Nat) a. Tuple dim a -> Vector a #
createFrom :: LengthUnit l => l -> Ptr a -> IO ByteString #
unsafeCopyToPointer :: Pointer ptr => ByteString -> ptr a -> IO () #
unsafeNCopyToPointer :: LengthUnit n => n -> ByteString -> Ptr a -> IO () #
withByteString :: ByteString -> (Ptr something -> IO a) -> IO a #
counterCellPtr :: ChaCha20Mem -> Ptr WORD #
keyCellPtr :: ChaCha20Mem -> Ptr (Key ChaCha20) #
process256Last :: forall (n :: Nat). KnownNat n => Compressor256 n -> AlignedBlockPtr n Sha256 -> BYTES Int -> Sha256Mem -> IO () #
process512Last :: forall (n :: Nat). KnownNat n => Compressor512 n -> AlignedBlockPtr n Sha512 -> BYTES Int -> Sha512Mem -> IO () #