1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 05:11:44 +03:00

Define Pretty1 for comments without orphans.

This commit is contained in:
Rob Rix 2017-08-22 14:20:47 -04:00
parent 367c6a73c5
commit 507b2e02ef

View File

@ -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