module Database.InfluxDB.Lens
( Lens, Lens'
, credentials
, httpManager
, user, password
, host, port, ssl
) where
import Control.Applicative
import Data.Text (Text)
import Prelude
import Network.HTTP.Client (Manager)
import Database.InfluxDB.Http
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
type Lens' s a = Lens s s a a
credentials :: Lens' Config Credentials
credentials f r = set <$> f (configCreds r)
where
set c = r { configCreds = c }
httpManager :: Lens' Config Manager
httpManager f c = set <$> f (configHttpManager c)
where
set m = c { configHttpManager = m }
user :: Lens' Credentials Text
user f c = set <$> f (credsUser c)
where
set u = c { credsUser = u }
password :: Lens' Credentials Text
password f s = set <$> f (credsPassword s)
where
set p = s { credsPassword = p }
host :: Lens' Server Text
host f s = set <$> f (serverHost s)
where
set h = s { serverHost = h }
port :: Lens' Server Int
port f s = set <$> f (serverPort s)
where
set p = s { serverPort = p }
ssl :: Lens' Server Bool
ssl f s = set <$> f (serverSsl s)
where
set s' = s { serverSsl = s' }