<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>As Lennart wrote, with UndecideableInstances all bets are off. &nbsp;</div><div><br></div><div>Concerning the fixed-depth recursion stack. &nbsp;It is currently only used for the simplification of class instance declarations, but if improvement rules are involved (either FDs or TFs) that check will not catch all cases anyway.</div><div><br></div><div>The interaction between solving class constraints and equalities with type families is currently rather ad hoc. &nbsp;We are currently re-designing that interaction and may then make the fixed-depth restriction more broadly applicable. &nbsp;However, as Tom already mentioned, the cycle does not involve type families in your example anyway.</div><div><br></div><div>Manuel</div><br><div><div>José Pedro Magalhães:</div><blockquote type="cite">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">&lt;<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> &nbsp;-- Lennart<br> <br> 2008/12/4 José Pedro Magalhães &lt;<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 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #-}<br> >> {-# LANGUAGE FlexibleContexts &nbsp; &nbsp; #-}<br> >> {-# LANGUAGE FlexibleInstances &nbsp; &nbsp;#-}<br> >> {-# LANGUAGE TypeOperators &nbsp; &nbsp; &nbsp; &nbsp;#-}<br> >> {-# LANGUAGE TypeFamilies &nbsp; &nbsp; &nbsp; &nbsp; #-}<br> >> {-# LANGUAGE OverlappingInstances #-}<br> >> {-# LANGUAGE UndecidableInstances #-}<br> >><br> >> module Test where<br> >><br> >> -- Some view<br> >> class Viewable a where<br> >> &nbsp; type View a<br> >> &nbsp; to &nbsp; :: a -> View a<br> >><br> >> -- Structural representations<br> >> data Unit &nbsp; &nbsp;= Unit<br> >> data a :+: b = L a | R b<br> >><br> >> instance Viewable Unit where<br> >> &nbsp; type View Unit = Unit<br> >> &nbsp; to = id<br> >><br> >> instance (Viewable a, Viewable b) => Viewable (a :+: b) where<br> >> &nbsp; type View (a :+: b) = a :+: b<br> >> &nbsp; to = id<br> >><br> >> -- Worker class<br> >> class F' a where<br> >> &nbsp; f' :: a -> ()<br> >><br> >> instance F' Unit where<br> >> &nbsp; f' Unit = ()<br> >><br> >> instance (F a, F b) => F' (a :+: b) where<br> >> &nbsp; f' (L x) = f x<br> >> &nbsp; f' (R x) = f x<br> >><br> >><br> >> -- Dispatcher class<br> >> class (Viewable a, F' (View a)) => F a where<br> >> &nbsp; f :: a -> ()<br> >> &nbsp; f = f' . to<br> >><br> >> instance F Unit where<br> >> &nbsp; f = f'<br> >><br> >> instance (F a, F b) => F (a :+: b) where<br> >> &nbsp; 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> >> &nbsp; type View Nat = Unit :+: Nat<br> >> &nbsp; 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> _______________________________________________<br>Glasgow-haskell-users mailing list<br><a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>http://www.haskell.org/mailman/listinfo/glasgow-haskell-users<br></blockquote></div><br></body></html>