#2079: GHC 6.8.* doesn't recognize type variables
----------------------------------+-----------------------------------------
Reporter: daniel.is.fischer | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.8.2 | Severity: normal
Keywords: | Testcase:
Architecture: x86 | Os: Linux
----------------------------------+-----------------------------------------
The module
{{{
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{- # LANGUAGE FlexibleInstances # -}
module Leandro where
data Abb a b = Branch a b (Abb a b) (Abb a b) | Leaf
data ListAssoc a b = Node a b (ListAssoc a b) | Empty
class Container c a b |c -> a, c -> b where
empty :: c
add :: c -> a -> b -> c
search :: c -> a -> Maybe b
del :: c -> a -> c
toListPair :: c -> [(a,b)]
instance (Ord a) => Container (Abb a b) a b where
empty = Leaf
add Leaf x y = Branch x y Leaf Leaf
add arb@(Branch ni nd ri rd) x y
|x == ni = arb
|x > ni = Branch ni nd ri (add rd x y)
|otherwise = Branch ni nd (add ri x y) rd
search Leaf x = Nothing
search (Branch ni nd ri rd) x
|x == ni = Just nd
|x > ni = search rd x
|x < ni = search ri x
}}}
triggers the following error in ghci (6.8.1 and 6.8.2):
{{{
[EMAIL PROTECTED]:~/Documents/haskell/move> ghci Leandro
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
[1 of 1] Compiling Leandro ( Leandro.hs, interpreted )
Leandro.hs:17:0:
Illegal instance declaration for `Container (Abb a b) a b'
(All instance types must be of the form (T a1 ... an)
where a1 ... an are distinct type *variables*
Use -XFlexibleInstances if you want to disable this.)
In the instance declaration for `Container (Abb a b) a b'
Failed, modules loaded: none.
}}}
To the best of my knowledge, a and b in 'instance Container (Abb a b) a b
where' are distinct type variables and neither hugs nor ghci-6.6.1
complain. Converting the third line to a language pragma makes the code
acceptable to 6.8.*.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2079>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs