-----------------------------------------------------------------------------
-- Module      :   Convert umlaut written as ae, oe or ue into ä, ö and ü
--              in a txt file
-----------------------------------------------------------------------------
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE TypeSynonymInstances  #-}
{-# LANGUAGE OverloadedStrings     #-}

module Lib.ProcDirMD -- (openMain, htf_thisModuelsTests)
                   where
-- import Uniform.Strings
-- import Uniform.TypedFile
-- import           Uniform.FileIO
-- import Uniform.Error
import           Lib.ProcTextFile
-- import Lib.ProcWord
import UniformBase
import Lib.FileHandling

procDirMD :: Bool -> [Text] -> Path Abs Dir -> ErrIO ()
-- ^ replace umlaut in all md files in directory (recursively!)
procDirMD :: Bool -> [Text] -> Path Abs Dir -> ErrIO ()
procDirMD Bool
debug [Text]
erl2 Path Abs Dir
dir = 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
"procDirMD start", forall {a}. Show a => a -> Text
showT Path Abs Dir
dir]
    -- pipedDoIOwithFilter :: Path Abs File -> Path Abs Dir -> Extension -> (Path Abs File -> ErrIO String) -> ErrIO ()
    Path Abs Dir
curr <- ErrIO (Path Abs Dir)
currentDir
    let msgFile :: FileResultT (Path Abs Dir) (Path Rel File)
msgFile = Path Abs Dir
curr forall fp file.
Filenames3 fp file =>
fp -> file -> FileResultT fp file
</> FilePath -> Path Rel File
makeRelFile FilePath
"msg4procDir.txt"
    ()
bools <- Path Abs File
-> Path Abs Dir
-> Extension
-> (Path Abs File -> ErrIO FilePath)
-> ErrIO ()
pipedDoIOwithFilter FileResultT (Path Abs Dir) (Path Rel File)
msgFile Path Abs Dir
dir (FilePath -> Extension
Extension FilePath
"md") (Bool -> [Text] -> Path Abs File -> ErrIO FilePath
procTxt0 Bool
debug [Text]
erl2)

    [Text]
msg2 <- forall a b.
TypedFiles7a a b =>
Path Abs File -> TypedFile5 a b -> ErrIO b
read8 FileResultT (Path Abs Dir) (Path Rel File)
msgFile TypedFile5 Text [Text]
textlinesFile
    forall (m :: * -> *). MonadIO m => [Text] -> m ()
putIOwords [Text
"processing for ", forall {a}. Show a => a -> Text
showT Path Abs Dir
dir, Text
"done with msg", forall {a}. Show a => a -> Text
showT [Text]
msg2]
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

procTxt0 :: Bool -> [Text] -> Path Abs File -> ErrIO String 
procTxt0 :: Bool -> [Text] -> Path Abs File -> ErrIO FilePath
procTxt0 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
"procTxt0 start", forall {a}. Show a => a -> Text
showT Path Abs File
fn]
    Bool -> [Text] -> Path Abs File -> ErrIO Bool
procTextFile Bool
debug [Text]
erl2 Path Abs File
fn 
    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
"procTxt0 end", forall {a}. Show a => a -> Text
showT Path Abs File
fn]
    forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> FilePath
show forall a b. (a -> b) -> a -> b
$ Path Abs File
fn