packages feed

rawfilepath 0.2.2 → 0.2.3

raw patch · 5 files changed

+60/−15 lines, 5 files

Files

rawfilepath.cabal view
@@ -1,5 +1,5 @@ name:                rawfilepath-version:             0.2.2+version:             0.2.3 synopsis:            Use RawFilePath instead of FilePath description:         Please see README.md homepage:            https://github.com/xtendo-org/rawfilepath#readme
src/RawFilePath.hs view
@@ -1,9 +1,53 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  RawFilePath+-- Copyright   :  (C) XT et al. 2017+-- License     :  BSD-style (see the file LICENSE)+--+-- Maintainer  :  e@xtendo.org+-- Stability   :  experimental+-- Portability :  POSIX+--+-- Welcome to @RawFilePath@, a small part of the Haskell community's effort to+-- purge 'String' for the Greater Good.+--+-- With this package, you can interact with the Unix system without the file+-- path encoding issue or the 'String' ↔ 'ByteString' conversion overhead.+--+-- == Rationale+--+-- Traditional `String` is notorious:+--+-- * 24 bytes (three words) required for one character (the List constructor, the actual Char value, and the pointer to the next List constructor). 24x memory consumption.+-- * Heap fragmentation causing malloc/free overhead+-- * A lot of pointer chasing for reading, devastating the cache hit rate+-- * A lot of pointer chasing plus a lot of heap object allocation for manipulation (appending, slicing, etc.)+-- - Completely unnecessary but mandatory conversions and memory allocation when the data is sent to or received from the outside world+--+-- 'String' has another problematic nature to serve as a file path data type: Encoding blindness. All functions that return 'FilePath' would actually take a series of bytes returned by a syscall and somehow magically "decode" it into a `String` which is surprising because no encoding information was given. Of course there is no magic and it's an abject fail. 'FilePath' just wouldn't work.+--+-- == Usage+--+-- This is the top-level module that re-exports the sub-modules. Therefore,+-- you can+--+-- @+-- import RawFilePath+-- @+--+-- to import all functions.+--+-----------------------------------------------------------------------------+ module RawFilePath-    ( module Module+    ( module RawFilePath.Directory+    , module RawFilePath.Process     , RawFilePath     ) where -import System.Posix.ByteString (RawFilePath)+import RawFilePath.Import -import RawFilePath.Directory as Module-import RawFilePath.Process as Module+-- local modules++import RawFilePath.Directory hiding (RawFilePath)+import RawFilePath.Process hiding (RawFilePath)
src/RawFilePath/Directory.hs view
@@ -14,9 +14,9 @@ -----------------------------------------------------------------------------  module RawFilePath.Directory-    (+    ( RawFilePath     -- ** Nondestructive (read-only)-      doesPathExist+    , doesPathExist     , doesFileExist     , doesDirectoryExist     , getHomeDirectory
src/RawFilePath/Process.hs view
@@ -49,10 +49,10 @@   module RawFilePath.Process-    (+    ( RawFilePath     -- ** Configuring process     -- $configuring-      ProcessConf+    , ProcessConf     , proc      -- *** Configuring process standard streams@@ -82,9 +82,12 @@      -- ** Utility functions     -- $utility-    , module RawFilePath.Process.Utility+    , callProcess+    , readProcessWithExitCode      ) where++import RawFilePath.Import  -- local modules 
src/RawFilePath/Process/Utility.hs view
@@ -29,11 +29,9 @@         , cfgStderr = NoStream         } --- | Fork an external process, read its standard output strictly, blocking--- until the process terminates, and return the output as 'ByteString'.------ Output is returned strictly, so this is not suitable for interactive--- applications.+-- | Fork an external process, read its standard output and standard error+-- strictly, blocking until the process terminates, and return them with the+-- process exit code. readProcessWithExitCode     :: ProcessConf stdin stdout stderr     -> IO (ExitCode, ByteString, ByteString)