Ticket #3018: A.hs

File A.hs, 0.8 KB (added by ben.kavanagh, 3 years ago)

This is the code that fails.

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