From 0d2bd1ffa083bb2315401ac229b5feae38a34daa Mon Sep 17 00:00:00 2001 From: Hiroki Tokunaga Date: Tue, 13 Aug 2024 23:11:19 +0900 Subject: [PATCH] Make `NodeComments` monoid (#939) --- src/HIndent/Ast/NodeComments.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/HIndent/Ast/NodeComments.hs b/src/HIndent/Ast/NodeComments.hs index 8f978c748..da0c2edb3 100644 --- a/src/HIndent/Ast/NodeComments.hs +++ b/src/HIndent/Ast/NodeComments.hs @@ -24,6 +24,11 @@ instance Semigroup NodeComments where , commentsAfter = commentsAfter x <> commentsAfter y } +instance Monoid NodeComments where + mempty = + NodeComments + {commentsBefore = [], commentsOnSameLine = [], commentsAfter = []} + fromEpAnn :: GHC.EpAnn a -> NodeComments fromEpAnn = fromEpAnn' . filterOutEofAndPragmasFromAnn