| 1 | {-# LANGUAGE OverlappingInstances , UndecidableInstances, EmptyDataDecls #-} |
|---|
| 2 | {-# LANGUAGE Rank2Types, KindSignatures, MultiParamTypeClasses, FlexibleInstances #-} |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | module InstFail where |
|---|
| 6 | |
|---|
| 7 | -- minimal Data/Rep classes |
|---|
| 8 | data Rep ctx a |
|---|
| 9 | |
|---|
| 10 | class Data (ctx :: * -> *) a where rep :: Rep ctx a |
|---|
| 11 | |
|---|
| 12 | class Sat a where dict :: a |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | -- Substitution class |
|---|
| 17 | -- substitute [a -> t] t'. |
|---|
| 18 | class Subst a t t' where |
|---|
| 19 | subst :: a -> t -> t' -> t' |
|---|
| 20 | |
|---|
| 21 | data SubstD a t t' = SubstD {substD:: a -> t -> t' -> t'} |
|---|
| 22 | |
|---|
| 23 | -- allow override dictionary verion with implementation of type class Subst |
|---|
| 24 | instance Subst a t t' => Sat (SubstD a t t') where |
|---|
| 25 | dict = SubstD {substD = subst} |
|---|
| 26 | |
|---|
| 27 | -- generic instance |
|---|
| 28 | instance Data (SubstD a t) t' => Subst a t t' where |
|---|
| 29 | subst = undefined |
|---|
| 30 | |
|---|