#2187: Top-level bindings are broken for polymorphic values
----------------------+-----------------------------------------------------
 Reporter:  yallop    |          Owner:             
     Type:  bug       |         Status:  new        
 Priority:  normal    |      Milestone:  6.10 branch
Component:  Compiler  |        Version:  6.8.2      
 Severity:  major     |     Resolution:             
 Keywords:            |     Difficulty:  Unknown    
 Testcase:            |   Architecture:  Unknown    
       Os:  Unknown   |  
----------------------+-----------------------------------------------------
Comment (by yallop):

 Thanks for the reply.  Yes, I ran into the problem in a real program.

 I have code that looks like this:
 {{{
    (x1,...,xn) = (e1,...en)
       where y = e
             z = f
 }}}

 which is generated via Template Haskell.  Sometimes the bindings are
 supposed to be polymorphic, sometimes not.

 It looks like I have two choices, neither of which is particularly
 desirable:

    1. Change the generation scheme to emit less elegant code, which will
 also
       complicate the generation code.
    2. Require all users of the library to add -XNoMonoPatBinds

 From a user's perspective (at least, from this user's), defaulting to
 monomorphic pattern bindings looks like quite an unfortunate choice:

    1. It doesn't bring any actual benefits to the user (that I can see).
    2. It breaks compatibility with Haskell 98, so code that works on other
 implementations mysteriously fails without so much as a warning.
    3. It generates quite unusable code: there's no realistic use for
 functions of type
 {{{
         GHC.Prim.Any -> GHC.Prim.Any
 }}}
       so why default to generating that sort of thing?
    4. It makes it more difficult to transform programs, since you can no
 longer replace
 {{{
        x = f (a,b)
 }}}
       with
 {{{
        (c,d) = (a,b)
        f (c,d)
 }}}

 It's difficult to see how it can simplify the implementation, since you
 still have to cope with -XNoMonoPatBinds.  There must be *some* reason for
 this change, but what can it be?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2187#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to