summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_compile/T2715.hs
blob: 0fae15eaf8afdf95fecfa10d12ded8ea9dcc8d07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts #-}

module T2715 where

data Interval v where
   Intv :: (Ord v, Enum v) => (v,v) -> Interval v

type family Domain (d :: * -> *) :: * -> *
type instance Domain Interval = Interval 

type family Value (d :: * -> *) :: *


class IDomain d where
   empty   :: (Ord (Value d), Enum (Value d)) => (Domain d) (Value d)

class (IDomain d1) -- (IDomain d1, IDomain d2, Value d1 ~ Value d2) 
   => IIDomain (d1 :: * -> *) (d2 :: * -> * ) where
   equals  :: Domain d1 (Value d1) -> Domain d2 (Value d2) -> Bool


instance Ord (Value Interval) 
      => IDomain Interval where
   empty                   = Intv (toEnum 1, toEnum 0)

instance Ord (Value Interval) 
      => IIDomain Interval Interval where
   equals  (Intv ix) (Intv iy) = ix == iy