#4125: Template haskell rejects duplicate instances before they're spliced
---------------------------------+------------------------------------------
    Reporter:  lilac             |        Owner:                           
        Type:  bug               |       Status:  new                      
    Priority:  normal            |    Milestone:                           
   Component:  Template Haskell  |      Version:  6.12.1                   
    Keywords:                    |   Difficulty:                           
          Os:  Unknown/Multiple  |     Testcase:                           
Architecture:  Unknown/Multiple  |      Failure:  GHC rejects valid program
---------------------------------+------------------------------------------

Comment(by simonpj):

 I can see why you think it's ridiculous, but there an underlying reason.
 Remember that TH quotations are ''typechecked''.  So if you write `[| map
 f [a,b] |]`, TH checks that the argument of `map` is compatible with
 `map`'s type.  To do that, it uses the type environment from outside the
 quote, which binds `map`.

 Your example contains an instance declaration.  If you saw `[| return True
 :: T Bool |]` you'd probably expect that to typecheck if (and only if) `T`
 is an instance of `Monad`.  Again, the instance environment comes from
 outside the quote.

 In this case it's a declaration splice but the story is the same: the
 declarations are typechecked in the type/instance environment from outside
 the quote; and that's why you get the complaint about a duplicate.

 So I'm going to flag this as "invalid", not because it's silly but because
 GHC is behaving according to specification at the moment.  I suppose one
 could imagine some kind of feature that would support what you want, but
 I'm not sure what the design would be.  If you feel like producing a
 design, by all means open a new feature request.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4125#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to