Skip to content

Commit

Permalink
Flip runIRCAction for consistency with run*T functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
barrucadu committed Jan 17, 2017
1 parent 04fc189 commit f4e52a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Network/IRC/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ runClient cconf iconf ustate = newIRCState cconf iconf ustate >>= runClientWith
-- utility of this is to be able to run @IRC s a@ actions in order to
-- interact with the client from the outside.
runClientWith :: MonadIO m => IRCState s -> m ()
runClientWith = flip runIRCAction runner
runClientWith = runIRCAction runner


-------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions Network/IRC/Client/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ runner = do
let thePass = get password cconf

-- Initialise the IRC session
let initialise = runIRCAction state $ do
let initialise = flip runIRCAction state $ do
liftIO . atomically $ writeTVar (_connectionState state) Connected
mapM_ (\p -> sendBS $ rawMessage "PASS" [encodeUtf8 p]) thePass
sendBS $ rawMessage "USER" [encodeUtf8 theUser, "-", "-", encodeUtf8 theReal]
Expand Down Expand Up @@ -164,7 +164,7 @@ eventSink lastReceived ircstate = go where
iconf <- snapshot instanceConfig ircstate
forM_ (get handlers iconf) $ \(EventHandler matcher handler) ->
maybe (pure ())
(void . forkIO . runIRCAction ircstate . handler (_source event'))
(void . forkIO . flip runIRCAction ircstate . handler (_source event'))
(matcher event')

-- If disconnected, do not loop.
Expand Down Expand Up @@ -290,8 +290,8 @@ reconnect = do
-- * Utils

-- | Interact with a client from the outside, by using its 'IRCState'.
runIRCAction :: MonadIO m => IRCState s -> IRC s a -> m a
runIRCAction s = liftIO . flip runReaderT s . runIRC
runIRCAction :: MonadIO m => IRC s a -> IRCState s -> m a
runIRCAction ma = liftIO . runReaderT (runIRC ma)

-- | Access the client state.
getIRCState :: IRC s (IRCState s)
Expand Down

0 comments on commit f4e52a9

Please sign in to comment.