Safe Haskell | None |
---|---|
Language | Haskell2010 |
This will hopefully be the only module with CPP in it.
Synopsis
- (@/=) :: (HasCallStack, Eq a, Show a, MonadIO m) => a -> a -> m ()
- (@==) :: (HasCallStack, Eq a, Show a, MonadIO m) => a -> a -> m ()
- (==@) :: (HasCallStack, Eq a, Show a, MonadIO m) => a -> a -> m ()
- asIO :: IO a -> IO a
- assertNotEqual :: (Eq a, Show a, HasCallStack) => String -> a -> a -> Assertion
- assertNotEmpty :: MonadIO m => [a] -> m ()
- assertEmpty :: MonadIO m => [a] -> m ()
- isTravis :: IO Bool
- module Database.Persist.Sql
- persistSettings :: MkPersistSettings
- data MkPersistSettings
- data family BackendKey backend
- 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 ()
- mkPersist :: MkPersistSettings -> [UnboundEntityDef] -> Q [Dec]
- mkMigrate :: String -> [UnboundEntityDef] -> Q [Dec]
- share :: [[a] -> Q [Dec]] -> [a] -> Q [Dec]
- sqlSettings :: MkPersistSettings
- persistLowerCase :: QuasiQuoter
- persistUpperCase :: QuasiQuoter
- data Int32
- data Int64
- data Text
- module Control.Monad.Reader
- forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
- 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
- void :: Functor f => f a -> f ()
- liftM :: Monad m => (a1 -> r) -> m a1 -> m r
- when :: Applicative f => Bool -> f () -> f ()
- class Monad m => MonadIO (m :: Type -> Type) where
- class MonadIO m => MonadUnliftIO (m :: Type -> Type) where
- withRunInIO :: ((forall a. m a -> IO a) -> IO b) -> m b
- newtype UnliftIO (m :: Type -> Type) = UnliftIO {}
- askUnliftIO :: MonadUnliftIO m => m (UnliftIO m)
- askRunInIO :: MonadUnliftIO m => m (m a -> IO a)
- withUnliftIO :: MonadUnliftIO m => (UnliftIO m -> IO a) -> m a
- toIO :: MonadUnliftIO m => m a -> m (IO a)
- wrappedWithRunInIO :: MonadUnliftIO n => (n b -> m b) -> (forall a. m a -> n a) -> ((forall a. m a -> IO a) -> IO b) -> m b
- 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
- data Proxy (t :: k) = Proxy
- newtype UUID = UUID {}
- sqlSettingsUuid :: Text -> MkPersistSettings
Documentation
assertNotEqual :: (Eq a, Show a, HasCallStack) => String -> a -> a -> Assertion Source #
assertNotEmpty :: MonadIO m => [a] -> m () Source #
assertEmpty :: MonadIO m => [a] -> m () Source #
module Database.Persist.Sql
data MkPersistSettings #
Settings to be passed to the mkPersist
function.
data family BackendKey backend #
Instances
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 | |
=> String | The message that is displayed if the assertion fails |
-> Bool | The condition |
-> 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 occurred.
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 -> [UnboundEntityDef] -> Q [Dec] #
Create data types and appropriate PersistEntity
instances for the given
EntityDef
s. Works well with the persist quasi-quoter.
mkMigrate :: String -> [UnboundEntityDef] -> 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.
In persistent-2.13.0.0
, this was changed to *ignore* the input entity def
list, and instead defer to mkEntityDefList
to get the correct entities.
This avoids problems where the QuasiQuoter is unable to know what the right
reference types are. This sets mkPersist
to be the "single source of truth"
for entity definitions.
share :: [[a] -> Q [Dec]] -> [a] -> 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.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.
Using ApplicativeDo
: '
' can be understood as
the replicateM
5 asdo
expression
do a1 <- as a2 <- as a3 <- as a4 <- as a5 <- as pure [a1,a2,a3,a4,a5]
Note the Applicative
constraint.
(>=>) :: 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
void :: Functor f => f a -> f () #
discards or ignores the result of evaluation, such
as the return value of an void
valueIO
action.
Using ApplicativeDo
: '
' can be understood as the
void
asdo
expression
do as pure ()
with an inferred Functor
constraint.
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.
class Monad m => MonadIO (m :: Type -> Type) where #
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
class MonadIO m => MonadUnliftIO (m :: Type -> Type) where #
Monads which allow their actions to be run in IO
.
While MonadIO
allows an IO
action to be lifted into another
monad, this class captures the opposite concept: allowing you to
capture the monadic context. Note that, in order to meet the laws
given below, the intuition is that a monad must have no monadic
state, but may have monadic context. This essentially limits
MonadUnliftIO
to ReaderT
and IdentityT
transformers on top of
IO
.
Laws. For any value u
returned by askUnliftIO
, it must meet the
monad transformer laws as reformulated for MonadUnliftIO
:
unliftIO u . return = return
unliftIO u (m >>= f) = unliftIO u m >>= unliftIO u . f
Instances of MonadUnliftIO
must also satisfy the idempotency law:
askUnliftIO >>= \u -> (liftIO . unliftIO u) m = m
This law showcases two properties. First, askUnliftIO
doesn't change
the monadic context, and second, liftIO . unliftIO u
is equivalent to
id
IF called in the same monadic context as askUnliftIO
.
Since: unliftio-core-0.1.0.0
withRunInIO :: ((forall a. m a -> IO a) -> IO b) -> m b #
Convenience function for capturing the monadic context and running an IO
action with a runner function. The runner function is used to run a monadic
action m
in IO
.
Since: unliftio-core-0.1.0.0
Instances
MonadUnliftIO IO | |
Defined in Control.Monad.IO.Unlift | |
MonadUnliftIO m => MonadUnliftIO (ResourceT m) | Since: resourcet-1.1.10 |
Defined in Control.Monad.Trans.Resource.Internal | |
MonadUnliftIO m => MonadUnliftIO (NoLoggingT m) | Since: monad-logger-0.3.26 |
Defined in Control.Monad.Logger withRunInIO :: ((forall a. NoLoggingT m a -> IO a) -> IO b) -> NoLoggingT m b # | |
MonadUnliftIO m => MonadUnliftIO (LoggingT m) | Since: monad-logger-0.3.26 |
Defined in Control.Monad.Logger | |
MonadUnliftIO m => MonadUnliftIO (IdentityT m) | |
Defined in Control.Monad.IO.Unlift | |
MonadUnliftIO m => MonadUnliftIO (ReaderT r m) | |
Defined in Control.Monad.IO.Unlift |
newtype UnliftIO (m :: Type -> Type) #
The ability to run any monadic action m a
as IO a
.
This is more precisely a natural transformation. We need to new
datatype (instead of simply using a forall
) due to lack of
support in GHC for impredicative types.
Since: unliftio-core-0.1.0.0
askUnliftIO :: MonadUnliftIO m => m (UnliftIO m) #
Capture the current monadic context, providing the ability to
run monadic actions in IO
.
See UnliftIO
for an explanation of why we need a helper
datatype here.
Prior to version 0.2.0.0 of this library, this was a method in the
MonadUnliftIO
type class. It was moved out due to
https://github.com/fpco/unliftio/issues/55.
Since: unliftio-core-0.1.0.0
askRunInIO :: MonadUnliftIO m => m (m a -> IO a) #
Same as askUnliftIO
, but returns a monomorphic function
instead of a polymorphic newtype wrapper. If you only need to apply
the transformation on one concrete type, this function can be more
convenient.
Since: unliftio-core-0.1.0.0
withUnliftIO :: MonadUnliftIO m => (UnliftIO m -> IO a) -> m a #
Convenience function for capturing the monadic context and running
an IO
action. The UnliftIO
newtype wrapper is rarely needed, so
prefer withRunInIO
to this function.
Since: unliftio-core-0.1.0.0
toIO :: MonadUnliftIO m => m a -> m (IO a) #
Convert an action in m
to an action in IO
.
Since: unliftio-core-0.1.0.0
:: MonadUnliftIO n | |
=> (n b -> m b) | The wrapper, for instance |
-> (forall a. m a -> n a) | The inverse, for instance |
-> ((forall a. m a -> IO a) -> IO b) | The actual function to invoke |
-> m b |
A helper function for implementing MonadUnliftIO
instances.
Useful for the common case where you want to simply delegate to the
underlying transformer.
Example
newtype AppT m a = AppT { unAppT :: ReaderT Int (ResourceT m) a } deriving (Functor, Applicative, Monad, MonadIO) -- Unfortunately, deriving MonadUnliftIO does not work. instance MonadUnliftIO m => MonadUnliftIO (AppT m) where withRunInIO = wrappedWithRunInIO AppT unAppT
Since: unliftio-core-0.1.2.0
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 #
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
.
Using ApplicativeDo
: '
' can be understood
as the liftA2
f as bsdo
expression
do a <- as b <- bs pure (f a b)
changeBackend :: forall backend backend' m. MonadUnliftIO m => (backend -> backend') -> RunDb backend m -> RunDb backend' m Source #
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
Instances
Generic1 (Proxy :: k -> Type) | Since: base-4.6.0.0 |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Foldable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable 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 |
ToJSON1 (Proxy :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON liftToJSON :: (a -> Value) -> ([a] -> Value) -> Proxy a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Proxy a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Proxy a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Proxy a] -> Encoding # | |
FromJSON1 (Proxy :: Type -> Type) | |
Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Eq1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Ord1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Read1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Show1 (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
Hashable1 (Proxy :: Type -> Type) | |
Defined in Data.Hashable.Class | |
Bounded (Proxy t) | Since: base-4.7.0.0 |
Enum (Proxy s) | Since: base-4.7.0.0 |
Eq (Proxy s) | Since: base-4.7.0.0 |
Ord (Proxy s) | Since: base-4.7.0.0 |
Read (Proxy t) | Since: base-4.7.0.0 |
Show (Proxy s) | Since: base-4.7.0.0 |
Ix (Proxy s) | Since: base-4.7.0.0 |
Defined in Data.Proxy | |
Generic (Proxy t) | Since: base-4.6.0.0 |
Semigroup (Proxy s) | Since: base-4.9.0.0 |
Monoid (Proxy s) | Since: base-4.7.0.0 |
Hashable (Proxy a) | |
Defined in Data.Hashable.Class | |
ToJSON (Proxy a) | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON (Proxy a) | |
MonoFunctor (Proxy a) | Since: mono-traversable-1.0.11.0 |
MonoFoldable (Proxy a) | Since: mono-traversable-1.0.11.0 |
Defined in Data.MonoTraversable ofoldMap :: Monoid m => (Element (Proxy a) -> m) -> Proxy a -> m # ofoldr :: (Element (Proxy a) -> b -> b) -> b -> Proxy a -> b # ofoldl' :: (a0 -> Element (Proxy a) -> a0) -> a0 -> Proxy a -> a0 # otoList :: Proxy a -> [Element (Proxy a)] # oall :: (Element (Proxy a) -> Bool) -> Proxy a -> Bool # oany :: (Element (Proxy a) -> Bool) -> Proxy a -> Bool # olength64 :: Proxy a -> Int64 # ocompareLength :: Integral i => Proxy a -> i -> Ordering # otraverse_ :: Applicative f => (Element (Proxy a) -> f b) -> Proxy a -> f () # ofor_ :: Applicative f => Proxy a -> (Element (Proxy a) -> f b) -> f () # omapM_ :: Applicative m => (Element (Proxy a) -> m ()) -> Proxy a -> m () # oforM_ :: Applicative m => Proxy a -> (Element (Proxy a) -> m ()) -> m () # ofoldlM :: Monad m => (a0 -> Element (Proxy a) -> m a0) -> a0 -> Proxy a -> m a0 # ofoldMap1Ex :: Semigroup m => (Element (Proxy a) -> m) -> Proxy a -> m # ofoldr1Ex :: (Element (Proxy a) -> Element (Proxy a) -> Element (Proxy a)) -> Proxy a -> Element (Proxy a) # ofoldl1Ex' :: (Element (Proxy a) -> Element (Proxy a) -> Element (Proxy a)) -> Proxy a -> Element (Proxy a) # headEx :: Proxy a -> Element (Proxy a) # lastEx :: Proxy a -> Element (Proxy a) # unsafeHead :: Proxy a -> Element (Proxy a) # unsafeLast :: Proxy a -> Element (Proxy a) # maximumByEx :: (Element (Proxy a) -> Element (Proxy a) -> Ordering) -> Proxy a -> Element (Proxy a) # minimumByEx :: (Element (Proxy a) -> Element (Proxy a) -> Ordering) -> Proxy a -> Element (Proxy a) # | |
MonoTraversable (Proxy a) | Since: mono-traversable-1.0.11.0 |
MonoPointed (Proxy a) | Since: mono-traversable-1.0.11.0 |
type Rep1 (Proxy :: k -> Type) | |
type Rep (Proxy t) | |
type Element (Proxy a) | |
Defined in Data.MonoTraversable |
Instances
Eq UUID Source # | |
Ord UUID Source # | |
Read UUID Source # | |
Show UUID Source # | |
ToJSON UUID Source # | |
FromJSON UUID Source # | |
ToHttpApiData UUID Source # | |
Defined in Init toUrlPiece :: UUID -> Text # toEncodedUrlPiece :: UUID -> Builder # toHeader :: UUID -> ByteString # toQueryParam :: UUID -> Text # | |
FromHttpApiData UUID Source # | |
Defined in Init parseUrlPiece :: Text -> Either Text UUID # parseHeader :: ByteString -> Either Text UUID # | |
PathPiece UUID Source # | |
Defined in Init fromPathPiece :: Text -> Maybe UUID # toPathPiece :: UUID -> Text # | |
PersistFieldSql UUID Source # | |
PersistField UUID Source # | |
Defined in Init toPersistValue :: UUID -> PersistValue # fromPersistValue :: PersistValue -> Either Text UUID # |
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] # |