{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE OverloadedStrings #-}
module Lib.ProcTxt
where
import Lib.ProcWord
import UniformBase
import Lib.FileHandling
import Control.Monad.Trans.Writer.Strict
procTxt :: Bool -> [Text] -> Path Abs File -> ErrIO Bool
procTxt :: Bool -> [Text] -> Path Abs File -> ErrIO Bool
procTxt Bool
debug [Text]
erl2 Path Abs File
fn = do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
debug forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). MonadIO m => [Text] -> m ()
putIOwords [Text
"procTxt start", forall {a}. Show a => a -> Text
showT Path Abs File
fn]
[Text]
ls :: [Text] <- forall a b.
TypedFiles7a a b =>
Path Abs File -> TypedFile5 a b -> ErrIO b
read8 Path Abs File
fn TypedFile5 Text [Text]
textlinesFile
let ([Text]
ls2,Text
report) = forall w a. Writer w a -> (a, w)
runWriter forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ([Text] -> Text -> Writer Text Text
procLine2Rep [Text]
erl2) [Text]
ls
let changed :: Bool
changed = forall z. Zeros z => z
zero forall a. Eq a => a -> a -> Bool
/= forall a. CharChains a => a -> a
trim' Text
report
Bool
-> Path Abs File
-> TypedFile5 Text [Text]
-> [Text]
-> ExceptT Text IO ()
writeWithBak Bool
debug Path Abs File
fn TypedFile5 Text [Text]
textlinesFile [Text]
ls2
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
changed