{-# LANGUAGE BlockArguments #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# OPTIONS_GHC -Wno-orphans #-} module Telegram.Bot.Simple.Instances where import Data.Text (Text) import Telegram.Bot.Simple.Eff import Telegram.Bot.Simple.Reply (replyText) instance GetAction a a where getNextAction :: BotM a -> BotM (Maybe a) getNextAction BotM a effect = a -> Maybe a forall a. a -> Maybe a Just (a -> Maybe a) -> BotM a -> BotM (Maybe a) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> BotM a effect instance GetAction () a where getNextAction :: BotM () -> BotM (Maybe a) getNextAction BotM () effect = Maybe a forall a. Maybe a Nothing Maybe a -> BotM () -> BotM (Maybe a) forall (f :: * -> *) a b. Functor f => a -> f b -> f a <$ BotM () effect instance GetAction Text a where getNextAction :: BotM Text -> BotM (Maybe a) getNextAction BotM Text effect = BotM () -> BotM (Maybe a) forall return action. GetAction return action => BotM return -> BotM (Maybe action) getNextAction do Text t <- BotM Text effect Text -> BotM () replyText Text t