Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- type DuckDBError = String
- isDuckDBError :: DuckDBState -> Bool
- newtype DuckDBMonad a = DuckDBMonad {}
- liftIO :: MonadIO m => IO a -> m a
- liftIOEither :: IO (Either DuckDBError a) -> DuckDBMonad a
- runDuckDB :: DuckDBMonad a -> IO (Either DuckDBError a)
- version :: DuckDBMonad String
- open :: String -> DuckDBMonad DuckDBDatabase
- configure :: DuckDBMonad DuckDBConfig
- configCount :: DuckDBMonad Int
- getConfigFlag :: Int -> DuckDBMonad (String, String)
- setConfig :: DuckDBConfig -> String -> String -> DuckDBMonad ()
- destroyConfig :: DuckDBConfig -> DuckDBMonad ()
- openExt :: String -> DuckDBConfig -> DuckDBMonad DuckDBDatabase
- connect :: DuckDBDatabase -> DuckDBMonad DuckDBConnection
- defaultConnection :: DuckDBMonad (DuckDBDatabase, DuckDBConnection)
- withDefaultConnection :: ((DuckDBDatabase, DuckDBConnection) -> DuckDBMonad a) -> DuckDBMonad a
- close :: (DuckDBDatabase, DuckDBConnection) -> DuckDBMonad ()
- closeConnection :: DuckDBConnection -> DuckDBMonad ()
- closeDatabase :: DuckDBDatabase -> DuckDBMonad ()
Error reporting
type DuckDBError = String Source #
isDuckDBError :: DuckDBState -> Bool Source #
Monad
newtype DuckDBMonad a Source #
Instances
liftIO :: MonadIO m => IO a -> m 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).
Example
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
, we would have ended up with this error:liftIO
• 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
and returns an IO
a(m a)
:
,
enabling us to run the program and see the expected results:liftIO
> evalStateT printState "hello" "hello" > evalStateT printState 3 3
liftIOEither :: IO (Either DuckDBError a) -> DuckDBMonad a Source #
runDuckDB :: DuckDBMonad a -> IO (Either DuckDBError a) Source #
Version
Database and Connection
open :: String -> DuckDBMonad DuckDBDatabase Source #
getConfigFlag :: Int -> DuckDBMonad (String, String) Source #
:: DuckDBConfig | |
-> String | name |
-> String | option |
-> DuckDBMonad () |
destroyConfig :: DuckDBConfig -> DuckDBMonad () Source #
openExt :: String -> DuckDBConfig -> DuckDBMonad DuckDBDatabase Source #
withDefaultConnection :: ((DuckDBDatabase, DuckDBConnection) -> DuckDBMonad a) -> DuckDBMonad a Source #
close :: (DuckDBDatabase, DuckDBConnection) -> DuckDBMonad () Source #
closeConnection :: DuckDBConnection -> DuckDBMonad () Source #
closeDatabase :: DuckDBDatabase -> DuckDBMonad () Source #