{-# LANGUAGE TypeOperators, FlexibleInstances, TypeSynonymInstances,
IncoherentInstances, UndecidableInstances, TemplateHaskell, GADTs #-}
module Data.Comp.Param.Multi.Show
(
ShowHD(..)
) where
import Data.Comp.Param.Multi.Term
import Data.Comp.Param.Multi.HDifunctor
import Data.Comp.Param.Multi.Ops
import Data.Comp.Param.Multi.Derive
import Data.Comp.Param.Multi.FreshM
$(derive [liftSum] [''ShowHD])
instance (HDifunctor f, ShowHD f) => ShowHD (Cxt h f) where
showHD (In t) = showHD $ hfmap (K . showHD) t
showHD (Hole h) = unK h
showHD (Var p) = return $ show p
instance (HDifunctor f, ShowHD f) => Show (Term f i) where
show = evalFreshM . showHD . toCxt . unTerm
instance (ShowHD f, Show p) => ShowHD (f :&: p) where
showHD (x :&: p) = do sx <- showHD x
return $ sx ++ " :&: " ++ show p