From 507b2e02ef0bba69c19b5659cdba87cedc7780a5 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 22 Aug 2017 14:20:47 -0400 Subject: [PATCH] Define Pretty1 for comments without orphans. --- src/Data/Syntax/Comment.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Data/Syntax/Comment.hs b/src/Data/Syntax/Comment.hs index 202795012..bf38a909c 100644 --- a/src/Data/Syntax/Comment.hs +++ b/src/Data/Syntax/Comment.hs @@ -4,18 +4,22 @@ module Data.Syntax.Comment where import Algorithm import Data.Align.Generic import Data.ByteString (ByteString) +import Data.Text.Encoding import Data.Functor.Classes.Eq.Generic -import Data.Functor.Classes.Pretty.Orphans +import Data.Functor.Classes.Pretty import Data.Functor.Classes.Show.Generic import GHC.Generics -- | An unnested comment (line or block). newtype Comment a = Comment { commentContent :: ByteString } - deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Pretty1, Show, Traversable) + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) instance Eq1 Comment where liftEq = genericLiftEq instance Show1 Comment where liftShowsPrec = genericLiftShowsPrec +instance Pretty1 Comment where + liftPretty _ _ (Comment c) = pretty ("Comment" :: String) <+> pretty (decodeUtf8With (\ _ -> ('\xfffd' <$)) c) + -- TODO: nested comment types -- TODO: documentation comment types -- TODO: literate programming comment types? alternatively, consider those as markup