summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/typecheck/should_compile/tc187.hs
blob: 15946f8a5033d2669aa5bd8f0777c56fd44ab57a (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
{-# LANGUAGE UndecidableInstances, FlexibleInstances,
             MultiParamTypeClasses, FunctionalDependencies #-}
-- UndecidableInstances now needed because the Coverage Condition fails

-- Hugs failed this functional-dependency test
-- Reported by Iavor Diatchki Feb 05

module ShouldCompile where

data N0
newtype Succ n    = Succ n

class Plus a b c | a b -> c
instance Plus N0 n n
instance Plus a b c => Plus (Succ a) b (Succ c)

( # )              :: Plus x y z => x -> y -> z
( # )               = undefined

class BitRep t n | t -> n where
  toBits         :: t -> n

instance BitRep Bool (Succ N0) where
  toBits = error "urk"

instance BitRep (Bool,Bool,Bool) (Succ (Succ (Succ N0))) where
  toBits (x,y,z) = toBits x # toBits y # toBits z

-- Hugs complains that it cannot solve the constraint:
-- Plus (Succ N0) (Succ N0) (Succ (Succ N0))