#89: type inference failure in ghc/hugs extensions
---------------------------------+------------------------------------------ Reporter: guest | Owner: nobody Type: defect | Status: new Priority: major | Milestone: Component: hugs | Version: 200609 Keywords: instance extensions | ---------------------------------+------------------------------------------ Oleg recently posted on the mailing list [hidden email] a magic coercion that makes pairs of numbers (x,y) behave as complex numbers. Aside from context, the type should be (a,a). The trick works with option -fglasgow-exts in ghc releases at least since 6.8.3. However in hugs Sept 2006 under option -98, it fails type inference. As I understand the documentation, option -98 is supposed to support the necessary extensions in common with ghc. Is the inconsistent handling of the attached fragment a bug, a feature, or perhaps an undefined corner of the semantics? Doug McIlroy [hidden email] -- Ticket URL: <http://hackage.haskell.org/trac/hugs/ticket/89> Hugs <http://www.haskell.org/hugs/> Hugs 98, an interpreter for Haskell _______________________________________________ Hugs-Bugs mailing list [hidden email] http://www.haskell.org/mailman/listinfo/hugs-bugs |
#89: type inference failure in ghc/hugs extensions
----------------------+----------------------------------------------------- Reporter: guest | Owner: nobody Type: defect | Status: closed Priority: major | Milestone: Component: hugs | Version: 200609 Resolution: invalid | Keywords: instance extensions ----------------------+----------------------------------------------------- Changes (by ross): * status: new => closed * resolution: => invalid Comment: There's an error in the example: should be (a,a) in the instance. If test1 is supplied with a signature, hugs then accepts this (but GHC 6.10 doesn't). -- Ticket URL: <http://hackage.haskell.org/trac/hugs/ticket/89#comment:1> Hugs <http://www.haskell.org/hugs/> Hugs 98, an interpreter for Haskell _______________________________________________ Hugs-Bugs mailing list [hidden email] http://www.haskell.org/mailman/listinfo/hugs-bugs |
In reply to this post by GHC-2
#89: type inference failure in ghc/hugs extensions
---------------------+------------------------------------------------------ Reporter: guest | Owner: nobody Type: defect | Status: reopened Priority: major | Milestone: Component: hugs | Version: 200609 Resolution: | Keywords: instance extensions ---------------------+------------------------------------------------------ Changes (by guest): * status: closed => reopened * resolution: invalid => Comment: Replying to [comment:1 ross]: > There's an error in the example: should be (a,a) in the instance. If test1 is supplied with a signature, hugs then accepts this (but GHC 6.10 doesn't). I understand the proposed fix to be essentially as follows, wherein the TypeCast classes become unnecessary {{{ instance Num a => Num (a,a) where (x,y)*(u,v) = (x*u-y*v, x*v+y*u) test1 :: Num a => (a,a) test1 = (1,1)*(2,2) }}} This code is defective in that (a,a) in the instance head does not force the two operands in (x,y) to the same type when (x,y) serves as a Num. The type of test1 cannot be inferred; it has to be declared. (I suspect GHC's rejection of the code is a symptom of the defect.) Oleg's magic was devised precisely to overcome the defect; see the threads http://www.haskell.org/pipermail/haskell/2009-January/020963.html http://www.haskell.org/pipermail/haskell/2009-January/020978.html (Oleg points out that the elaborate TypeCast mechanism can be simplified by using the a~b syntax available in GHC 6.10. I use the elaborate alternative because its syntax is supported more widely.) The bottom line is that Hugs and GHC infer types differently under the "same" type extensions. The difference needs to be sorted out, for the sake of Haskell' if not for me. Barring arcane reasons to the contrary, I incline towards GHC's approach, because it allows the programmer to place more of the burden of type inference on the compiler, so as to unclutter his mind and his code Doug McIlroy [hidden email] -- Ticket URL: <http://hackage.haskell.org/trac/hugs/ticket/89#comment:2> Hugs <http://www.haskell.org/hugs/> Hugs 98, an interpreter for Haskell _______________________________________________ Hugs-Bugs mailing list [hidden email] http://www.haskell.org/mailman/listinfo/hugs-bugs |
Free forum by Nabble | Edit this page |