Safe Haskell | None |
---|---|
Language | Haskell2010 |
This will hopefully be the only module with CPP in it.
Synopsis
- (@/=) :: (Eq a, Show a, MonadIO m) => a -> a -> m ()
- (@==) :: (Eq a, Show a, MonadIO m) => a -> a -> m ()
- (==@) :: (Eq a, Show a, MonadIO m) => a -> a -> m ()
- asIO :: IO a -> IO a
- assertNotEqual :: (Eq a, Show a) => String -> a -> a -> Assertion
- assertNotEmpty :: MonadIO m => [a] -> m ()
- assertEmpty :: MonadIO m => [a] -> m ()
- isTravis :: IO Bool
- module Database.Persist.Sql
- class Monad m => MonadIO (m :: Type -> Type)
- persistSettings :: MkPersistSettings
- data MkPersistSettings
- data family BackendKey backend :: Type
- class GenerateKey backend where
- generateKey :: IO (BackendKey backend)
- type RunDb backend m = ReaderT backend m () -> IO ()
- type Runner backend m = (MonadIO m, MonadUnliftIO m, MonadFail m, MonadThrow m, MonadBaseControl IO m, PersistStoreWrite backend, PersistStoreWrite (BaseBackend backend), GenerateKey backend, HasPersistBackend backend, PersistUniqueWrite backend, PersistQueryWrite backend, backend ~ BaseBackend backend, PersistQueryRead backend)
- module Database.Persist
- module Test.Hspec
- (@?=) :: (HasCallStack, Eq a, Show a) => a -> a -> Assertion
- (@=?) :: (HasCallStack, Eq a, Show a) => a -> a -> Assertion
- assertBool :: HasCallStack -> String -> Bool -> Assertion
- assertFailure :: HasCallStack => String -> IO a
- type Assertion = IO ()
- liftIO :: MonadIO m => IO a -> m a
- mkPersist :: MkPersistSettings -> [EntityDef] -> Q [Dec]
- mkMigrate :: String -> [EntityDef] -> Q [Dec]
- share :: [[EntityDef] -> Q [Dec]] -> [EntityDef] -> Q [Dec]
- sqlSettings :: MkPersistSettings
- persistLowerCase :: QuasiQuoter
- persistUpperCase :: QuasiQuoter
- data Int32
- data Int64
- data Text
- module Control.Monad.Trans.Reader
- unless :: Applicative f => Bool -> f () -> f ()
- replicateM :: Applicative m => Int -> m a -> m [a]
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
- void :: Functor f => f a -> f ()
- liftM :: Monad m => (a1 -> r) -> m a1 -> m r
- when :: Applicative f => Bool -> f () -> f ()
- data ByteString
- data SomeException
- class Monad m => MonadFail (m :: Type -> Type)
- data TestFn entity where
- truncateTimeOfDay :: TimeOfDay -> Gen TimeOfDay
- truncateToMicro :: Pico -> Pico
- truncateUTCTime :: UTCTime -> Gen UTCTime
- arbText :: Gen Text
- liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
- changeBackend :: forall backend backend' m. MonadUnliftIO m => (backend -> backend') -> RunDb backend m -> RunDb backend' m
Documentation
assertNotEmpty :: MonadIO m => [a] -> m () Source #
assertEmpty :: MonadIO m => [a] -> m () Source #
module Database.Persist.Sql
class Monad m => MonadIO (m :: Type -> Type) #
Monads in which IO
computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Instances
data MkPersistSettings #
Settings to be passed to the mkPersist
function.
data family BackendKey backend :: Type #
Instances
PersistStore backend => Arbitrary (BackendKey backend) Source # | |
Defined in Init arbitrary :: Gen (BackendKey backend) # shrink :: BackendKey backend -> [BackendKey backend] # | |
newtype BackendKey SqlBackend | |
Defined in Database.Persist.Sql.Orphan.PersistStore | |
newtype BackendKey SqlReadBackend | |
Defined in Database.Persist.Sql.Orphan.PersistStore | |
newtype BackendKey SqlWriteBackend | |
Defined in Database.Persist.Sql.Orphan.PersistStore |
class GenerateKey backend where Source #
generateKey :: IO (BackendKey backend) Source #
Instances
GenerateKey SqlBackend Source # | |
Defined in Init generateKey :: IO (BackendKey SqlBackend) Source # |
type Runner backend m = (MonadIO m, MonadUnliftIO m, MonadFail m, MonadThrow m, MonadBaseControl IO m, PersistStoreWrite backend, PersistStoreWrite (BaseBackend backend), GenerateKey backend, HasPersistBackend backend, PersistUniqueWrite backend, PersistQueryWrite backend, backend ~ BaseBackend backend, PersistQueryRead backend) Source #
module Database.Persist
module Test.Hspec
:: (HasCallStack, Eq a, Show a) | |
=> a | The actual value |
-> a | The expected value |
-> Assertion |
Asserts that the specified actual value is equal to the expected value (with the actual value on the left-hand side).
:: (HasCallStack, Eq a, Show a) | |
=> a | The expected value |
-> a | The actual value |
-> Assertion |
Asserts that the specified actual value is equal to the expected value (with the expected value on the left-hand side).
:: HasCallStack | The message that is displayed if the assertion fails |
-> String | The condition |
-> Bool | |
-> Assertion |
Asserts that the specified condition holds.
:: HasCallStack | |
=> String | A message that is displayed with the assertion failure |
-> IO a |
Unconditionally signals that a failure has occured. All other assertions can be expressed with the form:
if conditionIsMet then IO () else assertFailure msg
When an assertion is evaluated, it will output a message if and only if the assertion fails.
Test cases are composed of a sequence of one or more assertions.
mkPersist :: MkPersistSettings -> [EntityDef] -> Q [Dec] #
Create data types and appropriate PersistEntity
instances for the given
EntityDef
s. Works well with the persist quasi-quoter.
mkMigrate :: String -> [EntityDef] -> Q [Dec] #
Creates a single function to perform all migrations for the entities defined here. One thing to be aware of is dependencies: if you have entities with foreign references, make sure to place those definitions after the entities they reference.
share :: [[EntityDef] -> Q [Dec]] -> [EntityDef] -> Q [Dec] #
Apply the given list of functions to the same EntityDef
s.
This function is useful for cases such as:
>>>
share [mkSave "myDefs", mkPersist sqlSettings] [persistLowerCase|...|]
sqlSettings :: MkPersistSettings #
Use the SqlPersist
backend.
persistLowerCase :: QuasiQuoter #
Apply persistWith
to lowerCaseSettings
.
persistUpperCase :: QuasiQuoter #
Apply persistWith
to upperCaseSettings
.
32-bit signed integer type
Instances
64-bit signed integer type
Instances
A space efficient, packed, unboxed Unicode text type.
Instances
module Control.Monad.Trans.Reader
unless :: Applicative f => Bool -> f () -> f () #
The reverse of when
.
replicateM :: Applicative m => Int -> m a -> m [a] #
performs the action replicateM
n actn
times,
gathering the results.
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 #
Left-to-right composition of Kleisli arrows.
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
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.
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
data SomeException #
The SomeException
type is the root of the exception type hierarchy.
When an exception of type e
is thrown, behind the scenes it is
encapsulated in a SomeException
.
Instances
Show SomeException | Since: base-3.0 |
Defined in GHC.Exception.Type showsPrec :: Int -> SomeException -> ShowS # show :: SomeException -> String # showList :: [SomeException] -> ShowS # | |
Exception SomeException | Since: base-3.0 |
Defined in GHC.Exception.Type |
class Monad m => MonadFail (m :: Type -> Type) #
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
Since: base-4.9.0.0
Instances
data TestFn entity where Source #
A datatype that wraps a function on entity
that can has testable results.
Allows us to write:
foo :: entity -> entity -> [TestFn entity] -> Bool foo e0 e1 = all ((TestFn msg f) -> f e0 == f e1)
truncateToMicro :: Pico -> Pico Source #
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c #
changeBackend :: forall backend backend' m. MonadUnliftIO m => (backend -> backend') -> RunDb backend m -> RunDb backend' m Source #
Orphan instances
Arbitrary PersistValue Source # | |
arbitrary :: Gen PersistValue # shrink :: PersistValue -> [PersistValue] # | |
MonadBase b m => MonadBase b (ResourceT m) Source # | |
MonadBaseControl b m => MonadBaseControl b (ResourceT m) Source # | |
PersistStore backend => Arbitrary (BackendKey backend) Source # | |
arbitrary :: Gen (BackendKey backend) # shrink :: BackendKey backend -> [BackendKey backend] # |