| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.DuckDB.Simple.Function
Description
This module mirrors the high-level API provided by sqlite-simple for user
defined functions, adapted to DuckDB's chunked execution model. It allows
pure and IO-based Haskell functions to be exposed to SQL while reusing the
existing field-decoding and result-marshalling machinery for arguments and
return values.
Synopsis
- data ScalarType
- data ScalarValue
- class FunctionArg a
- class FunctionResult a
- class Function a where
- argumentTypes :: Proxy a -> [DuckDBType]
- returnType :: Proxy a -> ScalarType
- isVolatile :: Proxy a -> Bool
- applyFunction :: [Field] -> a -> IO ScalarValue
- createFunction :: Function f => Connection -> Text -> f -> IO ()
- createFunctionWithState :: forall s f. Function f => Connection -> Text -> IO s -> (s -> f) -> IO ()
- deleteFunction :: Connection -> Text -> IO ()
Documentation
data ScalarType Source #
Tag DuckDB logical types we support for scalar return values.
data ScalarValue Source #
Runtime representation of values returned to DuckDB.
class FunctionArg a Source #
Argument types supported by the scalar function machinery.
Minimal complete definition
argumentType
Instances
class FunctionResult a Source #
Class of scalar results that can be produced by user-defined functions.
Minimal complete definition
scalarReturnType, toScalarValue
Instances
class Function a where Source #
Typeclass describing Haskell functions that can be exposed to DuckDB.
Methods
argumentTypes :: Proxy a -> [DuckDBType] Source #
returnType :: Proxy a -> ScalarType Source #
isVolatile :: Proxy a -> Bool Source #
applyFunction :: [Field] -> a -> IO ScalarValue Source #
Instances
| FunctionResult a => Function a Source # | |
Defined in Database.DuckDB.Simple.Function Methods argumentTypes :: Proxy a -> [DuckDBType] Source # returnType :: Proxy a -> ScalarType Source # isVolatile :: Proxy a -> Bool Source # applyFunction :: [Field] -> a -> IO ScalarValue Source # | |
| FunctionResult a => Function (IO a) Source # | |
Defined in Database.DuckDB.Simple.Function Methods argumentTypes :: Proxy (IO a) -> [DuckDBType] Source # returnType :: Proxy (IO a) -> ScalarType Source # isVolatile :: Proxy (IO a) -> Bool Source # applyFunction :: [Field] -> IO a -> IO ScalarValue Source # | |
| (FromField a, FunctionArg a, Function r) => Function (a -> r) Source # | |
Defined in Database.DuckDB.Simple.Function Methods argumentTypes :: Proxy (a -> r) -> [DuckDBType] Source # returnType :: Proxy (a -> r) -> ScalarType Source # isVolatile :: Proxy (a -> r) -> Bool Source # applyFunction :: [Field] -> (a -> r) -> IO ScalarValue Source # | |
createFunction :: Function f => Connection -> Text -> f -> IO () Source #
Register a Haskell function under the supplied name.
createFunctionWithState :: forall s f. Function f => Connection -> Text -> IO s -> (s -> f) -> IO () Source #
Register a scalar function with per-worker thread-local state.
deleteFunction :: Connection -> Text -> IO () Source #
Drop a previously registered scalar function by issuing a DROP FUNCTION statement.