From 406ee299d2e2957ee92db67a3e3c88b3452619ab Mon Sep 17 00:00:00 2001 From: ltbinsbe Date: Sun, 3 Mar 2019 10:10:09 +0000 Subject: [PATCH 1/2] Added Semigroup instances for all Monoids, required for GHC 8.6 --- uu-cco/src/CCO/Printing/Printer.hs | 9 ++++++++- uu-cco/uu-cco.cabal | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/uu-cco/src/CCO/Printing/Printer.hs b/uu-cco/src/CCO/Printing/Printer.hs index 5241227..8d86e2a 100644 --- a/uu-cco/src/CCO/Printing/Printer.hs +++ b/uu-cco/src/CCO/Printing/Printer.hs @@ -29,6 +29,7 @@ module CCO.Printing.Printer ( ) where import CCO.Printing.Colour ( Colour (..) ) +import Data.Semigroup ( Semigroup (..) ) import Data.Monoid ( Monoid (..) ) import System.Console.ANSI ( ConsoleLayer (Foreground) , ColorIntensity (Dull) @@ -93,6 +94,9 @@ class Monoid a => Printer a where -- | The type of printers that produce 'String's. data StringPrinter = SP !Int !Int (String -> String) +instance Semigroup StringPrinter where + (<>) = mappend + instance Monoid StringPrinter where mempty = SP 0 0 id mappend (SP wl hl accl) (SP wr hr accr) = @@ -116,6 +120,9 @@ printToString (SP _ _ acc) = acc "" -- | The type of printers that print to the standard output channel. data IOPrinter = IOP !Int !Int ([Colour] -> (IO (), [Colour])) +instance Semigroup IOPrinter where + (<>) = mappend + instance Monoid IOPrinter where mempty = IOP 0 0 (\cs -> (return (), cs)) mappend (IOP wl hl f) (IOP wr hr g) = IOP (wl + wr) (hl + hr) $ \cs -> @@ -154,4 +161,4 @@ printToIO (IOP _ _ f) = fst (f [Default]) -- | An infinite supply of spaces. spaces :: [Char] -spaces = ' ' : spaces \ No newline at end of file +spaces = ' ' : spaces diff --git a/uu-cco/uu-cco.cabal b/uu-cco/uu-cco.cabal index b9d43fe..4a662b5 100644 --- a/uu-cco/uu-cco.cabal +++ b/uu-cco/uu-cco.cabal @@ -1,5 +1,5 @@ name: uu-cco -version: 0.1.0.5 +version: 0.1.0.6 synopsis: Utilities for compiler construction: core functionality description: A small utility library accompanying the course on Compiler Construction (INFOMCCO) at Utrecht Univerity. From 25b1d31ef51b323e11961f7f0475ee0281e875eb Mon Sep 17 00:00:00 2001 From: "L. Thomas van Binsbergen" Date: Sat, 26 Jun 2021 13:26:00 +0200 Subject: [PATCH 2/2] Removed method fail implementation from Monad to MonadFail instance for Feedback --- uu-cco/src/CCO/Feedback.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/uu-cco/src/CCO/Feedback.hs b/uu-cco/src/CCO/Feedback.hs index e0a6844..a20d6fc 100644 --- a/uu-cco/src/CCO/Feedback.hs +++ b/uu-cco/src/CCO/Feedback.hs @@ -61,6 +61,7 @@ instance Monad Feedback where Fail msgs' -> Fail (msgs ++ msgs') Fail msgs >>= _ = Fail msgs +instance MonadFail Feedback where fail msg = Fail [Error (text msg)] instance Applicative Feedback where