From a64224d119c1b10f44b1e485aae4f0fb86092d82 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Fri, 17 Apr 2020 12:26:07 +0200 Subject: [PATCH] Remove useless code equivalent to the identity in the right monad (IO) --- src/Main.hs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index d3f248d..323516e 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,14 +1,11 @@ -{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeApplications #-} module Main where -import Control.Monad.State (execState, execStateT) import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as BS (readFile, split, intercalate) import qualified Data.ByteString.Lazy.Char8 as Lazy (writeFile) import PDF (Layers(..), Document(..), UnifiedLayers(..), parseDocument, render) -import PDF.Box (Index(..), Maybe_(..), at, atAll, edit) +import PDF.Box (Index(..), Maybe_(..), at, atAll) import PDF.Layer (Layer, Objects(..)) import PDF.Object.Navigation (StreamContent(..)) import PDF.TextRendering (TextRendering(..), update) @@ -29,18 +26,14 @@ revealLayer = .atAll (Maybe_ StreamContent) $ return . revealText -reveal :: Document -> Document -reveal = execState $ - edit .at UnifiedLayers $ revealLayer +reveal :: Document -> IO Document +reveal = at UnifiedLayers $ revealLayer -revealFirst :: Document -> Document -revealFirst document = maybe document id $ execStateT ( - edit .at Layers .at(Index 0) $ revealLayer - ) document +revealFirst :: Document -> IO Document +revealFirst = at Layers .at(Index 0) $ revealLayer -deepReveal :: Document -> Document -deepReveal = execState $ - edit .atAll Layers $ revealLayer +deepReveal :: Document -> IO Document +deepReveal = atAll Layers $ revealLayer main :: IO () main = do @@ -48,4 +41,4 @@ main = do result <- parseDocument <$> BS.readFile inputPath case result of Left parseError -> hPutStrLn stderr $ show parseError - Right doc -> Lazy.writeFile outputPath . render $ reveal doc + Right doc -> Lazy.writeFile outputPath . render =<< reveal doc