Hello Lennart,<br><br>Yes, but according to the manual (<a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#undecidable-instances">http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#undecidable-instances</a>), "Termination is ensured by having a
fixed-depth recursion stack". So I would expect at least termination, which I'm not getting (but I guess that can be due to the type families).<br><br><br>Thanks,<br>Pedro<br><br><div class="gmail_quote">On Thu, Dec 4, 2008 at 15:10, Lennart Augustsson <span dir="ltr"><<a href="mailto:lennart@augustsson.net">lennart@augustsson.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Turning on UndecidableInstances is the same as saying: OK typechcker,<br>
you can loop if I make a mistake.<br>
I've not looked closely at your code, but if you turn on that flag,<br>
looping is probably not a bug.<br>
<br>
-- Lennart<br>
<br>
2008/12/4 José Pedro Magalhães <<a href="mailto:jpm@cs.uu.nl">jpm@cs.uu.nl</a>>:<br>
<div><div></div><div class="Wj3C7c">> Hello all,<br>
><br>
> Please consider the following code:<br>
><br>
>> {-# OPTIONS -Wall #-}<br>
>> {-# LANGUAGE FlexibleContexts #-}<br>
>> {-# LANGUAGE FlexibleInstances #-}<br>
>> {-# LANGUAGE TypeOperators #-}<br>
>> {-# LANGUAGE TypeFamilies #-}<br>
>> {-# LANGUAGE OverlappingInstances #-}<br>
>> {-# LANGUAGE UndecidableInstances #-}<br>
>><br>
>> module Test where<br>
>><br>
>> -- Some view<br>
>> class Viewable a where<br>
>> type View a<br>
>> to :: a -> View a<br>
>><br>
>> -- Structural representations<br>
>> data Unit = Unit<br>
>> data a :+: b = L a | R b<br>
>><br>
>> instance Viewable Unit where<br>
>> type View Unit = Unit<br>
>> to = id<br>
>><br>
>> instance (Viewable a, Viewable b) => Viewable (a :+: b) where<br>
>> type View (a :+: b) = a :+: b<br>
>> to = id<br>
>><br>
>> -- Worker class<br>
>> class F' a where<br>
>> f' :: a -> ()<br>
>><br>
>> instance F' Unit where<br>
>> f' Unit = ()<br>
>><br>
>> instance (F a, F b) => F' (a :+: b) where<br>
>> f' (L x) = f x<br>
>> f' (R x) = f x<br>
>><br>
>><br>
>> -- Dispatcher class<br>
>> class (Viewable a, F' (View a)) => F a where<br>
>> f :: a -> ()<br>
>> f = f' . to<br>
>><br>
>> instance F Unit where<br>
>> f = f'<br>
>><br>
>> instance (F a, F b) => F (a :+: b) where<br>
>> f = f'<br>
>><br>
>> -- All generic instances<br>
>> instance (Viewable a, F' (View a)) => F a<br>
>><br>
>><br>
>> -- A recursive datatype<br>
>> data Nat = Zero | Succ Nat<br>
>><br>
>> -- Instance of Viewable<br>
>> instance Viewable Nat where<br>
>> type View Nat = Unit :+: Nat<br>
>> to = undefined<br>
>><br>
>> -- Uncommenting the line below causes the typechecker to loop (GHC 6.10.1,<br>
>> Windows)<br>
>> --test = f Zero<br>
><br>
><br>
> Is this expected behavior or a bug?<br>
><br>
><br>
> Thanks,<br>
> Pedro<br>
><br>
</div></div>> _______________________________________________<br>
> Glasgow-haskell-users mailing list<br>
> <a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
><br>
><br>
</blockquote></div><br>