Remove useless code equivalent to the identity in the right monad (IO)
This commit is contained in:
parent
266032950e
commit
a64224d119
1 changed files with 8 additions and 15 deletions
23
src/Main.hs
23
src/Main.hs
|
@ -1,14 +1,11 @@
|
||||||
{-# LANGUAGE NamedFieldPuns #-}
|
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE TypeApplications #-}
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Control.Monad.State (execState, execStateT)
|
|
||||||
import Data.ByteString.Char8 (ByteString)
|
import Data.ByteString.Char8 (ByteString)
|
||||||
import qualified Data.ByteString.Char8 as BS (readFile, split, intercalate)
|
import qualified Data.ByteString.Char8 as BS (readFile, split, intercalate)
|
||||||
import qualified Data.ByteString.Lazy.Char8 as Lazy (writeFile)
|
import qualified Data.ByteString.Lazy.Char8 as Lazy (writeFile)
|
||||||
import PDF (Layers(..), Document(..), UnifiedLayers(..), parseDocument, render)
|
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.Layer (Layer, Objects(..))
|
||||||
import PDF.Object.Navigation (StreamContent(..))
|
import PDF.Object.Navigation (StreamContent(..))
|
||||||
import PDF.TextRendering (TextRendering(..), update)
|
import PDF.TextRendering (TextRendering(..), update)
|
||||||
|
@ -29,18 +26,14 @@ revealLayer =
|
||||||
.atAll (Maybe_ StreamContent) $
|
.atAll (Maybe_ StreamContent) $
|
||||||
return . revealText
|
return . revealText
|
||||||
|
|
||||||
reveal :: Document -> Document
|
reveal :: Document -> IO Document
|
||||||
reveal = execState $
|
reveal = at UnifiedLayers $ revealLayer
|
||||||
edit .at UnifiedLayers $ revealLayer
|
|
||||||
|
|
||||||
revealFirst :: Document -> Document
|
revealFirst :: Document -> IO Document
|
||||||
revealFirst document = maybe document id $ execStateT (
|
revealFirst = at Layers .at(Index 0) $ revealLayer
|
||||||
edit .at Layers .at(Index 0) $ revealLayer
|
|
||||||
) document
|
|
||||||
|
|
||||||
deepReveal :: Document -> Document
|
deepReveal :: Document -> IO Document
|
||||||
deepReveal = execState $
|
deepReveal = atAll Layers $ revealLayer
|
||||||
edit .atAll Layers $ revealLayer
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
@ -48,4 +41,4 @@ main = do
|
||||||
result <- parseDocument <$> BS.readFile inputPath
|
result <- parseDocument <$> BS.readFile inputPath
|
||||||
case result of
|
case result of
|
||||||
Left parseError -> hPutStrLn stderr $ show parseError
|
Left parseError -> hPutStrLn stderr $ show parseError
|
||||||
Right doc -> Lazy.writeFile outputPath . render $ reveal doc
|
Right doc -> Lazy.writeFile outputPath . render =<< reveal doc
|
||||||
|
|
Loading…
Reference in a new issue