iostring (empty) → 0.0.0.0
raw patch · 4 files changed
+137/−0 lines, 4 filesdep +basedep +bytestringdep +pathsetup-changed
Dependencies added: base, bytestring, path, text
Files
- LICENSE +22/−0
- Setup.hs +2/−0
- iostring.cabal +26/−0
- src/Data/IOString.hs +87/−0
+ LICENSE view
@@ -0,0 +1,22 @@+The MIT License++Copyright (c) 2016 Tom Sydney Kerckhove http://cs-syd.eu++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ iostring.cabal view
@@ -0,0 +1,26 @@+name: iostring+synopsis: A class of strings that can be involved in IO.+description: Strings that can be involved in IO, accesible with Path.+version: 0.0.0.0+cabal-version: >=1.10+build-type: Simple+license: MIT+license-file: LICENSE+copyright: Copyright: (c) 2016 Tom Sydney Kerckhove+maintainer: syd.kerckhove@gmail.com+homepage: http://cs-syd.eu+category: CsSyd+author: Tom Sydney Kerckhove++library+ exposed-modules:+ Data.IOString+ build-depends:+ base >=4.9 && <=5+ , path >=0.5 && <0.6+ , text >=1.2 && <1.3+ , bytestring >=0.10 && <0.11+ default-language: Haskell2010+ default-extensions: NoImplicitPrelude+ hs-source-dirs: src/+ ghc-options: -Wall
+ src/Data/IOString.hs view
@@ -0,0 +1,87 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE NoImplicitPrelude #-}++module Data.IOString+ ( IOString+ , writeFile+ , readFile+ , appendFile+ , putStr+ , putStrLn+ , FilePath+ ) where++import Data.Char (Char)+import Data.Function (($), (.))+import GHC.IO (FilePath, IO)++import qualified System.IO as Base++import Control.Monad.IO.Class (MonadIO, liftIO)+import qualified Data.ByteString.Char8 as BS+import qualified Data.ByteString.Lazy.Char8 as BL++import qualified Data.Text as T+import qualified Data.Text.IO as T++import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.IO as TL++import Path++class IOString s where+ iosWriteFile :: FilePath -> s -> IO ()+ iosReadFile :: FilePath -> IO s+ iosAppendFile :: FilePath -> s -> IO ()+ iosPutStr :: s -> IO ()+ iosPutStrLn :: s -> IO ()++instance IOString T.Text where+ iosWriteFile = T.writeFile+ iosReadFile = T.readFile+ iosAppendFile = T.appendFile+ iosPutStr = T.putStr+ iosPutStrLn = T.putStrLn++instance IOString TL.Text where+ iosWriteFile = TL.writeFile+ iosReadFile = TL.readFile+ iosAppendFile = TL.appendFile+ iosPutStr = TL.putStr+ iosPutStrLn = TL.putStrLn++instance IOString BS.ByteString where+ iosWriteFile = BS.writeFile+ iosReadFile = BS.readFile+ iosAppendFile = BS.appendFile+ iosPutStr = BS.putStr+ iosPutStrLn = BS.putStrLn++instance IOString BL.ByteString where+ iosWriteFile = BL.writeFile+ iosReadFile = BL.readFile+ iosAppendFile = BL.appendFile+ iosPutStr = BL.putStr+ iosPutStrLn = BL.putStrLn++instance IOString [Char] where+ iosWriteFile = Base.writeFile+ iosReadFile = Base.readFile+ iosAppendFile = Base.appendFile+ iosPutStr = Base.putStr+ iosPutStrLn = Base.putStrLn++writeFile :: (IOString s, MonadIO m) => Path Abs File -> s -> m ()+writeFile p s = liftIO $ iosWriteFile (toFilePath p) s++readFile :: (IOString s, MonadIO m) => Path Abs File -> m s+readFile = liftIO . iosReadFile . toFilePath++appendFile :: (IOString s, MonadIO m) => Path Abs File -> s -> m ()+appendFile p s = liftIO $ iosAppendFile (toFilePath p) s++putStr :: (IOString s, MonadIO m) => s -> m ()+putStr = liftIO . iosPutStr++putStrLn :: (IOString s, MonadIO m) => s -> m ()+putStrLn = liftIO . iosPutStrLn