diff options
Diffstat (limited to 'Regfish/Types.hs')
-rw-r--r-- | Regfish/Types.hs | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Regfish/Types.hs b/Regfish/Types.hs new file mode 100644 index 0000000..cef2808 --- /dev/null +++ b/Regfish/Types.hs @@ -0,0 +1,81 @@ +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE TemplateHaskell #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} + + +module Regfish.Types where + +import Control.Applicative +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 RRData + = A String + | MX Integer String + | CNAME 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 |