Commits

Emil Axelsson committed a98aeaa

ShowConstr instance for :+: and :&:

  • Participants
  • Parent commits fc3b3ac

Comments (0)

Files changed (2)

File src/Data/Comp/Render.hs

+{-# LANGUAGE TypeOperators, TemplateHaskell, TypeSynonymInstances #-}
 module Data.Comp.Render where
 
 import Data.Foldable (toList)
 -- | Write a term to an HTML file with foldable nodes
 writeHtmlTerm :: Render f => FilePath -> Term f -> IO ()
 writeHtmlTerm file = writeHtmlTree file . fmap (\n -> NodeInfo n "") . stringTree
+
+$(derive [liftSum] [''ShowConstr])

File src/Data/Comp/Show.hs

     showF (v :&: p) = showF v ++ " :&: " ++ show p
 
 $(derive [liftSum] [''ShowF])
-$(derive [makeShowF] [''Maybe, ''[], ''(,)])
+$(derive [makeShowF] [''Maybe, ''[], ''(,)])
+
+instance (ShowConstr f, Show p) => ShowConstr (f :&: p) where
+    showConstr (v :&: p) = showConstr v ++ " :&: " ++ show p
+
+$(derive [liftSum] [''ShowConstr])