Skip to content

Commit

Permalink
Merge branch 'release/v0.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitsutoshi Aoe committed Sep 16, 2014
2 parents aeb49e6 + cc66323 commit 15121f2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## v0.7.1 - 2014-09-16

* Add more lenses

## v0.7.0 - 2014-09-12

* Support for influxdb v0.8 (#15)
Expand Down
4 changes: 2 additions & 2 deletions influxdb.cabal
@@ -1,5 +1,5 @@
name: influxdb
version: 0.7.0
version: 0.7.1
synopsis: Haskell client library for InfluxDB
description: Haskell client library for InfluxDB
homepage: https://github.com/maoe/influxdb-haskell
Expand Down Expand Up @@ -153,5 +153,5 @@ source-repository head

source-repository this
type: git
tag: v0.7.0
tag: v0.7.1
location: https://github.com/maoe/influxdb-haskell.git
41 changes: 40 additions & 1 deletion src/Database/InfluxDB/Lens.hs
@@ -1,26 +1,65 @@
{-# LANGUAGE RankNTypes #-}
module Database.InfluxDB.Lens
( credentials, user, password
( Lens, Lens'

-- * Lenses for 'Config'
, credentials
, httpManager

-- * Lenses for 'Credentials'
, user, password

-- * Lenses for 'Server'
, host, port, ssl
) where
import Control.Applicative
import Data.Text (Text)

import Network.HTTP.Client (Manager)

import Database.InfluxDB.Http

type Lens s t a b = Functor f => (a -> f b) -> s -> f t
type Lens' s a = Lens s s a a

-- | User credentials for authentication
credentials :: Lens' Config Credentials
credentials f r = set <$> f (configCreds r)
where
set c = r { configCreds = c }

-- | An instance of 'Manager' from @http-client@ package
httpManager :: Lens' Config Manager
httpManager f c = set <$> f (configHttpManager c)
where
set m = c { configHttpManager = m }

-- | User name to be used for authentication
user :: Lens' Credentials Text
user f c = set <$> f (credsUser c)
where
set u = c { credsUser = u }

-- | Password to be used for authentication
password :: Lens' Credentials Text
password f s = set <$> f (credsPassword s)
where
set p = s { credsPassword = p }

-- | Host name or IP address of an InfluxDB
host :: Lens' Server Text
host f s = set <$> f (serverHost s)
where
set h = s { serverHost = h }

-- | Port number to be used to connect to an InfluxDB
port :: Lens' Server Int
port f s = set <$> f (serverPort s)
where
set p = s { serverPort = p }

-- | Whether or not to enable SSL connection
ssl :: Lens' Server Bool
ssl f s = set <$> f (serverSsl s)
where
set s' = s { serverSsl = s' }

0 comments on commit 15121f2

Please sign in to comment.