{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Web.Slack (
SlackConfig (..),
mkSlackConfig,
apiTest,
authTest,
chatPostMessage,
chatUpdate,
conversationsList,
conversationsListAll,
conversationsHistory,
conversationsHistoryAll,
conversationsReplies,
repliesFetchAll,
getUserDesc,
usersList,
usersListAll,
userLookupByEmail,
UsersConversations.usersConversations,
UsersConversations.usersConversationsAll,
authenticateReq,
Response,
LoadPage,
) where
import Control.Arrow ((&&&))
import Data.Map qualified as Map
import Data.Maybe
import Data.Proxy (Proxy (..))
import Data.Text (Text)
import Network.HTTP.Client (Manager, newManager)
import Network.HTTP.Client.TLS (tlsManagerSettings)
import Servant.API hiding (addHeader)
import Servant.Client hiding (Response, baseUrl)
import Servant.Client.Core (AuthenticatedRequest)
import Web.Slack.Api qualified as Api
import Web.Slack.Auth qualified as Auth
import Web.Slack.Chat qualified as Chat
import Web.Slack.Common qualified as Common
import Web.Slack.Conversation qualified as Conversation
import Web.Slack.Internal
import Web.Slack.Pager
import Web.Slack.User qualified as User
import Web.Slack.UsersConversations qualified as UsersConversations
import Prelude
type Api =
"api.test"
:> ReqBody '[FormUrlEncoded] Api.TestReq
:> Post '[JSON] (ResponseJSON Api.TestRsp)
:<|> "auth.test"
:> AuthProtect "token"
:> Post '[JSON] (ResponseJSON Auth.TestRsp)
:<|> "conversations.list"
:> AuthProtect "token"
:> ReqBody '[FormUrlEncoded] Conversation.ListReq
:> Post '[JSON] (ResponseJSON Conversation.ListRsp)
:<|> "conversations.history"
:> AuthProtect "token"
:> ReqBody '[FormUrlEncoded] Conversation.HistoryReq
:> Post '[JSON] (ResponseJSON Conversation.HistoryRsp)
:<|> "conversations.replies"
:> AuthProtect "token"
:> ReqBody '[FormUrlEncoded] Conversation.RepliesReq
:> Post '[JSON] (ResponseJSON Conversation.HistoryRsp)
:<|> "chat.postMessage"
:> AuthProtect "token"
:> ReqBody '[FormUrlEncoded] Chat.PostMsgReq
:> Post '[JSON] (ResponseJSON Chat.PostMsgRsp)
:<|> "chat.update"
:> AuthProtect "token"
:> ReqBody '[FormUrlEncoded] Chat.UpdateReq
:> Post '[JSON] (ResponseJSON Chat.UpdateRsp)
:<|> "users.list"
:> AuthProtect "token"
:> ReqBody '[FormUrlEncoded] User.ListReq
:> Post '[JSON] (ResponseJSON User.ListRsp)
:<|> "users.lookupByEmail"
:> AuthProtect "token"
:> ReqBody '[FormUrlEncoded] User.Email
:> Post '[JSON] (ResponseJSON User.UserRsp)
apiTest ::
Manager ->
Api.TestReq ->
IO (Response Api.TestRsp)
apiTest :: Manager -> TestReq -> IO (Response TestRsp)
apiTest Manager
mgr TestReq
req = ClientM (ResponseJSON TestRsp) -> Manager -> IO (Response TestRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (TestReq -> ClientM (ResponseJSON TestRsp)
apiTest_ TestReq
req) Manager
mgr
apiTest_ ::
Api.TestReq ->
ClientM (ResponseJSON Api.TestRsp)
authTest ::
SlackConfig ->
IO (Response Auth.TestRsp)
authTest :: SlackConfig -> IO (Response TestRsp)
authTest = do
AuthenticatedRequest (AuthProtect "token")
authR <- SlackConfig -> AuthenticatedRequest (AuthProtect "token")
mkSlackAuthenticateReq
ClientM (ResponseJSON TestRsp) -> Manager -> IO (Response TestRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (AuthenticatedRequest (AuthProtect "token")
-> ClientM (ResponseJSON TestRsp)
authTest_ AuthenticatedRequest (AuthProtect "token")
authR) (Manager -> IO (Response TestRsp))
-> (SlackConfig -> Manager) -> SlackConfig -> IO (Response TestRsp)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> Manager
slackConfigManager
authTest_ ::
AuthenticatedRequest (AuthProtect "token") ->
ClientM (ResponseJSON Auth.TestRsp)
conversationsList ::
SlackConfig ->
Conversation.ListReq ->
IO (Response Conversation.ListRsp)
conversationsList :: SlackConfig -> ListReq -> IO (Response ListRsp)
conversationsList = (ListReq -> SlackConfig -> IO (Response ListRsp))
-> SlackConfig -> ListReq -> IO (Response ListRsp)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((ListReq -> SlackConfig -> IO (Response ListRsp))
-> SlackConfig -> ListReq -> IO (Response ListRsp))
-> (ListReq -> SlackConfig -> IO (Response ListRsp))
-> SlackConfig
-> ListReq
-> IO (Response ListRsp)
forall a b. (a -> b) -> a -> b
$ \ListReq
listReq -> do
AuthenticatedRequest (AuthProtect "token")
authR <- SlackConfig -> AuthenticatedRequest (AuthProtect "token")
mkSlackAuthenticateReq
ClientM (ResponseJSON ListRsp) -> Manager -> IO (Response ListRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (AuthenticatedRequest (AuthProtect "token")
-> ListReq -> ClientM (ResponseJSON ListRsp)
conversationsList_ AuthenticatedRequest (AuthProtect "token")
authR ListReq
listReq) (Manager -> IO (Response ListRsp))
-> (SlackConfig -> Manager) -> SlackConfig -> IO (Response ListRsp)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> Manager
slackConfigManager
conversationsList_ ::
AuthenticatedRequest (AuthProtect "token") ->
Conversation.ListReq ->
ClientM (ResponseJSON Conversation.ListRsp)
conversationsListAll ::
SlackConfig ->
Conversation.ListReq ->
IO (LoadPage IO Conversation.Conversation)
conversationsListAll :: SlackConfig -> ListReq -> IO (LoadPage IO Conversation)
conversationsListAll = (ListReq -> IO (Response ListRsp))
-> ListReq -> IO (LoadPage IO (ResponseObject ListRsp))
(ListReq -> IO (Response ListRsp))
-> ListReq -> IO (LoadPage IO Conversation)
forall (m :: * -> *) req resp.
(MonadIO m, PagedRequest req, PagedResponse resp) =>
(req -> m (Response resp))
-> req -> m (LoadPage m (ResponseObject resp))
fetchAllBy ((ListReq -> IO (Response ListRsp))
-> ListReq -> IO (LoadPage IO Conversation))
-> (SlackConfig -> ListReq -> IO (Response ListRsp))
-> SlackConfig
-> ListReq
-> IO (LoadPage IO Conversation)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> ListReq -> IO (Response ListRsp)
conversationsList
conversationsHistory ::
SlackConfig ->
Conversation.HistoryReq ->
IO (Response Conversation.HistoryRsp)
conversationsHistory :: SlackConfig -> HistoryReq -> IO (Response HistoryRsp)
conversationsHistory = (HistoryReq -> SlackConfig -> IO (Response HistoryRsp))
-> SlackConfig -> HistoryReq -> IO (Response HistoryRsp)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((HistoryReq -> SlackConfig -> IO (Response HistoryRsp))
-> SlackConfig -> HistoryReq -> IO (Response HistoryRsp))
-> (HistoryReq -> SlackConfig -> IO (Response HistoryRsp))
-> SlackConfig
-> HistoryReq
-> IO (Response HistoryRsp)
forall a b. (a -> b) -> a -> b
$ \HistoryReq
histReq -> do
AuthenticatedRequest (AuthProtect "token")
authR <- SlackConfig -> AuthenticatedRequest (AuthProtect "token")
mkSlackAuthenticateReq
ClientM (ResponseJSON HistoryRsp)
-> Manager -> IO (Response HistoryRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (AuthenticatedRequest (AuthProtect "token")
-> HistoryReq -> ClientM (ResponseJSON HistoryRsp)
conversationsHistory_ AuthenticatedRequest (AuthProtect "token")
authR HistoryReq
histReq) (Manager -> IO (Response HistoryRsp))
-> (SlackConfig -> Manager)
-> SlackConfig
-> IO (Response HistoryRsp)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> Manager
slackConfigManager
conversationsHistory_ ::
AuthenticatedRequest (AuthProtect "token") ->
Conversation.HistoryReq ->
ClientM (ResponseJSON Conversation.HistoryRsp)
conversationsReplies ::
SlackConfig ->
Conversation.RepliesReq ->
IO (Response Conversation.HistoryRsp)
conversationsReplies :: SlackConfig -> RepliesReq -> IO (Response HistoryRsp)
conversationsReplies = (RepliesReq -> SlackConfig -> IO (Response HistoryRsp))
-> SlackConfig -> RepliesReq -> IO (Response HistoryRsp)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((RepliesReq -> SlackConfig -> IO (Response HistoryRsp))
-> SlackConfig -> RepliesReq -> IO (Response HistoryRsp))
-> (RepliesReq -> SlackConfig -> IO (Response HistoryRsp))
-> SlackConfig
-> RepliesReq
-> IO (Response HistoryRsp)
forall a b. (a -> b) -> a -> b
$ \RepliesReq
repliesReq -> do
AuthenticatedRequest (AuthProtect "token")
authR <- SlackConfig -> AuthenticatedRequest (AuthProtect "token")
mkSlackAuthenticateReq
ClientM (ResponseJSON HistoryRsp)
-> Manager -> IO (Response HistoryRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (AuthenticatedRequest (AuthProtect "token")
-> RepliesReq -> ClientM (ResponseJSON HistoryRsp)
conversationsReplies_ AuthenticatedRequest (AuthProtect "token")
authR RepliesReq
repliesReq) (Manager -> IO (Response HistoryRsp))
-> (SlackConfig -> Manager)
-> SlackConfig
-> IO (Response HistoryRsp)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> Manager
slackConfigManager
conversationsReplies_ ::
AuthenticatedRequest (AuthProtect "token") ->
Conversation.RepliesReq ->
ClientM (ResponseJSON Conversation.HistoryRsp)
chatPostMessage ::
SlackConfig ->
Chat.PostMsgReq ->
IO (Response Chat.PostMsgRsp)
chatPostMessage :: SlackConfig -> PostMsgReq -> IO (Response PostMsgRsp)
chatPostMessage = (PostMsgReq -> SlackConfig -> IO (Response PostMsgRsp))
-> SlackConfig -> PostMsgReq -> IO (Response PostMsgRsp)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((PostMsgReq -> SlackConfig -> IO (Response PostMsgRsp))
-> SlackConfig -> PostMsgReq -> IO (Response PostMsgRsp))
-> (PostMsgReq -> SlackConfig -> IO (Response PostMsgRsp))
-> SlackConfig
-> PostMsgReq
-> IO (Response PostMsgRsp)
forall a b. (a -> b) -> a -> b
$ \PostMsgReq
postReq -> do
AuthenticatedRequest (AuthProtect "token")
authR <- SlackConfig -> AuthenticatedRequest (AuthProtect "token")
mkSlackAuthenticateReq
ClientM (ResponseJSON PostMsgRsp)
-> Manager -> IO (Response PostMsgRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (AuthenticatedRequest (AuthProtect "token")
-> PostMsgReq -> ClientM (ResponseJSON PostMsgRsp)
chatPostMessage_ AuthenticatedRequest (AuthProtect "token")
authR PostMsgReq
postReq) (Manager -> IO (Response PostMsgRsp))
-> (SlackConfig -> Manager)
-> SlackConfig
-> IO (Response PostMsgRsp)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> Manager
slackConfigManager
chatPostMessage_ ::
AuthenticatedRequest (AuthProtect "token") ->
Chat.PostMsgReq ->
ClientM (ResponseJSON Chat.PostMsgRsp)
chatUpdate ::
SlackConfig ->
Chat.UpdateReq ->
IO (Response Chat.UpdateRsp)
chatUpdate :: SlackConfig -> UpdateReq -> IO (Response UpdateRsp)
chatUpdate = (UpdateReq -> SlackConfig -> IO (Response UpdateRsp))
-> SlackConfig -> UpdateReq -> IO (Response UpdateRsp)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((UpdateReq -> SlackConfig -> IO (Response UpdateRsp))
-> SlackConfig -> UpdateReq -> IO (Response UpdateRsp))
-> (UpdateReq -> SlackConfig -> IO (Response UpdateRsp))
-> SlackConfig
-> UpdateReq
-> IO (Response UpdateRsp)
forall a b. (a -> b) -> a -> b
$ \UpdateReq
updateReq -> do
AuthenticatedRequest (AuthProtect "token")
authR <- SlackConfig -> AuthenticatedRequest (AuthProtect "token")
mkSlackAuthenticateReq
ClientM (ResponseJSON UpdateRsp)
-> Manager -> IO (Response UpdateRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (AuthenticatedRequest (AuthProtect "token")
-> UpdateReq -> ClientM (ResponseJSON UpdateRsp)
chatUpdate_ AuthenticatedRequest (AuthProtect "token")
authR UpdateReq
updateReq) (Manager -> IO (Response UpdateRsp))
-> (SlackConfig -> Manager)
-> SlackConfig
-> IO (Response UpdateRsp)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> Manager
slackConfigManager
chatUpdate_ ::
AuthenticatedRequest (AuthProtect "token") ->
Chat.UpdateReq ->
ClientM (ResponseJSON Chat.UpdateRsp)
usersList ::
SlackConfig ->
User.ListReq ->
IO (Response User.ListRsp)
usersList :: SlackConfig -> ListReq -> IO (Response ListRsp)
usersList SlackConfig
config ListReq
req = do
let authR :: AuthenticatedRequest (AuthProtect "token")
authR = SlackConfig -> AuthenticatedRequest (AuthProtect "token")
mkSlackAuthenticateReq SlackConfig
config
ClientM (ResponseJSON ListRsp) -> Manager -> IO (Response ListRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (AuthenticatedRequest (AuthProtect "token")
-> ListReq -> ClientM (ResponseJSON ListRsp)
usersList_ AuthenticatedRequest (AuthProtect "token")
authR ListReq
req) (SlackConfig -> Manager
slackConfigManager SlackConfig
config)
usersList_ ::
AuthenticatedRequest (AuthProtect "token") ->
User.ListReq ->
ClientM (ResponseJSON User.ListRsp)
usersListAll ::
SlackConfig ->
User.ListReq ->
IO (LoadPage IO User.User)
usersListAll :: SlackConfig -> ListReq -> IO (LoadPage IO User)
usersListAll = (ListReq -> IO (Response ListRsp))
-> ListReq -> IO (LoadPage IO (ResponseObject ListRsp))
(ListReq -> IO (Response ListRsp))
-> ListReq -> IO (LoadPage IO User)
forall (m :: * -> *) req resp.
(MonadIO m, PagedRequest req, PagedResponse resp) =>
(req -> m (Response resp))
-> req -> m (LoadPage m (ResponseObject resp))
fetchAllBy ((ListReq -> IO (Response ListRsp))
-> ListReq -> IO (LoadPage IO User))
-> (SlackConfig -> ListReq -> IO (Response ListRsp))
-> SlackConfig
-> ListReq
-> IO (LoadPage IO User)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> ListReq -> IO (Response ListRsp)
usersList
userLookupByEmail ::
SlackConfig ->
User.Email ->
IO (Response User.UserRsp)
userLookupByEmail :: SlackConfig -> Email -> IO (Response UserRsp)
userLookupByEmail = (Email -> SlackConfig -> IO (Response UserRsp))
-> SlackConfig -> Email -> IO (Response UserRsp)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((Email -> SlackConfig -> IO (Response UserRsp))
-> SlackConfig -> Email -> IO (Response UserRsp))
-> (Email -> SlackConfig -> IO (Response UserRsp))
-> SlackConfig
-> Email
-> IO (Response UserRsp)
forall a b. (a -> b) -> a -> b
$ \Email
email -> do
AuthenticatedRequest (AuthProtect "token")
authR <- SlackConfig -> AuthenticatedRequest (AuthProtect "token")
mkSlackAuthenticateReq
ClientM (ResponseJSON UserRsp) -> Manager -> IO (Response UserRsp)
forall a. ClientM (ResponseJSON a) -> Manager -> IO (Response a)
run (AuthenticatedRequest (AuthProtect "token")
-> Email -> ClientM (ResponseJSON UserRsp)
userLookupByEmail_ AuthenticatedRequest (AuthProtect "token")
authR Email
email) (Manager -> IO (Response UserRsp))
-> (SlackConfig -> Manager) -> SlackConfig -> IO (Response UserRsp)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> Manager
slackConfigManager
userLookupByEmail_ ::
AuthenticatedRequest (AuthProtect "token") ->
User.Email ->
ClientM (ResponseJSON User.UserRsp)
getUserDesc ::
(Common.UserId -> Text) ->
User.ListRsp ->
(Common.UserId -> Text)
getUserDesc :: (UserId -> Text) -> ListRsp -> UserId -> Text
getUserDesc UserId -> Text
unknownUserFn ListRsp
users =
let userMap :: Map UserId Text
userMap = [(UserId, Text)] -> Map UserId Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(UserId, Text)] -> Map UserId Text)
-> [(UserId, Text)] -> Map UserId Text
forall a b. (a -> b) -> a -> b
$ (User -> UserId
User.userId (User -> UserId) -> (User -> Text) -> User -> (UserId, Text)
forall b c c'. (b -> c) -> (b -> c') -> b -> (c, c')
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& User -> Text
User.userName) (User -> (UserId, Text)) -> [User] -> [(UserId, Text)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ListRsp -> [User]
User.listRspMembers ListRsp
users
in \UserId
userId -> Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe (UserId -> Text
unknownUserFn UserId
userId) (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ UserId -> Map UserId Text -> Maybe Text
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup UserId
userId Map UserId Text
userMap
conversationsHistoryAll ::
SlackConfig ->
Conversation.HistoryReq ->
IO (LoadPage IO Common.Message)
conversationsHistoryAll :: SlackConfig -> HistoryReq -> IO (LoadPage IO Message)
conversationsHistoryAll = (HistoryReq -> IO (Response HistoryRsp))
-> HistoryReq -> IO (LoadPage IO (ResponseObject HistoryRsp))
(HistoryReq -> IO (Response HistoryRsp))
-> HistoryReq -> IO (LoadPage IO Message)
forall (m :: * -> *) req resp.
(MonadIO m, PagedRequest req, PagedResponse resp) =>
(req -> m (Response resp))
-> req -> m (LoadPage m (ResponseObject resp))
fetchAllBy ((HistoryReq -> IO (Response HistoryRsp))
-> HistoryReq -> IO (LoadPage IO Message))
-> (SlackConfig -> HistoryReq -> IO (Response HistoryRsp))
-> SlackConfig
-> HistoryReq
-> IO (LoadPage IO Message)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> HistoryReq -> IO (Response HistoryRsp)
conversationsHistory
repliesFetchAll ::
SlackConfig ->
Conversation.RepliesReq ->
IO (LoadPage IO Common.Message)
repliesFetchAll :: SlackConfig -> RepliesReq -> IO (LoadPage IO Message)
repliesFetchAll = (RepliesReq -> IO (Response HistoryRsp))
-> RepliesReq -> IO (LoadPage IO (ResponseObject HistoryRsp))
(RepliesReq -> IO (Response HistoryRsp))
-> RepliesReq -> IO (LoadPage IO Message)
forall (m :: * -> *) req resp.
(MonadIO m, PagedRequest req, PagedResponse resp) =>
(req -> m (Response resp))
-> req -> m (LoadPage m (ResponseObject resp))
fetchAllBy ((RepliesReq -> IO (Response HistoryRsp))
-> RepliesReq -> IO (LoadPage IO Message))
-> (SlackConfig -> RepliesReq -> IO (Response HistoryRsp))
-> SlackConfig
-> RepliesReq
-> IO (LoadPage IO Message)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlackConfig -> RepliesReq -> IO (Response HistoryRsp)
conversationsReplies
TestReq -> ClientM (ResponseJSON TestRsp)
apiTest_
:<|> AuthenticatedRequest (AuthProtect "token")
-> ClientM (ResponseJSON TestRsp)
authTest_
:<|> AuthenticatedRequest (AuthProtect "token")
-> ListReq -> ClientM (ResponseJSON ListRsp)
conversationsList_
:<|> AuthenticatedRequest (AuthProtect "token")
-> HistoryReq -> ClientM (ResponseJSON HistoryRsp)
conversationsHistory_
:<|> AuthenticatedRequest (AuthProtect "token")
-> RepliesReq -> ClientM (ResponseJSON HistoryRsp)
conversationsReplies_
:<|> AuthenticatedRequest (AuthProtect "token")
-> PostMsgReq -> ClientM (ResponseJSON PostMsgRsp)
chatPostMessage_
:<|> AuthenticatedRequest (AuthProtect "token")
-> UpdateReq -> ClientM (ResponseJSON UpdateRsp)
chatUpdate_
:<|> AuthenticatedRequest (AuthProtect "token")
-> ListReq -> ClientM (ResponseJSON ListRsp)
usersList_
:<|> AuthenticatedRequest (AuthProtect "token")
-> Email -> ClientM (ResponseJSON UserRsp)
userLookupByEmail_ =
Proxy Api -> Client ClientM Api
forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (Proxy Api
forall {k} (t :: k). Proxy t
Proxy :: Proxy Api)
mkSlackConfig :: Text -> IO SlackConfig
mkSlackConfig :: Text -> IO SlackConfig
mkSlackConfig Text
token = Manager -> Text -> SlackConfig
SlackConfig (Manager -> Text -> SlackConfig)
-> IO Manager -> IO (Text -> SlackConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ManagerSettings -> IO Manager
newManager ManagerSettings
tlsManagerSettings IO (Text -> SlackConfig) -> IO Text -> IO SlackConfig
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> IO Text
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
token