packages feed

uniform-fileio 0.1.3 → 0.1.5.1

raw patch · 8 files changed

+54/−182 lines, 8 filesdep ~uniform-algebrasdep ~uniform-errordep ~uniform-strings

Dependency ranges changed: uniform-algebras, uniform-error, uniform-strings, uniform-time

Files

ChangeLog.md view
@@ -15,3 +15,6 @@ 0.1.2     prepare for 9.2.1  0.1.3  changed for ExceptionT (stat ErrorT)+0.1.3.1 added renameToBak8 in TypedFiles++0.1.5.1  ghc 9.2.5 changed versino to be in sync with other packages
Uniform/FileIOalgebra.hs view
@@ -147,10 +147,8 @@   where   --   writeFile2 :: fp -> fc -> ErrIO ()-   -- write file if dir exist   readFile2 :: fp -> ErrIO fc-   -- read file   appendFile2 :: fp -> fc -> ErrIO () @@ -159,7 +157,6 @@   --    readFileOrZero2 :: (FileOps fp, Zeros fc) => fp -> ErrIO fc-   -- | reads file, if not present, returns zero   readFileOrZero2 fp = do     f <- doesFileExist' fp
Uniform/Piped.hs view
@@ -95,7 +95,8 @@  -- a convenient function to go through a directory and -- recursively apply a function to each file or directory--- filters for extension md+-- filters for extension (e.g. md)+-- file for error messages  pipedDoIOwithFilter :: Path Abs File -> Path Abs Dir -> Extension -> (Path Abs File -> ErrIO String) -> ErrIO () pipedDoIOwithFilter file path ext opex = do   hand <- openFile2handle file WriteMode
Uniform/TypedFile.hs view
@@ -250,6 +250,9 @@   read8 :: Path Abs File -> TypedFile5 a b -> ErrIO b    write8 :: Path Abs File -> TypedFile5 a b -> b -> ErrIO ()+++  renameToBak8 :: Path Abs File -> TypedFile5 a b -> ErrIO ()   -- ^ the createDir if missingis implied in the write  instance (TypedFiles7 Text b) => TypedFiles7a Text b where@@ -272,6 +275,12 @@     ares :: Text <- readFile2 fp2     return . wrap7 $ ares +  renameToBak8 fp tp = do +    let fp2 = fp <.> tpext5 tp +    let fpBak = fp <.> (Extension "bak")+    renameOneFile fp2 fpBak +    return ()+ instance (TypedFiles7 L.ByteString b) => TypedFiles7a L.ByteString b where   -- an instance for all what has text or bytestring  as underlying rep   write7 fp fn tp ct = do@@ -290,3 +299,9 @@     let fp2 = fp <.> tpext5 tp     ares :: L.ByteString <- readFile2 fp2     return . wrap7 $ ares++  renameToBak8 fp tp = do +    let fp2 = fp <.> tpext5 tp +    let fpBak = fp <.> (Extension "bak")+    renameOneFile fp2 fpBak +    return ()
tests/Testing.hs view
@@ -20,12 +20,12 @@  import            Test.Framework -import     {-@ HTF_TESTS @-}       Uniform.FileStrings_test+-- import     {-@ HTF_TESTS @-}       Uniform.FileStrings_test -- import {-@ HTF_TESTS @-} Uniform.ByteString_test-import     {-@ HTF_TESTS @-}       Uniform.Filenames_test-import     {-@ HTF_TESTS @-}       Uniform.PathShowCase_test-import    {-@ HTF_TESTS @-}        Uniform.FileStatus_test-import     {-@ HTF_TESTS @-}       Uniform.Piped_test+-- import     {-@ HTF_TESTS @-}       Uniform.Filenames_test+-- import     {-@ HTF_TESTS @-}       Uniform.PathShowCase_test+-- import    {-@ HTF_TESTS @-}        Uniform.FileStatus_test+-- import     {-@ HTF_TESTS @-}       Uniform.Piped_test import    {-@ HTF_TESTS @-}        Uniform.TypedFile_test  import           Uniform.Strings
− tests/Uniform/PathShowCase_test.hs
@@ -1,155 +0,0 @@-{-# LANGUAGE BangPatterns #-}-{-# LANGUAGE DoAndIfThenElse #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE PackageImports #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeSynonymInstances #-}-{-# LANGUAGE UndecidableInstances #-}------------------------------------------------------------------------------------ Module      :  Uniform.Example_test----------------------------------------------------------------------------------{-# OPTIONS_GHC -F -pgmF htfpp #-}---- {-# OPTIONS_GHC  -fno-warn-warnings-deprecations #-}---- | import examples to test with  {\-@ HTF_TESTS @-\}-module Uniform.PathShowCase_test where--import Control.Exception-import Path (-  parseAbsDir,-  parseAbsFile,-  parseRelDir,-  parseRelFile,- )-import qualified Path as P-import Test.Framework-import Uniform.Filenames-import Uniform.PathShowCase-import Uniform.Strings hiding ((<.>), (</>), (<|>))---- import Uniform.Test.TestHarness--- cannot be used (cycle fileio - convenience)--data T1 = T1-  { a11 :: Text-  , p11 :: Path Rel File-  , n11 :: Int-  }-  deriving (Show, Read, Eq)--t1 = T1 "some text" s11 37-st1 = showT t1-rt1 = read . t2s $ st1 :: T1--t2 = T1 "anoher long, atest text" r6 2009-rt2 = read . show $ t2 :: T1--test_sc1 = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 50) t1 rt1-test_sc2 = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 51) t2 rt2--data T2 = T2-  { a12 :: Text-  , p12 :: Path Rel File-  }-  deriving (Show, Read, Eq)--t22 = T2 "some interesting text" s11-test_sc3 = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 58) t22 (read . show $ t22)--s11 = makeRelFile "testFile.txt" :: Path Rel File---- r11 = "Path Rel File \"testFile.txt\""--- test_show1 = assertEqual r11 (showT s11)---- test_read = assertEqual s1 (readNoteT "243" . showT $ s1 )---- test_toP = assertEqual (p3a) (s2t . P.toFilePath $  s3)-n1 = "testFile.txt" :: FilePath-p3 = P.parseRelFile n1 :: Maybe (P.Path Rel File)---- s3 = path2internal s2 :: P.Path Rel File--- p3a = s2t . P.toFilePath . fromJustNote "sdsw" $ p3--test_makeRelDir = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 73) d4 f4-f4 = makeRelDir "Workspace"-d4 = makeRelDir "Workspace/" :: Path Rel Dir-s4 = showT d4-test_RelDir = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 77) d4 (readNoteT "RD" s4)--test_addDir = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 79) r6 (addDir f4 n6)-n6 = makeRelFile n1-r6 = makeRelFile "Workspace/testFile.txt"------------------pathShowTest :: IO ()-pathShowTest = do-  putIOwords ["the path as string", showT p1]-  putIOwords ["the mayb pars ed path", showT p2]-  putIOwords ["the mayb pars ed path 2", showT p2]-  putIOwords ["the mayb pars ed path 2a", showT p2a]-  putIOwords ["just px, typed Path Abs Dir", showT p2x]-  putIOwords ["show r1 ", s2t r1]-  putIOwords ["prefix stripped", s2t r3]-  putIOwords ["parsed r3", showT r4]---- putIOwords ["read r2", showT r2]--r1 = show p2x :: String-r2 = read r1 :: Path Abs Dir-r3 =-  fromJustNote "prefix strip"-    . stripPrefix' "Path Abs Dir "-    $ r1 ::-    String-r4 = parseAbsDir r3 :: Maybe (Path Abs Dir)--p1 = "/home/frank/testDir"-p1a = "/home/frank/testDir/"-p2 = parseAbsDir p1 :: Maybe (Path Abs Dir)-p2a = parseAbsDir p1a :: Maybe (Path Abs Dir)-p2x = fromJustNote "p2xbad" p2 :: Path Abs Dir---- p3 = show px :: String -- same as p1--f11 = "/home/frank/test.txt"-f21 = parseAbsFile f11 :: Maybe (Path Abs File)-f2a = fromJustNote "f2" f21-f31 = show f2a :: String-f41 = read f31 :: Path Abs File--g1 = "frank/test.txt"-g2 = parseRelFile g1 :: Maybe (Path Rel File)-g2a = fromJustNote "g2" g2-g3 = show g2a :: String-g4 = read g3 :: Path Rel File--test_g = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 121) g2 (Just g4)-h1 = "frank/test"-h2 = parseRelDir h1 :: Maybe (Path Rel Dir)-h2a = fromJustNote "h2" h2-h3 = show h2a :: String-h4 = read h3 :: Path Rel Dir--test_h = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 128) h2a h4-k1 = "/home/frank/test"-k2 = parseAbsDir k1 :: Maybe (Path Abs Dir)-k2a = fromJustNote "k2" k2-k3 = show k2a :: String-k4 = read k3 :: Path Abs Dir--test_k = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 135) k2a k4--l1 = "/home/frank/test/a.txt"-l2 = parseAbsFile l1 :: Maybe (Path Abs File)-l2a = fromJustNote "l2" l2-l3 = show l2a :: String-l4 = read l3 :: Path Abs File--test_l = assertEqual_ (makeLoc "/home/frank/Workspace11/uBase/uniform-fileio/tests/Uniform/PathShowCase_test.hs" 143) l2 (Just l4)
tests/Uniform/TypedFile_test.hs view
@@ -25,10 +25,10 @@ import Uniform.TypedFile  -textLinesFile = makeTyped (Extension "txt")  ::TypedFile5 [Text] ()+textLinesFile = makeTyped (Extension "txt")  ::TypedFile5 Text [Text] -- was [Text] () dir1 = makeAbsDir "/home/frank/" file1 = makeRelFile "aaa"-ct = ["eins", "zwei"] :: [Text]+ct = unlines' ["eins", "zwei"] :: Text test_write = do     r <- runErr $ write5 dir1 file1 textLinesFile ct     assertEqual (Right () ) r@@ -42,15 +42,16 @@ gzippedTriples = TypedFile5 {tpext5 = Extension "triples.gzip"}                  :: TypedFile5 L.ByteString [Text] +ct2 = ["eins", "zwei"] test_gz4txt = do -    r <- runErr $ write8 (dir1 </> file2) gzippedTriples  ct+    r <- runErr $ write8 (dir1 </> file2) gzippedTriples  ct2     assertEqual (Right ()) r   file2 = makeRelFile "b2"  test_gz4back = do      r <- runErr $ read8 (dir1 </> file2) gzippedTriples  -    assertEqual (Right ct) r +    assertEqual (Right ct2) r   instance TypedFiles7 L.ByteString  [Text]    where     unwrap7 =  compress . b2bl . t2b . showT@@ -72,3 +73,16 @@ test_fileFormed2 = assertEqual ("b2.triples.gzip")                 (toFilePath $ file2 <.> (tpext5 gzippedTriples)) +instance TypedFiles7 Text [Text] where  -- creates sequence of lines+  wrap7 t = lines' t  +  unwrap7 t = unlines' t ++file3 =   (dir1 </> makeRelFile "c3")+ct3 = ["some text for file c3"] ::[Text]+test_write8txt = do +        r <- runErr $ write8 (file3) textLinesFile ct3+        assertEqual (Right ()) r++test_rename8 = do +        r <- runErr $ renameToBak8 file3 textLinesFile +        assertEqual (Right ()) r
uniform-fileio.cabal view
@@ -1,13 +1,13 @@ cabal-version: 2.2 --- This file has been generated from package.yaml by hpack version 0.35.0.+-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack ----- hash: 21c3552a28c18c58a0b0d8885de87f2b10bff2082df7d3c4b2f56a258b8114fb+-- hash: 97d81afaf124fc69557e1bb823e85f2a639758c8c76252216ad730d201599cc8  name:           uniform-fileio-version:        0.1.3+version:        0.1.5.1 synopsis:       Uniform file handling operations description:    Uniform operations for handling files and file path names                 independent from the representation. @@ -15,8 +15,6 @@                 Additionally, functions to read and write files for specific                  typed content (marked by extension).                 .-                added stack build lts 19.16 for ghc 9.0.2-                .                 Please see the README on GitHub at <https://github.com/andrewufrank/uniform-fileiio/readme> category:       Data Text Uniform bug-reports:    https://github.com/andrewufrank/uniform-fileio/issues@@ -57,10 +55,10 @@     , pureMD5     , safe     , text-    , uniform-algebras >=0.1.2-    , uniform-error >=0.1.2-    , uniform-strings >=0.1.2-    , uniform-time >=0.1.0+    , uniform-algebras >=0.1.5+    , uniform-error >=0.1.5+    , uniform-strings >=0.1.5+    , uniform-time >=0.1.5     , unix     , zlib   default-language: Haskell2010@@ -73,7 +71,6 @@       Uniform.Filenames_test       Uniform.FileStatus_test       Uniform.FileStrings_test-      Uniform.PathShowCase_test       Uniform.Piped_test       Uniform.TypedFile_test       Paths_uniform_fileio@@ -99,11 +96,11 @@     , safe     , test-invariant     , text-    , uniform-algebras >=0.1.2-    , uniform-error >=0.1.2+    , uniform-algebras >=0.1.5+    , uniform-error >=0.1.5     , uniform-fileio-    , uniform-strings >=0.1.2-    , uniform-time >=0.1.0+    , uniform-strings >=0.1.5+    , uniform-time >=0.1.5     , unix     , zlib   default-language: Haskell2010