-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A primitive yet easy to use sqlite library. -- -- A primitive yet easy to use sqlite library built using sqlite-direct, -- resource-pool and migrant. @package sqlite-easy @version 0.2.0.1 module Database.Sqlite.Easy.Internal -- | A SQLite3 connection string newtype ConnectionString ConnectionString :: Text -> ConnectionString [unConnectionString] :: ConnectionString -> Text -- | Create a pool of a sqlite3 db with a specific connection string. createSqlitePool :: ConnectionString -> IO (Pool Database) -- | Open a database, run some stuff, close the database. withDb :: ConnectionString -> SQLite a -> IO a -- | Use an active database connection to run some stuff on a database. withDatabase :: Database -> SQLite a -> IO a -- | Use a resource pool to run some stuff on a database. withPool :: Pool Database -> SQLite a -> IO a -- | A SQL statement newtype SQL SQL :: Text -> SQL [unSQL] :: SQL -> Text -- | Run a SQL statement on a database and fetch the results. run :: SQL -> SQLite [[SQLData]] -- | Run a SQL statement with certain parameters on a database and fetch -- the results. runWith :: SQL -> [SQLData] -> SQLite [[SQLData]] -- | Run a statement and fetch all of the data. fetchAll :: Statement -> IO [[SQLData]] -- | The type of actions to run on a SQLite database. In essence, it is -- almost the same as Database -> IO a. -- -- SQLite actions can be created with the run and -- runWith functions, and can be composed using the type class -- instances. -- -- SQLite actions can be run with the withDb, -- withDatabase, and withPool functions. newtype SQLite a SQLite :: (SQLiteStuff -> IO a) -> SQLite a [unSQLite] :: SQLite a -> SQLiteStuff -> IO a data SQLiteStuff SQLiteStuff :: Database -> Maybe Int -> SQLiteStuff [dbConn] :: SQLiteStuff -> Database [transactionNumber] :: SQLiteStuff -> Maybe Int getDB :: SQLite Database runSQLite :: Database -> SQLite a -> IO a -- | Run operations as a transaction. If the action throws an error, the -- transaction is rolled back. For more information, visit: -- https://www.sqlite.org/lang_transaction.html transaction :: forall a. Typeable a => SQLite a -> SQLite a asTransaction' :: Database -> IO a -> IO a -- | Rollback the current (inner-most) transaction by supplying the return -- value. To be used inside transactions. rollback :: Typeable a => a -> SQLite a -- | Rollback all transaction structure by supplying the return value. To -- be used inside transactions. rollbackAll :: Typeable a => a -> SQLite a data RollbackCurrent a RollbackCurrent :: a -> RollbackCurrent a data RollbackAll a RollbackAll :: a -> RollbackAll a instance GHC.Show.Show Database.Sqlite.Easy.Internal.ConnectionString instance Data.String.IsString Database.Sqlite.Easy.Internal.ConnectionString instance GHC.Show.Show Database.Sqlite.Easy.Internal.SQL instance Data.String.IsString Database.Sqlite.Easy.Internal.SQL instance GHC.Base.Semigroup Database.Sqlite.Easy.Internal.SQL instance Control.Monad.IO.Unlift.MonadUnliftIO Database.Sqlite.Easy.Internal.SQLite instance Control.Monad.Fail.MonadFail Database.Sqlite.Easy.Internal.SQLite instance Control.Monad.IO.Class.MonadIO Database.Sqlite.Easy.Internal.SQLite instance GHC.Base.Monad Database.Sqlite.Easy.Internal.SQLite instance GHC.Base.Applicative Database.Sqlite.Easy.Internal.SQLite instance GHC.Base.Functor Database.Sqlite.Easy.Internal.SQLite instance GHC.Show.Show (Database.Sqlite.Easy.Internal.RollbackAll a) instance Data.Typeable.Internal.Typeable a => GHC.Exception.Type.Exception (Database.Sqlite.Easy.Internal.RollbackAll a) instance GHC.Show.Show (Database.Sqlite.Easy.Internal.RollbackCurrent a) instance Data.Typeable.Internal.Typeable a => GHC.Exception.Type.Exception (Database.Sqlite.Easy.Internal.RollbackCurrent a) instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Database.Sqlite.Easy.Internal.SQLite a) instance GHC.Base.Monoid a => GHC.Base.Monoid (Database.Sqlite.Easy.Internal.SQLite a) module Database.Sqlite.Easy.Migrant -- | Execute a migration against the database. A wrapper around migrant's -- migrate for SQLite. migrate :: [MigrationName] -> (MigrationName -> SQLite ()) -> (MigrationName -> SQLite ()) -> SQLite () instance Database.Migrant.Driver.Class.Driver Database.SQLite3.Direct.Database -- | Easy to use interface for SQLite3 using the direct-sqlite -- library. -- -- This can be useful for your toy, hobby projects. module Database.Sqlite.Easy -- | Open a database, run some stuff, close the database. withDb :: ConnectionString -> SQLite a -> IO a -- | Use an active database connection to run some stuff on a database. withDatabase :: Database -> SQLite a -> IO a -- | A SQLite3 connection string newtype ConnectionString ConnectionString :: Text -> ConnectionString [unConnectionString] :: ConnectionString -> Text data Database data Pool a -- | Create a pool of a sqlite3 db with a specific connection string. createSqlitePool :: ConnectionString -> IO (Pool Database) -- | Use a resource pool to run some stuff on a database. withPool :: Pool Database -> SQLite a -> IO a withResource :: Pool a -> (a -> IO r) -> IO r destroyAllResources :: Pool a -> IO () -- | Run a SQL statement on a database and fetch the results. run :: SQL -> SQLite [[SQLData]] -- | Run a SQL statement with certain parameters on a database and fetch -- the results. runWith :: SQL -> [SQLData] -> SQLite [[SQLData]] -- | The type of actions to run on a SQLite database. In essence, it is -- almost the same as Database -> IO a. -- -- SQLite actions can be created with the run and -- runWith functions, and can be composed using the type class -- instances. -- -- SQLite actions can be run with the withDb, -- withDatabase, and withPool functions. data SQLite a -- | Lift a computation from the IO monad. This allows us to run IO -- computations in any monadic stack, so long as it supports these kinds -- of operations (i.e. IO is the base monad for the stack). -- --
-- import Control.Monad.Trans.State -- from the "transformers" library -- -- printState :: Show s => StateT s IO () -- printState = do -- state <- get -- liftIO $ print state ---- -- Had we omitted liftIO, we would have ended up with -- this error: -- --
-- • Couldn't match type ‘IO’ with ‘StateT s IO’ -- Expected type: StateT s IO () -- Actual type: IO () ---- -- The important part here is the mismatch between StateT s IO -- () and IO (). -- -- Luckily, we know of a function that takes an IO a and -- returns an (m a): liftIO, enabling us to run -- the program and see the expected results: -- --
-- > evalStateT printState "hello" -- "hello" -- -- > evalStateT printState 3 -- 3 --liftIO :: MonadIO m => IO a -> m a fromString :: IsString a => String -> a -- | A SQL statement data SQL data SQLData SQLInteger :: !Int64 -> SQLData SQLFloat :: !Double -> SQLData SQLText :: !Text -> SQLData SQLBlob :: !ByteString -> SQLData SQLNull :: SQLData data SQLError SQLError :: !Error -> Text -> Text -> SQLError [sqlError] :: SQLError -> !Error [sqlErrorDetails] :: SQLError -> Text [sqlErrorContext] :: SQLError -> Text data ColumnType IntegerColumn :: ColumnType FloatColumn :: ColumnType TextColumn :: ColumnType BlobColumn :: ColumnType NullColumn :: ColumnType -- | Run operations as a transaction. If the action throws an error, the -- transaction is rolled back. For more information, visit: -- https://www.sqlite.org/lang_transaction.html transaction :: forall a. Typeable a => SQLite a -> SQLite a -- | Rollback the current (inner-most) transaction by supplying the return -- value. To be used inside transactions. rollback :: Typeable a => a -> SQLite a -- | Rollback all transaction structure by supplying the return value. To -- be used inside transactions. rollbackAll :: Typeable a => a -> SQLite a plan :: Driver d => [MigrationName] -> d -> IO [(MigrationDirection, MigrationName)] class Driver d withTransaction :: Driver d => (d -> IO a) -> d -> IO a initMigrations :: Driver d => d -> IO () markUp :: Driver d => MigrationName -> d -> IO () markDown :: Driver d => MigrationName -> d -> IO () getMigrations :: Driver d => d -> IO [MigrationName] data MigrationName data MigrationDirection data DummyDriver DummyDriver :: DummyDriver -- | Execute a migration against the database. A wrapper around migrant's -- migrate for SQLite. migrate :: [MigrationName] -> (MigrationName -> SQLite ()) -> (MigrationName -> SQLite ()) -> SQLite () -- | void value discards or ignores the result of -- evaluation, such as the return value of an IO action. -- --
-- >>> void Nothing -- Nothing -- -- >>> void (Just 3) -- Just () ---- -- Replace the contents of an Either Int -- Int with unit, resulting in an 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 --void :: Functor f => f a -> f () -- | 64-bit signed integer type data Int64 -- | A space efficient, packed, unboxed Unicode text type. data Text -- | 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. data ByteString