influxdb-0.5.0: Haskell client library for InfluxDB

Safe HaskellNone

Database.InfluxDB.Decode

Synopsis

Documentation

class FromSeries a whereSource

A type that can be converted from a Series.

fromSeries :: FromSeries a => Series -> Either String aSource

Converte a value from a Series, failing if the types do not match.

class FromSeriesData a whereSource

A type that can be converted from a SeriesData. A typical implementation is as follows.

 import Control.Applicative ((<$>), (<*>))
 import qualified Data.Vector as V

 data Event = Event Text EventType
 data EventType = Login | Logout

 instance FromSeriesData Event where
   parseSeriesData = withValues $ \values -> Event
     <$> values .: "user"
     <*> values .: "type"

 instance FromValue EventType

fromSeriesData :: FromSeriesData a => SeriesData -> Either String [a]Source

Converte a value from a SeriesData, failing if the types do not match.

withValues :: (Vector Value -> ValueParser a) -> Vector Column -> Vector Value -> Parser aSource

Helper function to define parseSeriesData from ValueParsers.

(.:) :: FromValue a => Vector Value -> Column -> ValueParser aSource

Retrieve the value associated with the given column. The result is empty if the column is not present or the value cannot be converted to the desired type.

(.:?) :: FromValue a => Vector Value -> Column -> ValueParser (Maybe a)Source

Retrieve the value associated with the given column. The result is Nothing if the column is not present or the value cannot be converted to the desired type.

(.!=) :: Parser (Maybe a) -> a -> Parser aSource

Helper for use in combination with .:? to provide default values for optional columns.

fromValue :: FromValue a => Value -> Either String aSource

Converte a value from a Value, failing if the types do not match.