Add hPutStr and hPutStrLn (#52)
This commit is contained in:
committed by
Stephen Diehl
parent
41710698ee
commit
307ecd7d6a
@@ -525,6 +525,8 @@
|
||||
* head
|
||||
* headDef
|
||||
* headMay
|
||||
* hPutStr
|
||||
* hPutStrLn
|
||||
* identity
|
||||
* ifM
|
||||
* imagPart
|
||||
|
||||
+17
-10
@@ -14,6 +14,7 @@ module Show (
|
||||
) where
|
||||
|
||||
import qualified Base
|
||||
import qualified System.IO as Base
|
||||
import Data.Function ((.))
|
||||
|
||||
import Control.Monad.IO.Class (MonadIO, liftIO)
|
||||
@@ -26,30 +27,36 @@ import qualified Data.Text.IO as T
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.IO as TL
|
||||
|
||||
import System.IO (Handle, stdout)
|
||||
|
||||
|
||||
class Print a where
|
||||
hPutStr :: MonadIO m => Handle -> a -> m ()
|
||||
putStr :: MonadIO m => a -> m ()
|
||||
putStr = hPutStr stdout
|
||||
hPutStrLn :: MonadIO m => Handle -> a -> m ()
|
||||
putStrLn :: MonadIO m => a -> m ()
|
||||
putStrLn = hPutStrLn stdout
|
||||
|
||||
instance Print T.Text where
|
||||
putStr = liftIO . T.putStr
|
||||
putStrLn = liftIO . T.putStrLn
|
||||
hPutStr = \h -> liftIO . T.hPutStr h
|
||||
hPutStrLn = \h -> liftIO . T.hPutStrLn h
|
||||
|
||||
instance Print TL.Text where
|
||||
putStr = liftIO . TL.putStr
|
||||
putStrLn = liftIO . TL.putStrLn
|
||||
hPutStr = \h -> liftIO . TL.hPutStr h
|
||||
hPutStrLn = \h -> liftIO . TL.hPutStrLn h
|
||||
|
||||
instance Print BS.ByteString where
|
||||
putStr = liftIO . BS.putStr
|
||||
putStrLn = liftIO . BS.putStrLn
|
||||
hPutStr = \h -> liftIO . BS.hPutStr h
|
||||
hPutStrLn = \h -> liftIO . BS.hPutStrLn h
|
||||
|
||||
instance Print BL.ByteString where
|
||||
putStr = liftIO . BL.putStr
|
||||
putStrLn = liftIO . BL.putStrLn
|
||||
hPutStr = \h -> liftIO . BL.hPutStr h
|
||||
hPutStrLn = \h -> liftIO . BL.hPutStrLn h
|
||||
|
||||
instance Print [Base.Char] where
|
||||
putStr = liftIO . Base.putStr
|
||||
putStrLn = liftIO . Base.putStrLn
|
||||
hPutStr = \h -> liftIO . Base.hPutStr h
|
||||
hPutStrLn = \h -> liftIO . Base.hPutStrLn h
|
||||
|
||||
-- For forcing type inference
|
||||
putText :: MonadIO m => T.Text -> m ()
|
||||
|
||||
Reference in New Issue
Block a user