From d06f4c18100e5a6adab174512a5f78c5f988b647 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 16 May 2023 11:03:23 +0800 Subject: [PATCH] Functor, Foldable, Traversable instances for Report, Marker and Note --- src/Error/Diagnose/Diagnostic/Internal.hs | 4 ++++ src/Error/Diagnose/Report/Internal.hs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/Error/Diagnose/Diagnostic/Internal.hs b/src/Error/Diagnose/Diagnostic/Internal.hs index 7e59379..bd01831 100644 --- a/src/Error/Diagnose/Diagnostic/Internal.hs +++ b/src/Error/Diagnose/Diagnostic/Internal.hs @@ -1,4 +1,7 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE FlexibleInstances #-} -- | @@ -47,6 +50,7 @@ data Diagnostic msg -- Reports are output one by one, without connections in between. !FileMap -- ^ A map associating files with their content as lists of lines. + deriving (Functor, Foldable, Traversable) instance Default (Diagnostic msg) where def = Diagnostic mempty mempty diff --git a/src/Error/Diagnose/Report/Internal.hs b/src/Error/Diagnose/Report/Internal.hs index 9a9014e..4c42ead 100644 --- a/src/Error/Diagnose/Report/Internal.hs +++ b/src/Error/Diagnose/Report/Internal.hs @@ -1,5 +1,8 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE RecordWildCards #-} @@ -67,6 +70,7 @@ data Report msg -- ^ A map associating positions with marker to show under the source code. [Note msg] -- ^ A list of notes to add at the end of the report. + deriving (Functor, Foldable, Traversable) -- | Pattern synonym for a warning report. pattern Warn :: Maybe msg -> msg -> [(Position, Marker msg)] -> [Note msg] -> Report msg @@ -120,6 +124,7 @@ data Marker msg Maybe msg | -- | An empty marker, whose sole purpose is to include a line of code in the report without markers under. Blank + deriving (Functor, Foldable, Traversable) instance Eq (Marker msg) where This _ == This _ = True @@ -147,6 +152,7 @@ data Note msg Note msg | -- | A hint, to propose potential fixes or help towards fixing the issue. Hint msg + deriving (Functor, Foldable, Traversable) #ifdef USE_AESON instance ToJSON msg => ToJSON (Note msg) where