influxdb-1.9.3.1: InfluxDB client library for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.InfluxDB

Description

 
Synopsis

Documentation

Getting started

This tutorial assumes the following language extensions and imports.

>>> :set -XOverloadedStrings
>>> :set -XRecordWildCards
>>> :set -XTypeApplications
>>> import Database.InfluxDB
>>> import qualified Database.InfluxDB.Format as F
>>> import Control.Lens
>>> import qualified Data.Map as Map
>>> import Data.Time
>>> import qualified Data.Vector as V

The examples below roughly follows the README in the official Go client library.

Creating a database

This library assumes the lens package in some APIs. Here we use ?~ to set the authentication parameters of type Maybe Credentials.

Also note that in order to construct a Query, we use formatQuery with the database formatter. There are many other formatters defined in Database.InfluxDB.Format.

>>> let db = "square_holes"
>>> let bubba = credentials "bubba" "bumblebeetuna"
>>> let p = queryParams db & authentication ?~ bubba
>>> manage p $ formatQuery ("DROP DATABASE "%F.database) db
>>> manage p $ formatQuery ("CREATE DATABASE "%F.database) db

Writing data

write or writeBatch can be used to write data. In general writeBatch should be used for efficiency when writing multiple data points.

>>> let wp = writeParams db & authentication ?~ bubba & precision .~ Second
>>> let cpuUsage = "cpu_usage"
>>> :{
writeBatch wp
  [ Line @UTCTime cpuUsage (Map.singleton "cpu" "cpu-total")
    (Map.fromList
      [ ("idle",   FieldFloat 10.1)
      , ("system", FieldFloat 53.3)
      , ("user",   FieldFloat 46.6)
      ])
    (Just $ parseTimeOrError False defaultTimeLocale
      "%F %T%Q %Z"
      "2017-06-17 15:41:40.42659044 UTC")
  ]
:}

Note that the type signature of the timestamp is necessary. Otherwise it doesn't type check.

Querying data

Using an one-off tuple

If all the field types are an instance of FromJSON, we can use a tuple to store the results.

>>> :set -XDataKinds -XOverloadedStrings -XTypeOperators
>>> type CPUUsage = (Tagged "time" UTCTime, Tagged "idle" Double, Tagged "system" Double, Tagged "user" Double)
>>> v <- query @CPUUsage p $ formatQuery ("SELECT * FROM "%F.measurement) cpuUsage
>>> v
[(Tagged 2017-06-17 15:41:40 UTC,Tagged 10.1,Tagged 53.3,Tagged 46.6)]

Note that the type signature on query here is also necessary to type check. We can remove the tags using untag:

>>> V.map (\(a, b, c, d) -> (untag a, untag b, untag c, untag d)) v :: V.Vector (UTCTime, Double, Double, Double)
[(2017-06-17 15:41:40 UTC,10.1,53.3,46.6)]

Or even using coerce:

>>> import Data.Coerce
>>> coerce v :: V.Vector (UTCTime, Double, Double, Double)
[(2017-06-17 15:41:40 UTC,10.1,53.3,46.6)]

Using a custom data type

We can define our custom data type and write a QueryResults instance instead. getField, parseUTCTime and parseJSON etc are avilable to make it easier to write a JSON decoder.

>>> :{
data CPUUsage = CPUUsage
  { time :: UTCTime
  , cpuIdle, cpuSystem, cpuUser :: Double
  } deriving Show
instance QueryResults CPUUsage where
  parseMeasurement prec _name _tags columns fields = do
    time <- getField "time" columns fields >>= parseUTCTime prec
    cpuIdle <- getField "idle" columns fields >>= parseJSON
    cpuSystem <- getField "system" columns fields >>= parseJSON
    cpuUser <- getField "user" columns fields >>= parseJSON
    return CPUUsage {..}
:}
>>> query @CPUUsage p $ formatQuery ("SELECT * FROM "%F.measurement) cpuUsage
[CPUUsage {time = 2017-06-17 15:41:40 UTC, cpuIdle = 10.1, cpuSystem = 53.3, cpuUser = 46.6}]

Writing data via HTTP

InfluxDB has two ways to write data into it, via HTTP and UDP. This module only exports functions for the HTTP API. For UDP, see Database.InfluxDB.Write.UDP.

write :: Timestamp time => WriteParams -> Line time -> IO () Source #

Write a Line.

>>> let p = writeParams "test-db"
>>> write p $ Line @UTCTime "room_temp" Map.empty (Map.fromList [("temp", FieldFloat 25.0)]) Nothing

writeBatch :: (Timestamp time, Foldable f) => WriteParams -> f (Line time) -> IO () Source #

Write multiple Lines in a batch.

This is more efficient than calling write multiple times.

>>> let p = writeParams "test-db"
>>> :{
writeBatch p
  [ Line @UTCTime "temp" (Map.singleton "city" "tokyo") (Map.fromList [("temp", FieldFloat 25.0)]) Nothing
  , Line @UTCTime "temp" (Map.singleton "city" "osaka") (Map.fromList [("temp", FieldFloat 25.2)]) Nothing
  ]
:}

Write parameters

data WriteParams Source #

The full set of parameters for the HTTP writer.

Following lenses are available to access its fields:

Instances

Instances details
HasCredentials WriteParams Source #

Authentication info for the write

>>> let p = writeParams "foo"
>>> p ^. authentication
Nothing
>>> let p' = p & authentication ?~ credentials "john" "passw0rd"
>>> p' ^. authentication . traverse . user
"john"
Instance details

Defined in Database.InfluxDB.Write

HasDatabase WriteParams Source #
>>> let p = writeParams "foo"
>>> p ^. database
"foo"
Instance details

Defined in Database.InfluxDB.Write

HasManager WriteParams Source #
>>> let p = writeParams "foo" & manager .~ Left HC.defaultManagerSettings
Instance details

Defined in Database.InfluxDB.Write

HasServer WriteParams Source #
>>> let p = writeParams "foo"
>>> p ^. server.host
"localhost"
Instance details

Defined in Database.InfluxDB.Write

HasPrecision 'WriteRequest WriteParams Source #
>>> let p = writeParams "foo"
>>> p ^. precision
Nanosecond
Instance details

Defined in Database.InfluxDB.Write

retentionPolicy :: Lens' WriteParams (Maybe Key) Source #

Target retention policy for the write.

InfluxDB writes to the default retention policy if this parameter is set to Nothing.

>>> let p = writeParams "foo" & retentionPolicy .~ Just "two_hours"
>>> p ^. retentionPolicy
Just "two_hours"

The Line protocol

data Line time Source #

Placeholder for the Line Protocol

See https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_tutorial/ for the concrete syntax.

Constructors

Line !Measurement !(Map Key Key) !(Map Key LineField) !(Maybe time) 

Instances

Instances details
Show time => Show (Line time) Source # 
Instance details

Defined in Database.InfluxDB.Line

Methods

showsPrec :: Int -> Line time -> ShowS #

show :: Line time -> String #

showList :: [Line time] -> ShowS #

measurement :: Lens' (Line time) Measurement Source #

Name of the measurement that you want to write your data to.

tagSet :: Lens' (Line time) (Map Key Key) Source #

Tag(s) that you want to include with your data point. Tags are optional in the Line Protocol, so you can set it empty.

fieldSet :: Lens' (Line time) (Map Key LineField) Source #

Field(s) for your data point. Every data point requires at least one field in the Line Protocol, so it shouldn't be empty.

timestamp :: Lens' (Line time) (Maybe time) Source #

Timestamp for your data point. You can put whatever type of timestamp that is an instance of the Timestamp class.

data Field (n :: Nullability) where Source #

Constructors

FieldInt :: !Int64 -> Field n

Signed 64-bit integers (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807).

FieldFloat :: !Double -> Field n

IEEE-754 64-bit floating-point numbers. This is the default numerical type.

FieldString :: !Text -> Field n

String field. Its length is limited to 64KB, which is not enforced by this library.

FieldBool :: !Bool -> Field n

Boolean field.

FieldNull :: Field 'Nullable

Null field.

Note that a field can be null only in queries. The line protocol doesn't allow null values.

Instances

Instances details
IsString (Field n) Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

fromString :: String -> Field n #

Show (Field n) Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

showsPrec :: Int -> Field n -> ShowS #

show :: Field n -> String #

showList :: [Field n] -> ShowS #

Eq (Field n) Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

(==) :: Field n -> Field n -> Bool #

(/=) :: Field n -> Field n -> Bool #

type LineField = Field 'NonNullable Source #

Field type for the line protocol. The line protocol doesn't accept null values.

type QueryField = Field 'Nullable Source #

Field type for queries. Queries can contain null values.

class Timestamp time where Source #

A Timestamp is something that can be converted to a valid InfluxDB timestamp, which is represented as a 64-bit integer.

Methods

roundTo :: Precision 'WriteRequest -> time -> Int64 Source #

Round a time to the given precision and scale it to nanoseconds

scaleTo :: Precision 'WriteRequest -> time -> Int64 Source #

Scale a time to the given precision

Instances

Instances details
Timestamp TimeSpec Source #
>>> let timespec = TimeSpec 123 123456789
>>> roundTo Nanosecond timespec
123123456789
>>> roundTo Microsecond timespec
123123457000
>>> roundTo Millisecond timespec
123123000000
>>> roundTo Second timespec
123000000000
>>> roundTo Minute timespec
120000000000
>>> roundTo Hour timespec
0
>>> scaleTo Nanosecond timespec
123123456789
>>> scaleTo Microsecond timespec
123123457
>>> scaleTo Millisecond timespec
123123
>>> scaleTo Second timespec
123
>>> scaleTo Minute timespec
2
>>> scaleTo Hour timespec
0
Instance details

Defined in Database.InfluxDB.Types

Timestamp NominalDiffTime Source #
>>> let dt = 123.123456789 :: NominalDiffTime
>>> roundTo Nanosecond dt
123123456789
>>> roundTo Microsecond dt
123123457000
>>> roundTo Millisecond dt
123123000000
>>> roundTo Second dt
123000000000
>>> roundTo Minute dt
120000000000
>>> roundTo Hour dt
0
>>> scaleTo Nanosecond dt
123123456789
>>> scaleTo Microsecond dt
123123457
>>> scaleTo Millisecond dt
123123
>>> scaleTo Second dt
123
>>> scaleTo Minute dt
2
>>> scaleTo Hour dt
0
Instance details

Defined in Database.InfluxDB.Types

Timestamp UTCTime Source #
>>> import Data.Time.Calendar
>>> let t = UTCTime (fromGregorian 2018 04 14) 123.123456789
>>> t
2018-04-14 00:02:03.123456789 UTC
>>> roundTo Nanosecond t
1523664123123456789
>>> roundTo Microsecond t
1523664123123457000
>>> roundTo Millisecond t
1523664123123000000
>>> roundTo Second t
1523664123000000000
>>> roundTo Minute t
1523664120000000000
>>> roundTo Hour t
1523664000000000000
>>> scaleTo Nanosecond t
1523664123123456789
>>> scaleTo Microsecond t
1523664123123457
>>> scaleTo Millisecond t
1523664123123
>>> scaleTo Second t
1523664123
>>> scaleTo Minute t
25394402
>>> scaleTo Hour t
423240
Instance details

Defined in Database.InfluxDB.Types

precisionScale :: Fractional a => Precision ty -> a Source #

Scale of the type precision.

>>> precisionScale RFC3339
1.0e-9
>>> precisionScale Microsecond
1.0e-6

precisionName :: Precision ty -> Text Source #

Name of the time precision.

>>> precisionName Nanosecond
"n"
>>> precisionName Microsecond
"u"
>>> precisionName Millisecond
"ms"
>>> precisionName Second
"s"
>>> precisionName Minute
"m"
>>> precisionName Hour
"h"
>>> precisionName RFC3339
"rfc3339"

Querying data

query and queryChunked can be used to query data. If your dataset fits your memory, query is easier to use. If it doesn't, use queryChunked to stream data.

data Query Source #

An InfluxDB query.

A spec of the format is available at https://docs.influxdata.com/influxdb/v1.7/query_language/spec/.

A Query can be constructed using either

>>> :set -XOverloadedStrings
>>> "SELECT * FROM series" :: Query
"SELECT * FROM series"
>>> import qualified Database.InfluxDB.Format as F
>>> formatQuery ("SELECT * FROM "%F.key) "series"
"SELECT * FROM \"series\""

NOTE: Currently this library doesn't support type-safe query construction.

Instances

Instances details
IsString Query Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

fromString :: String -> Query #

Show Query Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

showsPrec :: Int -> Query -> ShowS #

show :: Query -> String #

showList :: [Query] -> ShowS #

query :: forall a. QueryResults a => QueryParams -> Query -> IO (Vector a) Source #

Query data from InfluxDB.

It may throw InfluxException.

If you need a lower-level interface (e.g. to bypass the QueryResults constraint etc), see withQueryResponse.

queryChunked Source #

Arguments

:: QueryResults a 
=> QueryParams 
-> Optional Int

Chunk size

By Default, InfluxDB chunks responses by series or by every 10,000 points, whichever occurs first. If it set to a Specific value, InfluxDB chunks responses by series or by that number of points.

-> Query 
-> FoldM IO (Vector a) r 
-> IO r 

Same as query but it instructs InfluxDB to stream chunked responses rather than returning a huge JSON object. This can be lot more efficient than query if the result is huge.

It may throw InfluxException.

If you need a lower-level interface (e.g. to bypass the QueryResults constraint etc), see withQueryResponse.

Query construction

There are various utility functions available in Database.InfluxDB.Format. This module is designed to be imported as qualified:

import Database.InfluxDB
import qualified Database.InfluxDB.Format as F

formatQuery :: Format Query r -> r Source #

Format a Query.

>>> F.formatQuery "SELECT * FROM series"
"SELECT * FROM series"
>>> F.formatQuery ("SELECT * FROM "%F.key) "series"
"SELECT * FROM \"series\""

(%) :: Format b c -> Format a b -> Format a c Source #

Format specific synonym of (.).

This is typically easier to use than (.) is because it doesn't conflict with Prelude.(.).

Query parameters

data QueryParams Source #

The full set of parameters for the query API

Following lenses are available to access its fields:

Instances

Instances details
HasCredentials QueryParams Source #

Authentication info for the query

>>> let p = queryParams "foo"
>>> p ^. authentication
Nothing
>>> let p' = p & authentication ?~ credentials "john" "passw0rd"
>>> p' ^. authentication.traverse.user
"john"
Instance details

Defined in Database.InfluxDB.Query

HasDatabase QueryParams Source #
>>> let p = queryParams "foo"
>>> p ^. database
"foo"
Instance details

Defined in Database.InfluxDB.Query

HasManager QueryParams Source #
>>> let p = queryParams "foo" & manager .~ Left HC.defaultManagerSettings
Instance details

Defined in Database.InfluxDB.Query

HasServer QueryParams Source #
>>> let p = queryParams "foo"
>>> p ^. server.host
"localhost"
Instance details

Defined in Database.InfluxDB.Query

HasPrecision 'QueryRequest QueryParams Source #

Returning JSON responses contain timestamps in the specified precision/format.

>>> let p = queryParams "foo"
>>> p ^. precision
RFC3339
Instance details

Defined in Database.InfluxDB.Query

authentication :: HasCredentials a => Lens' a (Maybe Credentials) Source #

User name and password to be used when sending requests to InfluxDB.

decoder :: Lens' QueryParams Decoder Source #

Decoder settings

>>> let p = queryParams "foo"
>>> let _ = p & decoder .~ strictDecoder
>>> let _ = p & decoder .~ lenientDecoder

Parsing results

class QueryResults a where Source #

Types that can be converted from an JSON object returned by InfluxDB.

For example the h2o_feet series in the official document can be encoded as follows:

>>> :{
data H2OFeet = H2OFeet
  { time :: UTCTime
  , levelDesc :: T.Text
  , location :: T.Text
  , waterLevel :: Double
  }
instance QueryResults H2OFeet where
  parseMeasurement prec _name _tags columns fields = do
    time <- getField "time" columns fields >>= parseUTCTime prec
    levelDesc <- getField "level_description" columns fields >>= parseJSON
    location <- getField "location" columns fields >>= parseJSON
    waterLevel <- getField "water_level" columns fields >>= parseJSON
    return H2OFeet {..}
:}

Minimal complete definition

parseMeasurement

Methods

parseMeasurement Source #

Arguments

:: Precision 'QueryRequest

Timestamp precision

-> Maybe Text

Optional series name

-> HashMap Text Text

Tag set

-> Vector Text

Field keys

-> Array

Field values

-> Parser a 

Parse a single measurement in a JSON object.

coerceDecoder :: proxy a -> Maybe Decoder Source #

Always use this Decoder when decoding this type.

Just dec means decoder in QueryParams will be ignored and be replaced with the dec. Nothing means decoder in QueryParams will be used.

Instances

Instances details
QueryResults Void Source #

QueryResults instance for empty results. Used by manage.

NOTE: This instance is deprecated because it's unclear from the name whether it can be used to ignore results. Use Empty when expecting an empty result. Use Ignored if you want to ignore any results.

Instance details

Defined in Database.InfluxDB.Query

QueryResults ShowQuery Source # 
Instance details

Defined in Database.InfluxDB.Manage

QueryResults ShowSeries Source # 
Instance details

Defined in Database.InfluxDB.Manage

QueryResults Empty Source #

QueryResults instance for empty results. Used by manage.

Instance details

Defined in Database.InfluxDB.Query

QueryResults Ignored Source #

QueryResults instance for ignoring results.

Instance details

Defined in Database.InfluxDB.Query

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2) => QueryResults (Tagged k1 v1, Tagged k2 v2) Source #

One-off tuple for sigle-field measurements

Instance details

Defined in Database.InfluxDB.Query

(KnownSymbol k, FromJSON v) => QueryResults (Tagged k v) Source #

One-off type for non-timestamped measurements

>>> let p = queryParams "_internal"
>>> dbs <- query @(Tagged "name" T.Text) p "SHOW DATABASES"
>>> V.find ((== "_internal") . untag) dbs
Just (Tagged "_internal")
Instance details

Defined in Database.InfluxDB.Query

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3) Source #

One-off tuple for two-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4) Source #

One-off tuple for three-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4, KnownSymbol k5, FromJSON v5) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5) Source #

One-off tuple for four-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4, KnownSymbol k5, FromJSON v5, KnownSymbol k6, FromJSON v6) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6) Source #

One-off tuple for five-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4, KnownSymbol k5, FromJSON v5, KnownSymbol k6, FromJSON v6, KnownSymbol k7, FromJSON v7) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7) Source #

One-off tuple for six-field measurement

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4, KnownSymbol k5, FromJSON v5, KnownSymbol k6, FromJSON v6, KnownSymbol k7, FromJSON v7, KnownSymbol k8, FromJSON v8) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7, Tagged k8 v8) Source #

One-off tuple for seven-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7, Tagged k8 v8) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7, Tagged k8 v8) -> Maybe Decoder Source #

data Decoder Source #

A decoder to use when parsing a JSON response.

Use strictDecoder if you want to fail the entire decoding process if there's any failure. Use lenientDecoder if you want the decoding process to collect only successful results.

lenientDecoder :: Decoder Source #

A decoder that ignores parse failures and returns only successful results.

strictDecoder :: Decoder Source #

A decoder that fails immediately if there's any parse failure.

strictDecoder is defined as follows:

strictDecoder :: Decoder
strictDecoder = Decoder $ SomeDecoder
 { decodeEach = id
 , decodeFold = id
 }

Helper types and functions

data Ignored Source #

Ignored can be used in the result type of query when the result values are not needed.

>>> v <- query @Ignored (queryParams "dummy") "SHOW DATABASES"
>>> v
[]

Instances

Instances details
Show Ignored Source # 
Instance details

Defined in Database.InfluxDB.Query

QueryResults Ignored Source #

QueryResults instance for ignoring results.

Instance details

Defined in Database.InfluxDB.Query

data Empty Source #

Empty can be used in the result type of query when the expected results are always empty. Note that if the results are not empty, the decoding process will fail:

>>> let p = queryParams "empty"
>>> Database.InfluxDB.Manage.manage p "CREATE DATABASE empty"
>>> v <- query @Empty p "SELECT * FROM empty" -- query an empty series
>>> v
[]

Instances

Instances details
Show Empty Source # 
Instance details

Defined in Database.InfluxDB.Query

Methods

showsPrec :: Int -> Empty -> ShowS #

show :: Empty -> String #

showList :: [Empty] -> ShowS #

QueryResults Empty Source #

QueryResults instance for empty results. Used by manage.

Instance details

Defined in Database.InfluxDB.Query

newtype Tagged (s :: k) b #

A Tagged s b value is a value b with an attached phantom type s. This can be used in place of the more traditional but less safe idiom of passing in an undefined value with the type, because unlike an (s -> b), a Tagged s b can't try to use the argument s as a real value.

Moreover, you don't have to rely on the compiler to inline away the extra argument, because the newtype is "free"

Tagged has kind k -> * -> * if the compiler supports PolyKinds, therefore there is an extra k showing in the instance haddocks that may cause confusion.

Constructors

Tagged 

Fields

Instances

Instances details
Generic1 (Tagged s :: Type -> Type) 
Instance details

Defined in Data.Tagged

Associated Types

type Rep1 (Tagged s) :: k -> Type #

Methods

from1 :: forall (a :: k). Tagged s a -> Rep1 (Tagged s) a #

to1 :: forall (a :: k). Rep1 (Tagged s) a -> Tagged s a #

FromJSON2 (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON2 :: Maybe a -> (Value -> Parser a) -> (Value -> Parser [a]) -> Maybe b -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser (Tagged a b) #

liftParseJSONList2 :: Maybe a -> (Value -> Parser a) -> (Value -> Parser [a]) -> Maybe b -> (Value -> Parser b) -> (Value -> Parser [b]) -> Value -> Parser [Tagged a b] #

liftOmittedField2 :: Maybe a -> Maybe b -> Maybe (Tagged a b) #

ToJSON2 (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON2 :: (a -> Bool) -> (a -> Value) -> ([a] -> Value) -> (b -> Bool) -> (b -> Value) -> ([b] -> Value) -> Tagged a b -> Value #

liftToJSONList2 :: (a -> Bool) -> (a -> Value) -> ([a] -> Value) -> (b -> Bool) -> (b -> Value) -> ([b] -> Value) -> [Tagged a b] -> Value #

liftToEncoding2 :: (a -> Bool) -> (a -> Encoding) -> ([a] -> Encoding) -> (b -> Bool) -> (b -> Encoding) -> ([b] -> Encoding) -> Tagged a b -> Encoding #

liftToEncodingList2 :: (a -> Bool) -> (a -> Encoding) -> ([a] -> Encoding) -> (b -> Bool) -> (b -> Encoding) -> ([b] -> Encoding) -> [Tagged a b] -> Encoding #

liftOmitField2 :: (a -> Bool) -> (b -> Bool) -> Tagged a b -> Bool #

Bifoldable (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Tagged

Methods

bifold :: Monoid m => Tagged m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Tagged a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Tagged a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Tagged a b -> c #

Bifoldable1 (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Tagged

Methods

bifold1 :: Semigroup m => Tagged m m -> m #

bifoldMap1 :: Semigroup m => (a -> m) -> (b -> m) -> Tagged a b -> m #

Bifunctor (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Tagged

Methods

bimap :: (a -> b) -> (c -> d) -> Tagged a c -> Tagged b d #

first :: (a -> b) -> Tagged a c -> Tagged b c #

second :: (b -> c) -> Tagged a b -> Tagged a c #

Bitraversable (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Tagged

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Tagged a b -> f (Tagged c d) #

Eq2 (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Tagged

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> Tagged a c -> Tagged b d -> Bool #

Ord2 (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Tagged

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> Tagged a c -> Tagged b d -> Ordering #

Read2 (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Tagged

Methods

liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Tagged a b) #

liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Tagged a b] #

liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Tagged a b) #

liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Tagged a b] #

Show2 (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Tagged

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> Tagged a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [Tagged a b] -> ShowS #

Choice (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Choice

Methods

left' :: Tagged a b -> Tagged (Either a c) (Either b c) #

right' :: Tagged a b -> Tagged (Either c a) (Either c b) #

Corepresentable (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Rep

Associated Types

type Corep Tagged :: Type -> Type #

Methods

cotabulate :: (Corep Tagged d -> c) -> Tagged d c #

Profunctor (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Unsafe

Methods

dimap :: (a -> b) -> (c -> d) -> Tagged b c -> Tagged a d #

lmap :: (a -> b) -> Tagged b c -> Tagged a c #

rmap :: (b -> c) -> Tagged a b -> Tagged a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Tagged a b -> Tagged a c #

(.#) :: forall a b c q. Coercible b a => Tagged b c -> q a b -> Tagged a c #

Bitraversable1 (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Semigroup.Traversable.Class

Methods

bitraverse1 :: Apply f => (a -> f b) -> (c -> f d) -> Tagged a c -> f (Tagged b d) #

bisequence1 :: Apply f => Tagged (f a) (f b) -> f (Tagged a b) #

Representable (Tagged t) 
Instance details

Defined in Data.Functor.Rep

Associated Types

type Rep (Tagged t) #

Methods

tabulate :: (Rep (Tagged t) -> a) -> Tagged t a #

index :: Tagged t a -> Rep (Tagged t) -> a #

FromJSON1 (Tagged a) 
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

liftParseJSON :: Maybe a0 -> (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser (Tagged a a0) #

liftParseJSONList :: Maybe a0 -> (Value -> Parser a0) -> (Value -> Parser [a0]) -> Value -> Parser [Tagged a a0] #

liftOmittedField :: Maybe a0 -> Maybe (Tagged a a0) #

ToJSON1 (Tagged a) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

liftToJSON :: (a0 -> Bool) -> (a0 -> Value) -> ([a0] -> Value) -> Tagged a a0 -> Value #

liftToJSONList :: (a0 -> Bool) -> (a0 -> Value) -> ([a0] -> Value) -> [Tagged a a0] -> Value #

liftToEncoding :: (a0 -> Bool) -> (a0 -> Encoding) -> ([a0] -> Encoding) -> Tagged a a0 -> Encoding #

liftToEncodingList :: (a0 -> Bool) -> (a0 -> Encoding) -> ([a0] -> Encoding) -> [Tagged a a0] -> Encoding #

liftOmitField :: (a0 -> Bool) -> Tagged a a0 -> Bool #

Foldable (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

fold :: Monoid m => Tagged s m -> m #

foldMap :: Monoid m => (a -> m) -> Tagged s a -> m #

foldMap' :: Monoid m => (a -> m) -> Tagged s a -> m #

foldr :: (a -> b -> b) -> b -> Tagged s a -> b #

foldr' :: (a -> b -> b) -> b -> Tagged s a -> b #

foldl :: (b -> a -> b) -> b -> Tagged s a -> b #

foldl' :: (b -> a -> b) -> b -> Tagged s a -> b #

foldr1 :: (a -> a -> a) -> Tagged s a -> a #

foldl1 :: (a -> a -> a) -> Tagged s a -> a #

toList :: Tagged s a -> [a] #

null :: Tagged s a -> Bool #

length :: Tagged s a -> Int #

elem :: Eq a => a -> Tagged s a -> Bool #

maximum :: Ord a => Tagged s a -> a #

minimum :: Ord a => Tagged s a -> a #

sum :: Num a => Tagged s a -> a #

product :: Num a => Tagged s a -> a #

Foldable1 (Tagged a) 
Instance details

Defined in Data.Tagged

Methods

fold1 :: Semigroup m => Tagged a m -> m #

foldMap1 :: Semigroup m => (a0 -> m) -> Tagged a a0 -> m #

foldMap1' :: Semigroup m => (a0 -> m) -> Tagged a a0 -> m #

toNonEmpty :: Tagged a a0 -> NonEmpty a0 #

maximum :: Ord a0 => Tagged a a0 -> a0 #

minimum :: Ord a0 => Tagged a a0 -> a0 #

head :: Tagged a a0 -> a0 #

last :: Tagged a a0 -> a0 #

foldrMap1 :: (a0 -> b) -> (a0 -> b -> b) -> Tagged a a0 -> b #

foldlMap1' :: (a0 -> b) -> (b -> a0 -> b) -> Tagged a a0 -> b #

foldlMap1 :: (a0 -> b) -> (b -> a0 -> b) -> Tagged a a0 -> b #

foldrMap1' :: (a0 -> b) -> (a0 -> b -> b) -> Tagged a a0 -> b #

Eq1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftEq :: (a -> b -> Bool) -> Tagged s a -> Tagged s b -> Bool #

Ord1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftCompare :: (a -> b -> Ordering) -> Tagged s a -> Tagged s b -> Ordering #

Read1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Tagged s a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Tagged s a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Tagged s a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Tagged s a] #

Show1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tagged s a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tagged s a] -> ShowS #

Traversable (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

traverse :: Applicative f => (a -> f b) -> Tagged s a -> f (Tagged s b) #

sequenceA :: Applicative f => Tagged s (f a) -> f (Tagged s a) #

mapM :: Monad m => (a -> m b) -> Tagged s a -> m (Tagged s b) #

sequence :: Monad m => Tagged s (m a) -> m (Tagged s a) #

Applicative (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

pure :: a -> Tagged s a #

(<*>) :: Tagged s (a -> b) -> Tagged s a -> Tagged s b #

liftA2 :: (a -> b -> c) -> Tagged s a -> Tagged s b -> Tagged s c #

(*>) :: Tagged s a -> Tagged s b -> Tagged s b #

(<*) :: Tagged s a -> Tagged s b -> Tagged s a #

Functor (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

fmap :: (a -> b) -> Tagged s a -> Tagged s b #

(<$) :: a -> Tagged s b -> Tagged s a #

Monad (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

(>>=) :: Tagged s a -> (a -> Tagged s b) -> Tagged s b #

(>>) :: Tagged s a -> Tagged s b -> Tagged s b #

return :: a -> Tagged s a #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2) => QueryResults (Tagged k1 v1, Tagged k2 v2) Source #

One-off tuple for sigle-field measurements

Instance details

Defined in Database.InfluxDB.Query

Traversable1 (Tagged a) 
Instance details

Defined in Data.Semigroup.Traversable.Class

Methods

traverse1 :: Apply f => (a0 -> f b) -> Tagged a a0 -> f (Tagged a b) #

sequence1 :: Apply f => Tagged a (f b) -> f (Tagged a b) #

FromJSON b => FromJSON (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey b => FromJSONKey (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.FromJSON

ToJSON b => ToJSON (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

toJSON :: Tagged a b -> Value #

toEncoding :: Tagged a b -> Encoding #

toJSONList :: [Tagged a b] -> Value #

toEncodingList :: [Tagged a b] -> Encoding #

omitField :: Tagged a b -> Bool #

ToJSONKey b => ToJSONKey (Tagged a b) 
Instance details

Defined in Data.Aeson.Types.ToJSON

(Data s, Data b) => Data (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Tagged s b -> c (Tagged s b) #

gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Tagged s b) #

toConstr :: Tagged s b -> Constr #

dataTypeOf :: Tagged s b -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Tagged s b)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Tagged s b)) #

gmapT :: (forall b0. Data b0 => b0 -> b0) -> Tagged s b -> Tagged s b #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tagged s b -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tagged s b -> r #

gmapQ :: (forall d. Data d => d -> u) -> Tagged s b -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Tagged s b -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tagged s b -> m (Tagged s b) #

IsString a => IsString (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

fromString :: String -> Tagged s a #

Storable a => Storable (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

sizeOf :: Tagged s a -> Int #

alignment :: Tagged s a -> Int #

peekElemOff :: Ptr (Tagged s a) -> Int -> IO (Tagged s a) #

pokeElemOff :: Ptr (Tagged s a) -> Int -> Tagged s a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Tagged s a) #

pokeByteOff :: Ptr b -> Int -> Tagged s a -> IO () #

peek :: Ptr (Tagged s a) -> IO (Tagged s a) #

poke :: Ptr (Tagged s a) -> Tagged s a -> IO () #

(Semigroup a, Monoid a) => Monoid (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

mempty :: Tagged s a #

mappend :: Tagged s a -> Tagged s a -> Tagged s a #

mconcat :: [Tagged s a] -> Tagged s a #

Semigroup a => Semigroup (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(<>) :: Tagged s a -> Tagged s a -> Tagged s a #

sconcat :: NonEmpty (Tagged s a) -> Tagged s a #

stimes :: Integral b => b -> Tagged s a -> Tagged s a #

Bits a => Bits (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(.&.) :: Tagged s a -> Tagged s a -> Tagged s a #

(.|.) :: Tagged s a -> Tagged s a -> Tagged s a #

xor :: Tagged s a -> Tagged s a -> Tagged s a #

complement :: Tagged s a -> Tagged s a #

shift :: Tagged s a -> Int -> Tagged s a #

rotate :: Tagged s a -> Int -> Tagged s a #

zeroBits :: Tagged s a #

bit :: Int -> Tagged s a #

setBit :: Tagged s a -> Int -> Tagged s a #

clearBit :: Tagged s a -> Int -> Tagged s a #

complementBit :: Tagged s a -> Int -> Tagged s a #

testBit :: Tagged s a -> Int -> Bool #

bitSizeMaybe :: Tagged s a -> Maybe Int #

bitSize :: Tagged s a -> Int #

isSigned :: Tagged s a -> Bool #

shiftL :: Tagged s a -> Int -> Tagged s a #

unsafeShiftL :: Tagged s a -> Int -> Tagged s a #

shiftR :: Tagged s a -> Int -> Tagged s a #

unsafeShiftR :: Tagged s a -> Int -> Tagged s a #

rotateL :: Tagged s a -> Int -> Tagged s a #

rotateR :: Tagged s a -> Int -> Tagged s a #

popCount :: Tagged s a -> Int #

FiniteBits a => FiniteBits (Tagged s a) 
Instance details

Defined in Data.Tagged

Bounded b => Bounded (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

minBound :: Tagged s b #

maxBound :: Tagged s b #

Enum a => Enum (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

succ :: Tagged s a -> Tagged s a #

pred :: Tagged s a -> Tagged s a #

toEnum :: Int -> Tagged s a #

fromEnum :: Tagged s a -> Int #

enumFrom :: Tagged s a -> [Tagged s a] #

enumFromThen :: Tagged s a -> Tagged s a -> [Tagged s a] #

enumFromTo :: Tagged s a -> Tagged s a -> [Tagged s a] #

enumFromThenTo :: Tagged s a -> Tagged s a -> Tagged s a -> [Tagged s a] #

Floating a => Floating (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

pi :: Tagged s a #

exp :: Tagged s a -> Tagged s a #

log :: Tagged s a -> Tagged s a #

sqrt :: Tagged s a -> Tagged s a #

(**) :: Tagged s a -> Tagged s a -> Tagged s a #

logBase :: Tagged s a -> Tagged s a -> Tagged s a #

sin :: Tagged s a -> Tagged s a #

cos :: Tagged s a -> Tagged s a #

tan :: Tagged s a -> Tagged s a #

asin :: Tagged s a -> Tagged s a #

acos :: Tagged s a -> Tagged s a #

atan :: Tagged s a -> Tagged s a #

sinh :: Tagged s a -> Tagged s a #

cosh :: Tagged s a -> Tagged s a #

tanh :: Tagged s a -> Tagged s a #

asinh :: Tagged s a -> Tagged s a #

acosh :: Tagged s a -> Tagged s a #

atanh :: Tagged s a -> Tagged s a #

log1p :: Tagged s a -> Tagged s a #

expm1 :: Tagged s a -> Tagged s a #

log1pexp :: Tagged s a -> Tagged s a #

log1mexp :: Tagged s a -> Tagged s a #

RealFloat a => RealFloat (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

floatRadix :: Tagged s a -> Integer #

floatDigits :: Tagged s a -> Int #

floatRange :: Tagged s a -> (Int, Int) #

decodeFloat :: Tagged s a -> (Integer, Int) #

encodeFloat :: Integer -> Int -> Tagged s a #

exponent :: Tagged s a -> Int #

significand :: Tagged s a -> Tagged s a #

scaleFloat :: Int -> Tagged s a -> Tagged s a #

isNaN :: Tagged s a -> Bool #

isInfinite :: Tagged s a -> Bool #

isDenormalized :: Tagged s a -> Bool #

isNegativeZero :: Tagged s a -> Bool #

isIEEE :: Tagged s a -> Bool #

atan2 :: Tagged s a -> Tagged s a -> Tagged s a #

Generic (Tagged s b) 
Instance details

Defined in Data.Tagged

Associated Types

type Rep (Tagged s b) :: Type -> Type #

Methods

from :: Tagged s b -> Rep (Tagged s b) x #

to :: Rep (Tagged s b) x -> Tagged s b #

Ix b => Ix (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

range :: (Tagged s b, Tagged s b) -> [Tagged s b] #

index :: (Tagged s b, Tagged s b) -> Tagged s b -> Int #

unsafeIndex :: (Tagged s b, Tagged s b) -> Tagged s b -> Int #

inRange :: (Tagged s b, Tagged s b) -> Tagged s b -> Bool #

rangeSize :: (Tagged s b, Tagged s b) -> Int #

unsafeRangeSize :: (Tagged s b, Tagged s b) -> Int #

Num a => Num (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(+) :: Tagged s a -> Tagged s a -> Tagged s a #

(-) :: Tagged s a -> Tagged s a -> Tagged s a #

(*) :: Tagged s a -> Tagged s a -> Tagged s a #

negate :: Tagged s a -> Tagged s a #

abs :: Tagged s a -> Tagged s a #

signum :: Tagged s a -> Tagged s a #

fromInteger :: Integer -> Tagged s a #

Read b => Read (Tagged s b) 
Instance details

Defined in Data.Tagged

Fractional a => Fractional (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

(/) :: Tagged s a -> Tagged s a -> Tagged s a #

recip :: Tagged s a -> Tagged s a #

fromRational :: Rational -> Tagged s a #

Integral a => Integral (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

quot :: Tagged s a -> Tagged s a -> Tagged s a #

rem :: Tagged s a -> Tagged s a -> Tagged s a #

div :: Tagged s a -> Tagged s a -> Tagged s a #

mod :: Tagged s a -> Tagged s a -> Tagged s a #

quotRem :: Tagged s a -> Tagged s a -> (Tagged s a, Tagged s a) #

divMod :: Tagged s a -> Tagged s a -> (Tagged s a, Tagged s a) #

toInteger :: Tagged s a -> Integer #

Real a => Real (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

toRational :: Tagged s a -> Rational #

RealFrac a => RealFrac (Tagged s a) 
Instance details

Defined in Data.Tagged

Methods

properFraction :: Integral b => Tagged s a -> (b, Tagged s a) #

truncate :: Integral b => Tagged s a -> b #

round :: Integral b => Tagged s a -> b #

ceiling :: Integral b => Tagged s a -> b #

floor :: Integral b => Tagged s a -> b #

Show b => Show (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

showsPrec :: Int -> Tagged s b -> ShowS #

show :: Tagged s b -> String #

showList :: [Tagged s b] -> ShowS #

NFData b => NFData (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

rnf :: Tagged s b -> () #

Eq b => Eq (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

(==) :: Tagged s b -> Tagged s b -> Bool #

(/=) :: Tagged s b -> Tagged s b -> Bool #

Ord b => Ord (Tagged s b) 
Instance details

Defined in Data.Tagged

Methods

compare :: Tagged s b -> Tagged s b -> Ordering #

(<) :: Tagged s b -> Tagged s b -> Bool #

(<=) :: Tagged s b -> Tagged s b -> Bool #

(>) :: Tagged s b -> Tagged s b -> Bool #

(>=) :: Tagged s b -> Tagged s b -> Bool #

max :: Tagged s b -> Tagged s b -> Tagged s b #

min :: Tagged s b -> Tagged s b -> Tagged s b #

(KnownSymbol k, FromJSON v) => QueryResults (Tagged k v) Source #

One-off type for non-timestamped measurements

>>> let p = queryParams "_internal"
>>> dbs <- query @(Tagged "name" T.Text) p "SHOW DATABASES"
>>> V.find ((== "_internal") . untag) dbs
Just (Tagged "_internal")
Instance details

Defined in Database.InfluxDB.Query

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3) Source #

One-off tuple for two-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3) -> Maybe Decoder Source #

Wrapped (Tagged s a) 
Instance details

Defined in Control.Lens.Wrapped

Associated Types

type Unwrapped (Tagged s a) #

Methods

_Wrapped' :: Iso' (Tagged s a) (Unwrapped (Tagged s a)) #

t ~ Tagged s' a' => Rewrapped (Tagged s a) t 
Instance details

Defined in Control.Lens.Wrapped

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4) Source #

One-off tuple for three-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4, KnownSymbol k5, FromJSON v5) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5) Source #

One-off tuple for four-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4, KnownSymbol k5, FromJSON v5, KnownSymbol k6, FromJSON v6) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6) Source #

One-off tuple for five-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4, KnownSymbol k5, FromJSON v5, KnownSymbol k6, FromJSON v6, KnownSymbol k7, FromJSON v7) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7) Source #

One-off tuple for six-field measurement

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7) -> Maybe Decoder Source #

(KnownSymbol k1, FromJSON v1, KnownSymbol k2, FromJSON v2, KnownSymbol k3, FromJSON v3, KnownSymbol k4, FromJSON v4, KnownSymbol k5, FromJSON v5, KnownSymbol k6, FromJSON v6, KnownSymbol k7, FromJSON v7, KnownSymbol k8, FromJSON v8) => QueryResults (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7, Tagged k8 v8) Source #

One-off tuple for seven-field measurements

Instance details

Defined in Database.InfluxDB.Query

Methods

parseMeasurement :: Precision 'QueryRequest -> Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7, Tagged k8 v8) Source #

coerceDecoder :: proxy (Tagged k1 v1, Tagged k2 v2, Tagged k3 v3, Tagged k4 v4, Tagged k5 v5, Tagged k6 v6, Tagged k7 v7, Tagged k8 v8) -> Maybe Decoder Source #

type Rep1 (Tagged s :: Type -> Type) 
Instance details

Defined in Data.Tagged

type Rep1 (Tagged s :: Type -> Type) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.8-5pABEsRRePW4CriBGxxhqf" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Corep (Tagged :: Type -> Type -> Type) 
Instance details

Defined in Data.Profunctor.Rep

type Corep (Tagged :: Type -> Type -> Type) = Proxy :: Type -> Type
type Rep (Tagged t) 
Instance details

Defined in Data.Functor.Rep

type Rep (Tagged t) = ()
type Rep (Tagged s b) 
Instance details

Defined in Data.Tagged

type Rep (Tagged s b) = D1 ('MetaData "Tagged" "Data.Tagged" "tagged-0.8.8-5pABEsRRePW4CriBGxxhqf" 'True) (C1 ('MetaCons "Tagged" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTagged") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 b)))
type Unwrapped (Tagged s a) 
Instance details

Defined in Control.Lens.Wrapped

type Unwrapped (Tagged s a) = a

untag :: forall {k} (s :: k) b. Tagged s b -> b #

Alias for unTagged

getField Source #

Arguments

:: MonadFail m 
=> Text

Column name

-> Vector Text

Columns

-> Vector Value

Field values

-> m Value 

Get a field value from a column name

getTag Source #

Arguments

:: MonadFail m 
=> Text

Tag name

-> HashMap Text Value

Tags

-> m Value 

Get a tag value from a tag name

parseUTCTime :: Precision ty -> Value -> Parser UTCTime Source #

Parse either a POSIX timestamp or RFC3339 formatted timestamp as UTCTime.

parsePOSIXTime :: Precision ty -> Value -> Parser POSIXTime Source #

Parse either a POSIX timestamp or RFC3339 formatted timestamp as POSIXTime.

Database management

manage :: QueryParams -> Query -> IO () Source #

Send a database management query to InfluxDB.

>>> let db = "manage-test"
>>> let p = queryParams db
>>> manage p $ F.formatQuery ("CREATE DATABASE "%F.database) db

Common data types and classes

data Precision (ty :: RequestType) where Source #

Predefined set of time precision.

RFC3339 is only available for QueryRequests.

Constructors

Nanosecond :: Precision ty

POSIX time in ns

Microsecond :: Precision ty

POSIX time in μs

Millisecond :: Precision ty

POSIX time in ms

Second :: Precision ty

POSIX time in s

Minute :: Precision ty

POSIX time in minutes

Hour :: Precision ty

POSIX time in hours

RFC3339 :: Precision 'QueryRequest

Nanosecond precision time in a human readable format, like 2016-01-04T00:00:23.135623Z. This is the default format for /query.

Instances

Instances details
Show (Precision a) Source # 
Instance details

Defined in Database.InfluxDB.Types

Eq (Precision a) Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

(==) :: Precision a -> Precision a -> Bool #

(/=) :: Precision a -> Precision a -> Bool #

data Database Source #

Database name.

formatDatabase can be used to construct a Database.

>>> "test-db" :: Database
"test-db"
>>> formatDatabase "test-db"
"test-db"
>>> formatDatabase ("test-db-"%F.decimal) 0
"test-db-0"

Instances

Instances details
IsString Database Source # 
Instance details

Defined in Database.InfluxDB.Types

Show Database Source # 
Instance details

Defined in Database.InfluxDB.Types

Eq Database Source # 
Instance details

Defined in Database.InfluxDB.Types

Ord Database Source # 
Instance details

Defined in Database.InfluxDB.Types

formatDatabase :: Format Database r -> r Source #

Format a Database.

>>> F.formatDatabase "test-db"
"test-db"
>>> F.formatDatabase ("test-db-"%F.decimal) 0
"test-db-0"

data Measurement Source #

String name that is used for measurements.

formatMeasurement can be used to construct a Measurement.

>>> "test-series" :: Measurement
"test-series"
>>> formatMeasurement "test-series"
"test-series"
>>> formatMeasurement ("test-series-"%F.decimal) 0
"test-series-0"

formatMeasurement :: Format Measurement r -> r Source #

Format a Measurement.

>>> F.formatMeasurement "test-series"
"test-series"
>>> F.formatMeasurement ("test-series-"%F.decimal) 0
"test-series-0"

data Key Source #

String type that is used for tag keys/values and field keys.

formatKey can be used to construct a Key.

>>> "test-key" :: Key
"test-key"
>>> formatKey "test-key"
"test-key"
>>> formatKey ("test-key-"%F.decimal) 0
"test-key-0"

Instances

Instances details
IsString Key Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

fromString :: String -> Key #

Show Key Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

Eq Key Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

(==) :: Key -> Key -> Bool #

(/=) :: Key -> Key -> Bool #

Ord Key Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

compare :: Key -> Key -> Ordering #

(<) :: Key -> Key -> Bool #

(<=) :: Key -> Key -> Bool #

(>) :: Key -> Key -> Bool #

(>=) :: Key -> Key -> Bool #

max :: Key -> Key -> Key #

min :: Key -> Key -> Key #

formatKey :: Format Key r -> r Source #

Format a Key.

>>> F.formatKey "test-key"
"test-key"
>>> F.formatKey ("test-key-"%F.decimal) 0
"test-key-0"

data Server Source #

InfluxDB server to connect to.

Following lenses are available to access its fields:

  • host: FQDN or IP address of the InfluxDB server
  • port: Port number of the InfluxDB server
  • ssl: Whether or not to use SSL

Instances

Instances details
Generic Server Source # 
Instance details

Defined in Database.InfluxDB.Types

Associated Types

type Rep Server :: Type -> Type #

Methods

from :: Server -> Rep Server x #

to :: Rep Server x -> Server #

Show Server Source # 
Instance details

Defined in Database.InfluxDB.Types

Eq Server Source # 
Instance details

Defined in Database.InfluxDB.Types

Methods

(==) :: Server -> Server -> Bool #

(/=) :: Server -> Server -> Bool #

Ord Server Source # 
Instance details

Defined in Database.InfluxDB.Types

type Rep Server Source # 
Instance details

Defined in Database.InfluxDB.Types

type Rep Server = D1 ('MetaData "Server" "Database.InfluxDB.Types" "influxdb-1.9.3.1-lY6jJXng982UKuXUOnzAc" 'False) (C1 ('MetaCons "Server" 'PrefixI 'True) (S1 ('MetaSel ('Just "_host") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Just "_port") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "_ssl") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))))

defaultServer :: Server Source #

Default InfluxDB server settings

Default parameters:

>>> defaultServer ^. host
"localhost"
>>> defaultServer ^. port
8086
>>> defaultServer ^. ssl
False

secureServer :: Server Source #

HTTPS-enabled InfluxDB server settings

host :: Lens' Server Text Source #

Host name of the server

port :: Lens' Server Int Source #

Port number of the server

ssl :: Lens' Server Bool Source #

If SSL is enabled

For secure connections (HTTPS), consider using one of the following packages:

data Credentials Source #

User credentials.

Following lenses are available to access its fields:

Instances

Instances details
Show Credentials Source # 
Instance details

Defined in Database.InfluxDB.Types

credentials Source #

Arguments

:: Text

User name

-> Text

Password

-> Credentials 

Smart constructor for Credentials

user :: Lens' Credentials Text Source #

User name to access InfluxDB.

>>> let creds = credentials "john" "passw0rd"
>>> creds ^. user
"john"

password :: Lens' Credentials Text Source #

Password to access InfluxDB

>>> let creds = credentials "john" "passw0rd"
>>> creds ^. password
"passw0rd"

Exception

data InfluxException Source #

Exceptions used in this library.

In general, the library tries to convert exceptions from the dependent libraries to the following types of errors.

Constructors

ServerError String

Server side error.

You can expect to get a successful response once the issue is resolved on the server side.

ClientError String Request

Client side error.

You need to fix your query to get a successful response.

UnexpectedResponse String Request ByteString

Received an unexpected response. The String field is a message and the ByteString field is a possibly-empty relevant payload of the response.

This can happen e.g. when the response from InfluxDB is incompatible with what this library expects due to an upstream format change or when the JSON response doesn't have expected fields etc.

HTTPException HttpException

HTTP communication error.

Typical HTTP errors (4xx and 5xx) are covered by ClientError and ServerError. So this exception means something unusual happened. Note that if checkResponse is overridden to throw an HttpException on an unsuccessful HTTP code, this exception is thrown instead of ClientError or ServerError.

class HasServer a where Source #

Class of data types that have a server field

Methods

server :: Lens' a Server Source #

InfluxDB server address and port that to interact with.

Instances

Instances details
HasServer PingParams Source #
>>> pingParams ^. server.host
"localhost"
Instance details

Defined in Database.InfluxDB.Ping

HasServer QueryParams Source #
>>> let p = queryParams "foo"
>>> p ^. server.host
"localhost"
Instance details

Defined in Database.InfluxDB.Query

HasServer WriteParams Source #
>>> let p = writeParams "foo"
>>> p ^. server.host
"localhost"
Instance details

Defined in Database.InfluxDB.Write

class HasDatabase a where Source #

Class of data types that have a database field

Methods

database :: Lens' a Database Source #

Database name to work on.

Instances

Instances details
HasDatabase ShowQuery Source #
>>> v <- query @ShowQuery (queryParams "_internal") "SHOW QUERIES"
>>> v ^.. each.database
...
Instance details

Defined in Database.InfluxDB.Manage

HasDatabase QueryParams Source #
>>> let p = queryParams "foo"
>>> p ^. database
"foo"
Instance details

Defined in Database.InfluxDB.Query

HasDatabase WriteParams Source #
>>> let p = writeParams "foo"
>>> p ^. database
"foo"
Instance details

Defined in Database.InfluxDB.Write

class HasPrecision (ty :: RequestType) a | a -> ty where Source #

Class of data types that have a precision field

Methods

precision :: Lens' a (Precision ty) Source #

Time precision parameter.

Instances

Instances details
HasPrecision 'QueryRequest QueryParams Source #

Returning JSON responses contain timestamps in the specified precision/format.

>>> let p = queryParams "foo"
>>> p ^. precision
RFC3339
Instance details

Defined in Database.InfluxDB.Query

HasPrecision 'WriteRequest WriteParams Source #
>>> let p = writeParams "foo"
>>> p ^. precision
Nanosecond
Instance details

Defined in Database.InfluxDB.Write

HasPrecision 'WriteRequest WriteParams Source #

Timestamp precision.

In the UDP API, all timestamps are sent in nanosecond but you can specify lower precision. The writer just rounds timestamps to the specified precision.

Instance details

Defined in Database.InfluxDB.Write.UDP

class HasManager a where Source #

Class of data types that have a manager field

Methods

manager :: Lens' a (Either ManagerSettings Manager) Source #

HTTP manager settings or a manager itself.

If it's set to ManagerSettings, the library will create a Manager from the settings for you.

Instances

Instances details
HasManager PingParams Source #
>>> let p = pingParams & manager .~ Left HC.defaultManagerSettings
Instance details

Defined in Database.InfluxDB.Ping

HasManager QueryParams Source #
>>> let p = queryParams "foo" & manager .~ Left HC.defaultManagerSettings
Instance details

Defined in Database.InfluxDB.Query

HasManager WriteParams Source #
>>> let p = writeParams "foo" & manager .~ Left HC.defaultManagerSettings
Instance details

Defined in Database.InfluxDB.Write