Re: Strange behaviour with classes (both Hugs and GHC)

"Sigbjorn Finne" <[email protected]> Wed, 31 May 2006 06:33:32 -0700
Newsgroups gmane.comp.lang.haskell.hugs.bugs,gmane.comp.lang.haskell.glasgow.bugs
Message-ID <0baa01c684b6$d05cba10$6501a8c0@soflap>
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" <[email protected]>
To: <[email protected]>; <[email protected]>
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
> [email protected]
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
>