[project @ 2005-07-19 16:44:50 by simonpj]
authorsimonpj <unknown>
Tue, 19 Jul 2005 16:45:02 +0000 (16:45 +0000)
committersimonpj <unknown>
Tue, 19 Jul 2005 16:45:02 +0000 (16:45 +0000)
commita7ecdf96844404b7bc8273d4ff6d85759278427c
treebc03e6e6643d96a1237b61e9caf5f047e458e42e
parent8a9aba1ff5e66aad02aba0997339ea6ec60d6b1e
[project @ 2005-07-19 16:44:50 by simonpj]
WARNING: this is a big commit.  You might want
to wait a few days before updating, in case I've
broken something.

However, if any of the changes are what you wanted,
please check it out and test!

This commit does three main things:

1. A re-organisation of the way that GHC handles bindings in HsSyn.
   This has been a bit of a mess for quite a while.  The key new
   types are

-- Bindings for a let or where clause
data HsLocalBinds id
  = HsValBinds (HsValBinds id)
  | HsIPBinds  (HsIPBinds id)
  | EmptyLocalBinds

-- Value bindings (not implicit parameters)
data HsValBinds id
  = ValBindsIn  -- Before typechecking
(LHsBinds id) [LSig id] -- Not dependency analysed
-- Recursive by default

  | ValBindsOut -- After typechecking
[(RecFlag, LHsBinds id)]-- Dependency analysed

2. Implement Mark Jones's idea of increasing polymoprhism
   by using type signatures to cut the strongly-connected components
   of a recursive group.  As a consequence, GHC no longer insists
   on the contexts of the type signatures of a recursive group
   being identical.

   This drove a significant change: the renamer no longer does dependency
   analysis.  Instead, it attaches a free-variable set to each binding,
   so that the type checker can do the dep anal.  Reason: the typechecker
   needs to do *two* analyses:
one to find the true mutually-recursive groups
(which we need so we can build the right CoreSyn)
one to find the groups in which to typecheck, taking
account of type signatures

3. Implement non-ground SPECIALISE pragmas, as promised, and as
   requested by Remi and Ross.  Certainly, this should fix the
   current problem with GHC, namely that if you have
g :: Eq a => a -> b -> b
   then you can now specialise thus
SPECIALISE g :: Int -> b -> b
    (This didn't use to work.)

   However, it goes further than that.  For example:
f :: (Eq a, Ix b) => a -> b -> b
   then you can make a partial specialisation
SPECIALISE f :: (Eq a) => a -> Int -> Int

    In principle, you can specialise f to *any* type that is
    "less polymorphic" (in the sense of subsumption) than f's
    actual type.  Such as
SPECIALISE f :: Eq a => [a] -> Int -> Int
    But I haven't tested that.

    I implemented this by doing the specialisation in the typechecker
    and desugarer, rather than leaving around the strange SpecPragmaIds,
    for the specialiser to find.  Indeed, SpecPragmaIds have vanished
    altogether (hooray).

    Pragmas in general are handled more tidily.  There's a new
    data type HsBinds.Prag, which lives in an AbsBinds, and carries
    pragma info from the typechecker to the desugarer.

Smaller things

- The loop in the renamer goes via RnExpr, instead of RnSource.
  (That makes it more like the type checker.)

- I fixed the thing that was causing 'check_tc' warnings to be
  emitted.
71 files changed:
ghc/compiler/basicTypes/BasicTypes.lhs
ghc/compiler/basicTypes/Id.lhs
ghc/compiler/basicTypes/IdInfo.lhs
ghc/compiler/basicTypes/NameEnv.lhs
ghc/compiler/basicTypes/Var.lhs
ghc/compiler/coreSyn/CoreUnfold.lhs
ghc/compiler/coreSyn/PprCore.lhs
ghc/compiler/deSugar/Desugar.lhs
ghc/compiler/deSugar/DsArrows.lhs
ghc/compiler/deSugar/DsBinds.lhs
ghc/compiler/deSugar/DsExpr.hi-boot-6
ghc/compiler/deSugar/DsExpr.lhs
ghc/compiler/deSugar/DsExpr.lhs-boot
ghc/compiler/deSugar/DsForeign.lhs
ghc/compiler/deSugar/DsGRHSs.lhs
ghc/compiler/deSugar/DsListComp.lhs
ghc/compiler/deSugar/DsMeta.hs
ghc/compiler/deSugar/DsMonad.lhs
ghc/compiler/deSugar/Match.lhs
ghc/compiler/deSugar/MatchCon.lhs
ghc/compiler/hsSyn/Convert.lhs
ghc/compiler/hsSyn/HsBinds.lhs
ghc/compiler/hsSyn/HsDecls.lhs
ghc/compiler/hsSyn/HsExpr.lhs
ghc/compiler/hsSyn/HsUtils.lhs
ghc/compiler/iface/IfaceSyn.lhs
ghc/compiler/iface/IfaceType.lhs
ghc/compiler/iface/MkIface.lhs
ghc/compiler/main/CodeOutput.lhs
ghc/compiler/main/GHC.hs
ghc/compiler/main/HscStats.lhs
ghc/compiler/main/Main.hs
ghc/compiler/parser/Parser.y.pp
ghc/compiler/parser/RdrHsSyn.lhs
ghc/compiler/rename/RnBinds.lhs
ghc/compiler/rename/RnEnv.lhs
ghc/compiler/rename/RnExpr.hi-boot-6 [new file with mode: 0644]
ghc/compiler/rename/RnExpr.lhs
ghc/compiler/rename/RnHsSyn.lhs
ghc/compiler/rename/RnNames.lhs
ghc/compiler/rename/RnSource.hi-boot-6 [deleted file]
ghc/compiler/rename/RnSource.lhs
ghc/compiler/rename/RnTypes.lhs
ghc/compiler/simplCore/OccurAnal.lhs
ghc/compiler/simplCore/SimplCore.lhs
ghc/compiler/simplCore/SimplUtils.lhs
ghc/compiler/specialise/Rules.lhs
ghc/compiler/specialise/Specialise.lhs
ghc/compiler/stgSyn/CoreToStg.lhs
ghc/compiler/typecheck/Inst.lhs
ghc/compiler/typecheck/TcArrows.lhs
ghc/compiler/typecheck/TcBinds.lhs
ghc/compiler/typecheck/TcClassDcl.lhs
ghc/compiler/typecheck/TcDeriv.lhs
ghc/compiler/typecheck/TcEnv.lhs
ghc/compiler/typecheck/TcExpr.lhs
ghc/compiler/typecheck/TcHsSyn.lhs
ghc/compiler/typecheck/TcHsType.lhs
ghc/compiler/typecheck/TcInstDcls.lhs
ghc/compiler/typecheck/TcMatches.lhs
ghc/compiler/typecheck/TcRnDriver.lhs
ghc/compiler/typecheck/TcRnMonad.lhs
ghc/compiler/typecheck/TcRules.lhs
ghc/compiler/typecheck/TcSplice.lhs
ghc/compiler/typecheck/TcUnify.lhs
ghc/compiler/types/Generics.lhs
ghc/compiler/types/TyCon.lhs
ghc/compiler/utils/IOEnv.hs
ghc/compiler/utils/ListSetOps.lhs
ghc/compiler/utils/UniqFM.lhs
ghc/compiler/utils/Util.lhs