duckdb-haskell-0.1.0.0: Haskell bindings for duckdb.
Safe HaskellSafe-Inferred
LanguageGHC2021

Database.DuckDB.Connection

Synopsis

Error reporting

Monad

newtype DuckDBMonad a Source #

Constructors

DuckDBMonad 

Instances

Instances details
MonadIO DuckDBMonad Source # 
Instance details

Defined in Database.DuckDB.Internal

Methods

liftIO :: IO a -> DuckDBMonad a #

Applicative DuckDBMonad Source # 
Instance details

Defined in Database.DuckDB.Internal

Methods

pure :: a -> DuckDBMonad a #

(<*>) :: DuckDBMonad (a -> b) -> DuckDBMonad a -> DuckDBMonad b #

liftA2 :: (a -> b -> c) -> DuckDBMonad a -> DuckDBMonad b -> DuckDBMonad c #

(*>) :: DuckDBMonad a -> DuckDBMonad b -> DuckDBMonad b #

(<*) :: DuckDBMonad a -> DuckDBMonad b -> DuckDBMonad a #

Functor DuckDBMonad Source # 
Instance details

Defined in Database.DuckDB.Internal

Methods

fmap :: (a -> b) -> DuckDBMonad a -> DuckDBMonad b #

(<$) :: a -> DuckDBMonad b -> DuckDBMonad a #

Monad DuckDBMonad Source # 
Instance details

Defined in Database.DuckDB.Internal

Methods

(>>=) :: DuckDBMonad a -> (a -> DuckDBMonad b) -> DuckDBMonad b #

(>>) :: DuckDBMonad a -> DuckDBMonad b -> DuckDBMonad b #

return :: a -> DuckDBMonad a #

MonadError DuckDBError DuckDBMonad Source # 
Instance details

Defined in Database.DuckDB.Internal

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

Expand
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

Version

Database and Connection

setConfig Source #

Arguments

:: DuckDBConfig 
-> String

name

-> String

option

-> DuckDBMonad ()