From 3d0621a8747a4977f6f8bc72e8a11386c7cb2e73 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 9 Jan 2016 23:27:15 +0000 Subject: Cleanup up monoid instances --- spec/src/Thermoprint/Printout.hs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'spec/src/Thermoprint') diff --git a/spec/src/Thermoprint/Printout.hs b/spec/src/Thermoprint/Printout.hs index 23e950a..c96573e 100644 --- a/spec/src/Thermoprint/Printout.hs +++ b/spec/src/Thermoprint/Printout.hs @@ -83,8 +83,12 @@ instance Monoid Block where | Seq.null xs = y | Seq.null ys = x | otherwise = NewlSep (xs <> ys) - (NewlSep xs) `mappend` y = NewlSep (xs |> y) - x `mappend` (NewlSep ys) = NewlSep (x <| ys) + (NewlSep xs) `mappend` y + | Seq.null xs = y + | otherwise = NewlSep (xs |> y) + x `mappend` (NewlSep ys) + | Seq.null ys = x + | otherwise = NewlSep (x <| ys) x `mappend` y = NewlSep $ Seq.fromList [x, y] instance Monoid Line where @@ -93,8 +97,12 @@ instance Monoid Line where | Seq.null xs = y | Seq.null ys = x | otherwise = SpaceSep (xs <> ys) - (SpaceSep xs) `mappend` y = SpaceSep (xs |> y) - x `mappend` (SpaceSep ys) = SpaceSep (x <| ys) + (SpaceSep xs) `mappend` y + | Seq.null xs = y + | otherwise = SpaceSep (xs |> y) + x `mappend` (SpaceSep ys) + | Seq.null ys = x + | otherwise = SpaceSep (x <| ys) x `mappend` y = SpaceSep $ Seq.fromList [x, y] -- cgit v1.2.3