{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Regfish.Types where import Control.Lens import Control.Monad.Reader import Control.Monad.State import qualified Data.ByteString.Char8 as BS8 import Data.SafeCopy (base, deriveSafeCopy) import Data.Typeable import qualified Network.HTTP.Client as C import qualified Network.Wreq as W deriveSafeCopy 0 'base ''C.CookieJar deriveSafeCopy 0 'base ''W.Cookie newtype Regfish a = Regfish { runRegfish_ :: ReaderT RFConfig (StateT RFState IO) a } deriving ( Applicative , Functor , Monad , MonadIO , MonadReader RFConfig , MonadState RFState ) -- TODO reduce number of aliases? type Password = String type RRaux = Integer type RRdata = String type RRid = Integer type RRname = String type RRttl = Integer type RRtype = String type SessionToken = BS8.ByteString type Url = String type Username = String data RFConfig = RFConfig { _username :: Username , _password :: Password , _allinone :: Url } deriving (Show) data RFState = RFState { _cookieJar :: C.CookieJar } deriving (Show, Typeable) -- ^ TODO rm Show makeLenses ''RFState data RR = RR String String Integer RRData deriving (Show) data RRData = A String | AAAA String | ALIAS String | CNAME String | MX Integer String | NS String | TXT String | SRV String deriving (Show) -- TODO kill Record? data Record = Record String String String Int Int String deriving (Show) deriveSafeCopy 0 'base ''RFState deriveSafeCopy 0 'base ''RFConfig