From d260ea19c9d5bd4c8c236225f79a082ea4aaf7dd Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Sun, 18 Sep 2016 09:54:07 +0900 Subject: [PATCH] Add a Semigroup instance over Source. --- src/Source.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Source.hs b/src/Source.hs index 9dc50df45..04cc5f379 100644 --- a/src/Source.hs +++ b/src/Source.hs @@ -100,6 +100,9 @@ sourceSpanToRange source SourceSpan{..} = Range start end sumLengths = sum . fmap (\ Range{..} -> end - start) +instance Semigroup (Source a) where + Source a <> Source b = Source (a Vector.++ b) + instance Monoid (Source a) where mempty = fromList [] - mappend = (Source .) . (Vector.++) `on` getVector + mappend = (<>)