safer-file-handles-text (empty) → 0.1
raw patch · 5 files changed
+275/−0 lines, 5 filesdep +explicit-iomodes-textdep +regionsdep +safer-file-handlesbuild-type:Customsetup-changed
Dependencies added: explicit-iomodes-text, regions, safer-file-handles, text, transformers
Files
- Data/Text/IO/SaferFileHandles.hs +85/−0
- Data/Text/Lazy/IO/SaferFileHandles.hs +85/−0
- LICENSE +31/−0
- Setup.hs +47/−0
- safer-file-handles-text.cabal +27/−0
+ Data/Text/IO/SaferFileHandles.hs view
@@ -0,0 +1,85 @@+{-# LANGUAGE UnicodeSyntax, NoImplicitPrelude, CPP #-}++-------------------------------------------------------------------------------+-- |+-- Module : Data.Text.IO.SaferFileHandles+-- Copyright : (c) 2010 Bas van Dijk+-- License : BSD3 (see the file LICENSE)+-- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com>+--+-- This module lifts the 'Text' IO operations into the region monad.+--+-------------------------------------------------------------------------------++module Data.Text.IO.SaferFileHandles+ ( hGetLine+ , hGetContents++ , hPutStr+ , hPutStrLn+ ) where+++-------------------------------------------------------------------------------+-- Imports+-------------------------------------------------------------------------------++-- from transformers:+import Control.Monad.IO.Class ( MonadIO )++-- from text:+import Data.Text ( Text )++#ifdef __HADDOCK__+import qualified Data.Text.IO as T ( hGetLine+ , hGetContents++ , hPutStr+ , hPutStrLn+ )+#endif++-- from explicit-iomodes-text:+import qualified Data.Text.IO.ExplicitIOModes as E ( hGetLine+ , hGetContents++ , hPutStr+ , hPutStrLn+ )+-- from regions:+import Control.Monad.Trans.Region ( ParentOf )++-- from safer-file-handles:+import System.IO.SaferFileHandles ( RegionalFileHandle+ , ReadModes, WriteModes+ )+import System.IO.SaferFileHandles.Unsafe ( wrap, wrap2 )+++-------------------------------------------------------------------------------+-- Text I/O with regional file handles+-------------------------------------------------------------------------------++-- | Wraps: @Data.Text.IO.'T.hGetLine'@.+hGetLine ∷ (pr `ParentOf` cr, MonadIO cr, ReadModes ioMode)+ ⇒ RegionalFileHandle ioMode pr → cr Text+hGetLine = wrap E.hGetLine++-- | Wraps: @Data.Text.IO.'T.hGetContents'@.+hGetContents ∷ (pr `ParentOf` cr, MonadIO cr, ReadModes ioMode)+ ⇒ RegionalFileHandle ioMode pr → cr Text+hGetContents = wrap E.hGetContents+++-- | Wraps: @Data.Text.IO.'T.hPutStr'@.+hPutStr ∷ (pr `ParentOf` cr, MonadIO cr, WriteModes ioMode)+ ⇒ RegionalFileHandle ioMode pr → Text → cr ()+hPutStr = wrap2 E.hPutStr++-- | Wraps: @Data.Text.IO.'T.hPutStrLn'@.+hPutStrLn ∷ (pr `ParentOf` cr, MonadIO cr, WriteModes ioMode)+ ⇒ RegionalFileHandle ioMode pr → Text → cr ()+hPutStrLn = wrap2 E.hPutStrLn+++-- The End ---------------------------------------------------------------------
+ Data/Text/Lazy/IO/SaferFileHandles.hs view
@@ -0,0 +1,85 @@+{-# LANGUAGE UnicodeSyntax, NoImplicitPrelude, CPP #-}++-------------------------------------------------------------------------------+-- |+-- Module : Data.Text.Lazy.IO.SaferFileHandles+-- Copyright : (c) 2010 Bas van Dijk+-- License : BSD3 (see the file LICENSE)+-- Maintainer : Bas van Dijk <v.dijk.bas@gmail.com>+--+-- This module lifts the lazy 'Text' IO operations into the region monad.+--+-------------------------------------------------------------------------------++module Data.Text.Lazy.IO.SaferFileHandles+ ( hGetLine+ , hGetContents++ , hPutStr+ , hPutStrLn+ ) where+++-------------------------------------------------------------------------------+-- Imports+-------------------------------------------------------------------------------++-- from transformers:+import Control.Monad.IO.Class ( MonadIO )++-- from text:+import Data.Text.Lazy ( Text )++#ifdef __HADDOCK__+import qualified Data.Text.Lazy.IO as T ( hGetLine+ , hGetContents++ , hPutStr+ , hPutStrLn+ )+#endif++-- from explicit-iomodes-text:+import qualified Data.Text.Lazy.IO.ExplicitIOModes as E ( hGetLine+ , hGetContents++ , hPutStr+ , hPutStrLn+ )+-- from regions:+import Control.Monad.Trans.Region ( ParentOf )++-- from safer-file-handles:+import System.IO.SaferFileHandles ( RegionalFileHandle+ , ReadModes, WriteModes+ )+import System.IO.SaferFileHandles.Unsafe ( wrap, wrap2 )+++-------------------------------------------------------------------------------+-- Lazy Text I/O with regional file handles+-------------------------------------------------------------------------------++-- | Wraps: @Data.Text.Lazy.IO.'T.hGetLine'@.+hGetLine ∷ (pr `ParentOf` cr, MonadIO cr, ReadModes ioMode)+ ⇒ RegionalFileHandle ioMode pr → cr Text+hGetLine = wrap E.hGetLine++-- | Wraps: @Data.Text.Lazy.IO.'T.hGetContents'@.+hGetContents ∷ (pr `ParentOf` cr, MonadIO cr, ReadModes ioMode)+ ⇒ RegionalFileHandle ioMode pr → cr Text+hGetContents = wrap E.hGetContents+++-- | Wraps: @Data.Text.Lazy.IO.'T.hPutStr'@.+hPutStr ∷ (pr `ParentOf` cr, MonadIO cr, WriteModes ioMode)+ ⇒ RegionalFileHandle ioMode pr → Text → cr ()+hPutStr = wrap2 E.hPutStr++-- | Wraps: @Data.Text.Lazy.IO.'T.hPutStrLn'@.+hPutStrLn ∷ (pr `ParentOf` cr, MonadIO cr, WriteModes ioMode)+ ⇒ RegionalFileHandle ioMode pr → Text → cr ()+hPutStrLn = wrap2 E.hPutStrLn+++-- The End ---------------------------------------------------------------------
+ LICENSE view
@@ -0,0 +1,31 @@+Copyright (c) 2010 Bas van Dijk++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * The name of Bas van Dijk and the names of contributors may NOT+ be used to endorse or promote products derived from this+ software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,47 @@+#! /usr/bin/env runhaskell++{-# LANGUAGE NoImplicitPrelude, UnicodeSyntax #-}++module Main (main) where+++-------------------------------------------------------------------------------+-- Imports+-------------------------------------------------------------------------------++-- from base+import Control.Monad ( (>>), return )+import System.IO ( IO )++-- from cabal+import Distribution.Simple ( defaultMainWithHooks+ , simpleUserHooks+ , UserHooks(haddockHook)+ , Args+ )++import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) )+import Distribution.Simple.Program ( userSpecifyArgs )+import Distribution.Simple.Setup ( HaddockFlags )+import Distribution.PackageDescription ( PackageDescription(..) )+++-------------------------------------------------------------------------------+-- Cabal setup program with support for 'cabal test' and+-- which sets the CPP define '__HADDOCK __' when haddock is run.+-------------------------------------------------------------------------------++main ∷ IO ()+main = defaultMainWithHooks hooks+ where+ hooks = simpleUserHooks { haddockHook = haddockHook' }++-- Define __HADDOCK__ for CPP when running haddock.+haddockHook' ∷ PackageDescription → LocalBuildInfo → UserHooks → HaddockFlags → IO ()+haddockHook' pkg lbi =+ haddockHook simpleUserHooks pkg (lbi { withPrograms = p })+ where+ p = userSpecifyArgs "haddock" ["--optghc=-D__HADDOCK__"] (withPrograms lbi)+++-- The End ---------------------------------------------------------------------
+ safer-file-handles-text.cabal view
@@ -0,0 +1,27 @@+name: safer-file-handles-text+version: 0.1+cabal-version: >=1.6+build-type: Custom+license: BSD3+license-file: LICENSE+copyright: 2010 Bas van Dijk+author: Bas van Dijk+maintainer: Bas van Dijk <v.dijk.bas@gmail.com>+stability: experimental+category: System, Monadic Regions+synopsis: Extends safer-file-handles with Text operations+description: Extends @safer-file-handles@ with @Text@ operations++source-repository head+ Type: darcs+ Location: http://code.haskell.org/~basvandijk/code/safer-file-handles-text++Library+ GHC-Options: -Wall+ build-depends: text >= 0.7 && < 0.8+ , regions >= 0.6 && < 0.7+ , transformers >= 0.2 && < 0.3+ , explicit-iomodes-text >= 0.1 && < 0.2+ , safer-file-handles >= 0.6 && < 0.7+ exposed-modules: Data.Text.IO.SaferFileHandles+ Data.Text.Lazy.IO.SaferFileHandles