{-# LANGUAGE OverlappingInstances , UndecidableInstances, EmptyDataDecls #-}
{-# LANGUAGE Rank2Types, KindSignatures, MultiParamTypeClasses, FlexibleInstances #-}


module InstFail where

-- minimal Data/Rep classes
data Rep ctx a

class Data (ctx :: * -> *) a where rep :: Rep ctx a  

class Sat a where dict :: a 



-- Substitution class
-- substitute [a -> t] t'. 
class Subst a t t' where
    subst :: a -> t -> t' -> t'

data SubstD a t t' = SubstD {substD:: a -> t -> t' -> t'}

-- allow override dictionary verion with implementation of type class Subst
instance Subst a t t' => Sat (SubstD a t t') where
    dict = SubstD {substD = subst}

-- generic instance
instance Data (SubstD a t) t' => Subst a t t' where
    subst = undefined



