Safe Haskell | None |
---|
- data Handle
- newHandle :: IO Handle
- run :: (Any a, FromResponse (Result a)) => Handle -> Exp a -> IO (Res a)
- nextChunk :: FromResponse (Sequence a) => Handle -> Sequence a -> IO (Either Error (Sequence a))
- collect :: FromResponse (Sequence a) => Handle -> Sequence a -> IO (Either Error (Vector a))
- data Error
- = ProtocolError !Text
- | ClientError
- | CompileError
- | RuntimeError
- data Exp a
- type Array = Vector Datum
- type Object = HashMap Text Datum
- data Datum
- data Sequence a
- constant :: IsDatum a => a -> Exp a
- data Table
- data Database
- data SingleSelection
- type Res a = Either Error (Result a)
- emptyOptions :: Object
- class ToJSON a => Any a
- class Any a => IsDatum a
- class IsDatum a => IsObject a
- class Any a => IsSequence a
- db :: Exp Text -> Exp Database
- table :: Exp Text -> Exp Table
- getField :: IsObject o => Exp o -> Exp Text -> Exp Datum
- extractField :: (IsSequence s, IsDatum a) => Exp s -> Exp Text -> Exp (Sequence a)
- get :: Exp Table -> Exp Text -> Exp SingleSelection
- coerceTo :: Any v => Exp v -> Exp Text => Exp Text
- getAll :: IsDatum a => Exp Table -> [Exp a] -> Maybe Text -> Exp Array
- getAllIndexed :: IsDatum a => Exp Table -> [Exp a] -> Text -> Exp (Sequence Datum)
- add :: [Exp Double] -> Exp Double
- insert :: Exp Table -> Object -> Exp Object
- limit :: Any a => Exp a -> Exp Double -> Exp Table
- append :: Exp Array -> Exp Datum -> Exp Array
Documentation
run :: (Any a, FromResponse (Result a)) => Handle -> Exp a -> IO (Res a)Source
Start a new query and wait for its (first) result. If the result is an
single value (Datum
), then three will be no further results. If it is
a sequence, then you must consume results until the sequence ends.
nextChunk :: FromResponse (Sequence a) => Handle -> Sequence a -> IO (Either Error (Sequence a))Source
Get the next chunk of a sequence. It is an error to request the next chunk
if the sequence is already Done
,
collect :: FromResponse (Sequence a) => Handle -> Sequence a -> IO (Either Error (Vector a))Source
Collect all the values in a sequence and make them available as a 'Vector a'.
ProtocolError !Text | An error on the protocol level. Perhaps the socket was closed unexpectedly, or the server sent a message which the driver could not parse. |
ClientError | |
CompileError | |
RuntimeError |
A sumtype covering all the primitive types which can appear in queries or responses.
Sequences are a bounded list of items. The server may split the sequence
into multiple chunks when sending it to the client. When the response is
a partial sequence, the client may request additional chunks until it gets
a Done
.
Tables are something you can select objects from.
This type is not exported, and merely serves as a sort of phantom type. On
the client tables are converted to a Sequence
.
A Database
is something which contains tables. It is a server-only
type.
data SingleSelection Source
SingleSelection
is essentially a 'Maybe Object', where Nothing
is
represented with Null
in the network protocol.
type Res a = Either Error (Result a)Source
The result of a query. It is either an error or a result (which depends
on the type of the query expression). This type is named to be symmetrical
to Exp
, so we get this nice type for run
.
run :: Handle -> Exp a -> IO (Res a)
class ToJSON a => Any a Source
Any value which can appear in RQL terms.
For convenience we require that it can be converted to JSON, but that is
not required for all types. Only types which satisfy IsDatum
are
eventually converted to JSON.
Any Bool | For a boolean type, we're reusing the standard Haskell |
Any Double | Numbers are |
Any Text | For strings, we're using the Haskell |
Any Database | |
Any SingleSelection | |
Any Table | |
Any Object | |
Any Array | |
Any Datum | |
Any a => Any (Sequence a) |
class Any a => IsSequence a Source
IsSequence Table | |
Any a => IsSequence (Sequence a) |
extractField :: (IsSequence s, IsDatum a) => Exp s -> Exp Text -> Exp (Sequence a)Source