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>), &quot;Termination is ensured by having a
fixed-depth recursion stack&quot;. So I would expect at least termination, which I&#39;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">&lt;<a href="mailto:lennart@augustsson.net">lennart@augustsson.net</a>&gt;</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&#39;ve not looked closely at your code, but if you turn on that flag,<br>
looping is probably not a bug.<br>
<br>
 &nbsp;-- Lennart<br>
<br>
2008/12/4 José Pedro Magalhães &lt;<a href="mailto:jpm@cs.uu.nl">jpm@cs.uu.nl</a>&gt;:<br>
<div><div></div><div class="Wj3C7c">&gt; Hello all,<br>
&gt;<br>
&gt; Please consider the following code:<br>
&gt;<br>
&gt;&gt; {-# OPTIONS -Wall &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #-}<br>
&gt;&gt; {-# LANGUAGE FlexibleContexts &nbsp; &nbsp; #-}<br>
&gt;&gt; {-# LANGUAGE FlexibleInstances &nbsp; &nbsp;#-}<br>
&gt;&gt; {-# LANGUAGE TypeOperators &nbsp; &nbsp; &nbsp; &nbsp;#-}<br>
&gt;&gt; {-# LANGUAGE TypeFamilies &nbsp; &nbsp; &nbsp; &nbsp; #-}<br>
&gt;&gt; {-# LANGUAGE OverlappingInstances #-}<br>
&gt;&gt; {-# LANGUAGE UndecidableInstances #-}<br>
&gt;&gt;<br>
&gt;&gt; module Test where<br>
&gt;&gt;<br>
&gt;&gt; -- Some view<br>
&gt;&gt; class Viewable a where<br>
&gt;&gt; &nbsp; type View a<br>
&gt;&gt; &nbsp; to &nbsp; :: a -&gt; View a<br>
&gt;&gt;<br>
&gt;&gt; -- Structural representations<br>
&gt;&gt; data Unit &nbsp; &nbsp;= Unit<br>
&gt;&gt; data a :+: b = L a | R b<br>
&gt;&gt;<br>
&gt;&gt; instance Viewable Unit where<br>
&gt;&gt; &nbsp; type View Unit = Unit<br>
&gt;&gt; &nbsp; to = id<br>
&gt;&gt;<br>
&gt;&gt; instance (Viewable a, Viewable b) =&gt; Viewable (a :+: b) where<br>
&gt;&gt; &nbsp; type View (a :+: b) = a :+: b<br>
&gt;&gt; &nbsp; to = id<br>
&gt;&gt;<br>
&gt;&gt; -- Worker class<br>
&gt;&gt; class F&#39; a where<br>
&gt;&gt; &nbsp; f&#39; :: a -&gt; ()<br>
&gt;&gt;<br>
&gt;&gt; instance F&#39; Unit where<br>
&gt;&gt; &nbsp; f&#39; Unit = ()<br>
&gt;&gt;<br>
&gt;&gt; instance (F a, F b) =&gt; F&#39; (a :+: b) where<br>
&gt;&gt; &nbsp; f&#39; (L x) = f x<br>
&gt;&gt; &nbsp; f&#39; (R x) = f x<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; -- Dispatcher class<br>
&gt;&gt; class (Viewable a, F&#39; (View a)) =&gt; F a where<br>
&gt;&gt; &nbsp; f :: a -&gt; ()<br>
&gt;&gt; &nbsp; f = f&#39; . to<br>
&gt;&gt;<br>
&gt;&gt; instance F Unit where<br>
&gt;&gt; &nbsp; f = f&#39;<br>
&gt;&gt;<br>
&gt;&gt; instance (F a, F b) =&gt; F (a :+: b) where<br>
&gt;&gt; &nbsp; f = f&#39;<br>
&gt;&gt;<br>
&gt;&gt; -- All generic instances<br>
&gt;&gt; instance (Viewable a, F&#39; (View a)) =&gt; F a<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; -- A recursive datatype<br>
&gt;&gt; data Nat = Zero | Succ Nat<br>
&gt;&gt;<br>
&gt;&gt; -- Instance of Viewable<br>
&gt;&gt; instance Viewable Nat where<br>
&gt;&gt; &nbsp; type View Nat = Unit :+: Nat<br>
&gt;&gt; &nbsp; to = undefined<br>
&gt;&gt;<br>
&gt;&gt; -- Uncommenting the line below causes the typechecker to loop (GHC 6.10.1,<br>
&gt;&gt; Windows)<br>
&gt;&gt; --test = f Zero<br>
&gt;<br>
&gt;<br>
&gt; Is this expected behavior or a bug?<br>
&gt;<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Pedro<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Glasgow-haskell-users mailing list<br>
&gt; <a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
&gt;<br>
&gt;<br>
</blockquote></div><br>