AMP (#8004) almost finished, review would be nice

Simon Peyton-Jones simonpj at microsoft.com
Fri Sep 20 14:40:52 CEST 2013


David

You'll recall this interchange about the AMP patch

| > Don't use tryTc in tcLookupClassMaybe -- it's a sledgehammer to crack
| > a nut. The only classes you are looking up are monad, applicative,
| > alternative, and they will always be found -- or at least if not we
| > have a problem, and tcLookupClass will rightly report an error.  So I
| > see no need for this tryTc and matching on maybes.
| 
| The use of tryTc there fixed the problem we (me and Dan) discussed
| recently on ghc-devs: the testsuite errors with
| 
| GHC/Base.lhs:1:1:
|     GHC internal error: ‛GHC.Base.Monad’ is not in scope during type
|     checking, but it passed the renamer tcl_env of environment: []

I think I know roughly what's happening.  Clearly we can't look up Monad in the type environment until we've typechecked that class.  But the amp-warning stuff will try to look it up *regardless*. Ditto Applicative. Trying to look it up will make GHC look for Control.Applicative.hi, which won't exist until Control.Applicative is compiled.  Hence the error.


I'll tidy this up with a bit of refactoring

Simon

| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Simon
| Peyton-Jones
| Sent: 04 September 2013 12:25
| To: David Luposchainsky
| Cc: ghc-devs at haskell.org
| Subject: RE: AMP (#8004) almost finished, review would be nice
| 
| | GHC/Base.lhs:1:1:
| |     GHC internal error: ‛GHC.Base.Monad’ is not in scope during type
| |     checking, but it passed the renamer tcl_env of environment: []
| 
| I don't understand this.  The message comes from TcEnv.notFound,
| presumably from tcLookupGlobal.  But the latter only calls notFound for
| an internal name (which this is not), or when compiling the very same
| module (GHC.Base in this case). But I think you are saying this message
| 
| So something mysterious is going on.  Can you try the obvious thing
| again and let's look at it?
| 
| (I suppose you could commit as-is (when you've unravelled the validation
| questions) so that I can see it too.)
| 
| Simon
| 
| |
| | (and the full build errored with "missing interfaces for GHC.Base").
| The
| | maybe business fixed this. (Subject of the discussion: "Cannot make
| | ghc: Failed to load interface for GHC.Base")
| |
| | Also note that the Prelude is not necessarily imported, so I think the
| | lookups here can fail regardless of the issue mentioned before.
| |
| |
| |
| | > I don't see any documentation.
| |
| | In what sense? More comments, longer function headers? I thought the
| | names used were clear, with comments giving an overview over longer
| | sections. (If you're talking about Haddock: the AMP functions are not
| | exported, hence no HTML docs. tcAmpWarn is called from inside
| | tcTopSrcDecls in the same module.)
| |
| |
| |
| | > I don't know about this validation stuff; maybe others can help.
| | > Why not *not* add -fno-warn-amp to GcStage1HcOpts?
| |
| | The flag is mysteriously passed to the existing GHC, i.e. it appears
| | when building phase 1. However, the current compiler doesn't know
| about
| | the flag and fails. (This was my initial attempt.)
| |
| |
| |
| | Thanks for the advice,
| | David/quchen
| _______________________________________________
| ghc-devs mailing list
| ghc-devs at haskell.org
| http://www.haskell.org/mailman/listinfo/ghc-devs


More information about the ghc-devs mailing list