Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions uu-cco/src/CCO/Feedback.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion uu-cco/src/CCO/Printing/Printer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) =
Expand All @@ -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 ->
Expand Down Expand Up @@ -154,4 +161,4 @@ printToIO (IOP _ _ f) = fst (f [Default])

-- | An infinite supply of spaces.
spaces :: [Char]
spaces = ' ' : spaces
spaces = ' ' : spaces
2 changes: 1 addition & 1 deletion uu-cco/uu-cco.cabal
Original file line number Diff line number Diff line change
@@ -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.
Expand Down