summaryrefslogtreecommitdiff
path: root/src/System/Texrunner/Parse.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/System/Texrunner/Parse.hs')
-rw-r--r--src/System/Texrunner/Parse.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/System/Texrunner/Parse.hs b/src/System/Texrunner/Parse.hs
index a02b31e..91bd162 100644
--- a/src/System/Texrunner/Parse.hs
+++ b/src/System/Texrunner/Parse.hs
@@ -35,7 +35,7 @@ import Data.Attoparsec.ByteString.Char8 as A
import Data.ByteString.Char8 (ByteString, cons, pack)
import qualified Data.ByteString.Char8 as B
import Data.Maybe
-import Data.Monoid
+import Data.Semigroup
------------------------------------------------------------------------
-- Boxes
@@ -99,13 +99,16 @@ data TexInfo = TexInfo
deriving Show
-- Make shift way to parse a log by combining it in this way.
-instance Monoid TexLog where
- mempty = TexLog (TexInfo Nothing Nothing Nothing) Nothing []
- TexLog prog pages1 errors1 `mappend` TexLog _ pages2 errors2 =
+instance Semigroup TexLog where
+ TexLog prog pages1 errors1 <> TexLog _ pages2 errors2 =
case (pages1,pages2) of
(Just a,_) -> TexLog prog (Just a) (errors1 ++ errors2)
(_,b) -> TexLog prog b (errors1 ++ errors2)
+instance Monoid TexLog where
+ mempty = TexLog (TexInfo Nothing Nothing Nothing) Nothing []
+ mappend = (<>)
+
infoParser :: Parser TexInfo
infoParser
= TexInfo
@@ -131,7 +134,7 @@ parseLog = (\(Right a) -> a) . parseOnly logFile
-- the parse should never fail (I think)
prettyPrintLog :: TexLog -> ByteString
-prettyPrintLog (TexLog {..}) =
+prettyPrintLog TexLog {..} =
fromMaybe "unknown program" (texCommand texInfo)
<> maybe "" (" version " <>) (texVersion texInfo)
<> maybe "" (" " <>) (texDistribution texInfo)
@@ -173,7 +176,7 @@ data TexError'
| UnknownError ByteString
deriving (Show, Read, Eq)
--- Parse any line begining with "! ". Any unknown errors are returned as 'UnknownError'.
+-- | Parse any line begining with "! ". Any unknown errors are returned as 'UnknownError'.
someError :: Parser TexError
someError = mark *> errors
where