Copyright | (c) 2022 Tim Emiola |
---|---|
License | BSD3 |
Maintainer | Tim Emiola <adetokunbo@emio.la> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Uses Test.Hspec to validate the behaviour of a Handle
implementation
Synopsis
- void :: Functor f => f a -> f ()
- throwIO :: Exception e => e -> IO a
- data ByteString
- data NonEmpty a = a :| [a]
- data Natural
- type Key = ByteString
- data Handle (m :: Type -> Type)
- data Glob
- data HandleErr
- mkGlob :: ByteString -> Maybe Glob
- module Test.Hspec
- module Test.Hspec.Benri
- module Test.KeyedVals.Types
a test fixture
setup/teardown hspec tests
module re-export
functions
module re-eports
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
throwIO :: Exception e => e -> IO a #
A variant of throw
that can only be used within the IO
monad.
Although throwIO
has a type that is an instance of the type of throw
, the
two functions are subtly different:
throw e `seq` () ===> throw e throwIO e `seq` () ===> ()
The first example will cause the exception e
to be raised,
whereas the second one won't. In fact, throwIO
will only cause
an exception to be raised when it is used within the IO
monad.
The throwIO
variant should be used in preference to throw
to
raise an exception within the IO
monad because it guarantees
ordering with respect to other operations, whereas throw
does not. We say that throwIO
throws *precise* exceptions and
throw
, error
, etc. all throw *imprecise* exceptions.
For example
throw e + error "boom" ===> error "boom" throw e + error "boom" ===> throw e
are both valid reductions and the compiler may pick any (loop, even), whereas
throwIO e >> error "boom" ===> throwIO e
will always throw e
when executed.
See also the GHC wiki page on precise exceptions for a more technical introduction to how GHC optimises around precise vs. imprecise exceptions.
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
Non-empty (and non-strict) list type.
Since: base-4.9.0.0
a :| [a] infixr 5 |
Instances
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS
constructor
Instances
type Key = ByteString #
Represents a key used to store a Val
.
Represents a redis glob use to select keys
Represents the errors that might arise in Handle
functions
Instances
Exception HandleErr | |
Defined in KeyedVals.Handle.Internal toException :: HandleErr -> SomeException # fromException :: SomeException -> Maybe HandleErr # displayException :: HandleErr -> String # | |
Show HandleErr | |
Eq HandleErr | |
FromHandleErr HandleErr | |
Defined in KeyedVals.Handle.Codec fromHandleErr :: HandleErr -> HandleErr # |
module Test.Hspec
module Test.Hspec.Benri
module Test.KeyedVals.Types