Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#1406 closed bug (fixed)

Constraint doesn't reduce in the presence of quantified type variables

Reported by: ccshan Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 6.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: x86
Type of failure: None/Unknown Test Case: tc229
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-undecidable-instances #-}

module Problem where

data Z
data S a

class HPrefix l
instance (NSub (S Z) ndiff, HDrop ndiff l l) => HPrefix l

class NSub n1 n3 | n1 -> n3
instance NSub Z Z
instance NSub n1 n3 => NSub (S n1) n3

class HDrop n l1 l2 | n l1 -> l2
instance HDrop Z l l

t_hPrefix :: HPrefix l => l -> ()
t_hPrefix = undefined

-- This works...
thr' :: (forall r. l -> a) -> a
thr' f = f undefined
thP4' = thr' t_hPrefix

-- ... but this doesn't work...?
thr :: (forall r. r -> a) -> a
thr f = f undefined
thP4 = thr t_hPrefix
$ ghci GHCProblem.hs 
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 6.6.1, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
[1 of 1] Compiling Problem          ( GHCProblem.hs, interpreted )

GHCProblem.hs:30:11:
    No instance for (HDrop ndiff r r)
      arising from use of `t_hPrefix' at GHCProblem.hs:30:11-19
    Possible fix:
      add (HDrop ndiff r r) to the expected type of an expression
    In the first argument of `thr', namely `t_hPrefix'
    In the expression: thr t_hPrefix
    In the definition of `thP4': thP4 = thr t_hPrefix
Failed, modules loaded: none.

Change History (2)

comment:1 Changed 12 years ago by igloo

Resolution: fixed
Status: newclosed
Test Case: tc229

Thanks for the report. This already works in the HEAD; I've added your example to the testsuite as test tc229.

comment:2 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.