Stefan Holdermans | 15 May 15:43

Type checker loops with innocent looking associated type synonym

I've written this cute ;-) piece of code involving an associated type  
synonym,

   {-# OPTIONS_GHC -fglasgow-exts #-}

   class ZipWithA a where
     type Elem a :: *
     zipWithA    :: [Elem a] -> a

   instance ZipWithA [a] where
     type Elem [a] = a
     zipWithA xs   = xs

   instance ZipWithA b => ZipWithA ([a] -> b) where
     type Elem ([a] -> b) = a -> Elem b
     zipWithA fs          = zipWithA . zipWith ($) fs

and it behaves as intended:

   *Main> zipWithA [2, 3] :: [Int]
   [2,3]

   *Main> zipWithA [pred, succ] [2, 3] :: [Int]
   [1,4]

   *Main> zipWithA [(+), (-)] [2, 3] [5, 7] :: [Int]
   [7,-4]

However, as soon as the overloading cannot be resolved, the type  
checker loops:
(Continue reading)

Bulat Ziganshin | 15 May 16:26

Re: Type checker loops with innocent looking associated type synonym

Hello Stefan,

Thursday, May 15, 2008, 5:46:57 PM, you wrote:

>    class ZipWithA a where
>      type Elem a :: *

> Should I report this a bug? Or is it perhaps already been taken care  
> of in the head? Or am I just plain unreasonable here? :-)

afair, the rule of thumb is: please don't report us errors with type
families in 6.8 - it's unofficial and incomplete here. test against
HEAD if you are really interested

--

-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin <at> gmail.com
Favicon
Gravatar

Re: Type checker loops with innocent looking associated type synonym

Stefan Holdermans:
> Should I report this a bug? Or is it perhaps already been taken care  
> of in the head?

Probably the latter.

But really as, Bulat wrote, type families in 6.8 are unsupported.   
Please test your code with a HEAD snapshot.  If that goes wrong, a bug  
report on Trac would be most appreciated.

Manuel
Stefan Holdermans | 22 May 13:40

Re: Type checker loops with innocent looking associated type synonym

Manuel,

>> Should I report this a bug? Or is it perhaps already been taken  
>> care of in the head?
>
> Probably the latter.
>
> But really as, Bulat wrote, type families in 6.8 are unsupported.   
> Please test your code with a HEAD snapshot.  If that goes wrong, a  
> bug report on Trac would be most appreciated.

Indeed: no problem with yesterday's HEAD.

Thanks,

   Stefan

Gmane