Strange behaviour with classes (both Hugs and GHC)
Sigbjorn Finne
sof at galois.com
Wed May 31 09:33:32 EDT 2006
Hi,
if you desugar the definition that's causing the type error,
perhaps it becomes a little bit clearer what's going on, i.e.,
from
problematic :: MyAnnotatedType Int
problematic = defaultVal{theInt=42,theAnnotation=10}
you expand this to
problematic' = case defaultVal of { MAT a b c -> MAT 42 b 10 }
Clearly, the type of 'c' is ambiguous here. Interestingly, if Haskell 98
had defined record update expr "e{fields}" as having the same type
as "e", this wouldn't have been an issue:
no_probs =
case defaultVal of { m@(MAT a b c) -> (MAT 42 b 10) `asTypeOf` m}
hth
--sigbjorn
----- Original Message -----
From: "Magnus Björk" <mab at cs.chalmers.se>
To: <glasgow-haskell-bugs at haskell.org>; <hugs-bugs at haskell.org>
Sent: Monday, May 29, 2006 03:34
Subject: Strange behaviour with classes (both Hugs and GHC)
>I just ran into a strange behaviour of both Hugs and GHC. I discussed it
> with John Hughes who managed to find a workaround, and suggested that I
> ask you whether this is really expected behaviour.
>
> The attached file contains a small example that exhibits the problem.
>
> --
> /MpB
--------------------------------------------------------------------------------
> _______________________________________________
> Glasgow-haskell-bugs mailing list
> Glasgow-haskell-bugs at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
>
More information about the Hugs-Bugs
mailing list