module Control.Monad.Class.MonadSay where

import           Control.Monad.State
import qualified Data.ByteString.Char8 as BSC

class Monad m => MonadSay m where
  say :: String -> m ()

instance MonadSay IO where
  say :: String -> IO ()
say = ByteString -> IO ()
BSC.putStrLn (ByteString -> IO ()) -> (String -> ByteString) -> String -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ByteString
BSC.pack

instance MonadSay m => MonadSay (StateT s m) where
  say :: String -> StateT s m ()
say = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> (String -> m ()) -> String -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> m ()
forall (m :: * -> *). MonadSay m => String -> m ()
say