blob: 17ced8677af445e805bc377d95c3ed327a9d8be2 (
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
|
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
{-# 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))
|