module Data.Reify.TGraph
( ShowF(..), Id, V(..), Bind(..), Graph(..)
) where
type Id = Int
data V ty a = V Id (ty a)
instance Eq (V ty a) where V i _ == V j _ = i == j
data Bind ty n = forall a. Bind (V ty a) (n (V ty) a)
class ShowF f where
showF :: f a -> String
instance ShowF (V ty) where
showF (V i _) = 'x' : show i
instance Show (V ty a) where show = showF
instance ShowF (n (V ty)) => Show (Bind ty n) where
show (Bind v n) = showF v ++" = "++ showF n
data Graph ty n a = Graph [Bind ty n] (V ty a)
instance (ShowF (n (V ty)), Show (V ty a)) => Show (Graph ty n a) where
show (Graph netlist start) = "let " ++ show netlist ++ " in " ++ show start