module Network.IRC.Client.Lens where
import Control.Concurrent.STM (TVar)
import Control.Monad.Catch (SomeException)
import Data.ByteString (ByteString)
import Data.Profunctor (Choice (right'),
Profunctor (dimap))
import Data.Text (Text)
import Data.Time (NominalDiffTime)
import Network.IRC.Client.Internal.Lens
import Network.IRC.Client.Internal.Types
{-# ANN module ("HLint: ignore Redundant lambda") #-}
{-# INLINE connectionConfig #-}
connectionConfig :: Getter (IRCState s) (ConnectionConfig s)
connectionConfig = \ afb s -> (\ b -> s {_connectionConfig = b}) <$> afb (_connectionConfig s)
{-# INLINE userState #-}
userState :: Lens' (IRCState s) (TVar s)
userState = \ afb s -> (\ b -> s {_userState = b}) <$> afb (_userState s)
{-# INLINE instanceConfig #-}
instanceConfig :: Lens' (IRCState s) (TVar (InstanceConfig s))
instanceConfig = \ afb s -> (\ b -> s {_instanceConfig = b}) <$> afb (_instanceConfig s)
{-# INLINE connectionState #-}
connectionState :: Lens' (IRCState s) (TVar ConnectionState)
connectionState = \ afb s -> (\ b -> s {_connectionState = b}) <$> afb (_connectionState s)
{-# INLINE server #-}
server :: Getter (ConnectionConfig s) ByteString
server = \ afb s -> (\ b -> s {_server = b}) <$> afb (_server s)
{-# INLINE port #-}
port :: Getter (ConnectionConfig s) Int
port = \ afb s -> (\ b -> s {_port = b}) <$> afb (_port s)
{-# INLINE username #-}
username :: Lens' (ConnectionConfig s) Text
username = \ afb s -> (\ b -> s {_username = b}) <$> afb (_username s)
{-# INLINE realname #-}
realname :: Lens' (ConnectionConfig s) Text
realname = \ afb s -> (\ b -> s {_realname = b}) <$> afb (_realname s)
{-# INLINE password #-}
password :: Lens' (ConnectionConfig s) (Maybe Text)
password = \ afb s -> (\ b -> s {_password = b}) <$> afb (_password s)
{-# INLINE flood #-}
flood :: Lens' (ConnectionConfig s) NominalDiffTime
flood = \ afb s -> (\ b -> s {_flood = b}) <$> afb (_flood s)
{-# INLINE timeout #-}
timeout :: Lens' (ConnectionConfig s) NominalDiffTime
timeout = \ afb s -> (\ b -> s {_timeout = b}) <$> afb (_timeout s)
{-# INLINE onconnect #-}
onconnect :: Lens' (ConnectionConfig s) (IRC s ())
onconnect = \ afb s -> (\ b -> s {_onconnect = b}) <$> afb (_onconnect s)
{-# INLINE ondisconnect #-}
ondisconnect :: Lens' (ConnectionConfig s) (Maybe SomeException -> IRC s ())
ondisconnect = \ afb s -> (\ b -> s {_ondisconnect = b}) <$> afb (_ondisconnect s)
{-# INLINE logfunc #-}
logfunc :: Lens' (ConnectionConfig s) (Origin -> ByteString -> IO ())
logfunc = \ afb s -> (\ b -> s {_logfunc = b}) <$> afb (_logfunc s)
{-# INLINE nick #-}
nick :: Lens' (InstanceConfig s) Text
nick = \ afb s -> (\ b -> s {_nick = b}) <$> afb (_nick s)
{-# INLINE channels #-}
channels :: Lens' (InstanceConfig s) [Text]
channels = \ afb s -> (\ b -> s {_channels = b}) <$> afb (_channels s)
{-# INLINE version #-}
version :: Lens' (InstanceConfig s) Text
version = \ afb s -> (\ b -> s {_version = b}) <$> afb (_version s)
{-# INLINE handlers #-}
handlers :: Lens' (InstanceConfig s) [EventHandler s]
handlers = \ afb s -> (\ b -> s {_handlers = b}) <$> afb (_handlers s)
{-# INLINE ignore #-}
ignore :: Lens' (InstanceConfig s) [(Text, Maybe Text)]
ignore = \ afb s -> (\ b -> s {_ignore = b}) <$> afb (_ignore s)
{-# INLINE _Connected #-}
_Connected :: Prism' ConnectionState ()
_Connected = dimap (\ s -> case s of Connected -> Right (); _ -> Left s)
(either pure $ fmap (\ () -> Connected)) . right'
{-# INLINE _Disconnecting #-}
_Disconnecting :: Prism' ConnectionState ()
_Disconnecting = dimap (\ s -> case s of Disconnecting -> Right (); _ -> Left s)
(either pure $ fmap (\ () -> Disconnecting)) . right'
{-# INLINE _Disconnected #-}
_Disconnected :: Prism' ConnectionState ()
_Disconnected = dimap (\ s -> case s of Disconnected -> Right (); _ -> Left s)
(either pure $ fmap (\ () -> Disconnected)) . right'
{-# INLINE _FromServer #-}
_FromServer :: Prism' Origin ()
_FromServer = dimap (\ s -> case s of FromServer -> Right (); _ -> Left s)
(either pure $ fmap (\ () -> FromServer)) . right'
{-# INLINE _FromClient #-}
_FromClient :: Prism' Origin ()
_FromClient = dimap (\ s -> case s of FromClient -> Right (); _ -> Left s)
(either pure $ fmap (\ () -> FromClient)) . right'