1. 16 Jan, 2015 1 commit
    • Alan Zimmerman's avatar
      API Annotations tweaks. · 11881ec6
      Alan Zimmerman authored
      HsTyLit now has SourceText
      Update documentation of HsSyn to reflect which annotations are attached to which element.
      Ensure that the parser always keeps HsSCC and HsTickPragma values, to
      be ignored in the desugar phase if not needed
      Bringing in SourceText for pragmas
      Add Location in NPlusKPat
      Add Location in FunDep
      Make RecCon payload Located
      Explicitly add AnnVal to RdrName where it is compound
      Add Location in IPBind
      Add Location to name in IEThingAbs
      Add Maybe (Located id,Bool) to Match to track fun_id,infix
        This includes converting Match into a record and adding a note about why
        the fun_id needs to be replicated in the Match.
      Add Location in KindedTyVar
      Sort out semi-colons for parsing
        - import statements
        - stmts
        - decls
        - decls_cls
        - decls_inst
      This updates the haddock submodule.
      Test Plan: ./validate
      Reviewers: hvr, austin, goldfire, simonpj
      Reviewed By: simonpj
      Subscribers: thomie, carter
      Differential Revision: https://phabricator.haskell.org/D538
  2. 14 Jan, 2015 1 commit
  3. 11 Jan, 2015 1 commit
  4. 09 Jan, 2015 1 commit
  5. 08 Jan, 2015 1 commit
    • Simon Peyton Jones's avatar
      Improve HsBang · 9564bb8c
      Simon Peyton Jones authored
      Provoked by questions from Johan
       - Improve comments, fix misleading stuff
       - Add commented synonyms for HsSrcBang, HsImplBang, and use them throughout
       - Rename HsUserBang to HsSrcBang
       - Rename dataConStrictMarks to dataConSrcBangs
                dataConRepBangs    to dataConImplBangs
      This renaming affects Haddock in a trivial way, hence submodule update
  6. 06 Jan, 2015 4 commits
    • Simon Peyton Jones's avatar
    • Simon Peyton Jones's avatar
    • Simon Peyton Jones's avatar
      Major patch to add -fwarn-redundant-constraints · 32973bf3
      Simon Peyton Jones authored
      The idea was promted by Trac #9939, but it was Christmas, so I did
      some recreational programming that went much further.
      The idea is to warn when a constraint in a user-supplied context is
      redundant.  Everything is described in detail in
        Note [Tracking redundant constraints]
      in TcSimplify.
      Main changes:
       * The new ic_status field in an implication, of type ImplicStatus.
         It replaces ic_insol, and includes information about redundant
       * New function TcSimplify.setImplicationStatus sets the ic_status.
       * TcSigInfo has sig_report_redundant field to say whenther a
         redundant constraint should be reported; and similarly
         the FunSigCtxt constructor of UserTypeCtxt
       * EvBinds has a field eb_is_given, to record whether it is a given
         or wanted binding. Some consequential chagnes to creating an evidence
         binding (so that we record whether it is given or wanted).
       * AbsBinds field abs_ev_binds is now a *list* of TcEvBiinds;
         see Note [Typechecking plan for instance declarations] in
       * Some significant changes to the type checking of instance
         declarations; Note [Typechecking plan for instance declarations]
         in TcInstDcls.
       * I found that TcErrors.relevantBindings was failing to zonk the
         origin of the constraint it was looking at, and hence failing to
         find some relevant bindings.  Easy to fix, and orthogonal to
         everything else, but hard to disentangle.
      Some minor refactorig:
       * TcMType.newSimpleWanteds moves to Inst, renamed as newWanteds
       * TcClassDcl and TcInstDcls now have their own code for typechecking
         a method body, rather than sharing a single function. The shared
         function (ws TcClassDcl.tcInstanceMethodBody) didn't have much code
         and the differences were growing confusing.
       * Add new function TcRnMonad.pushLevelAndCaptureConstraints, and
         use it
       * Add new function Bag.catBagMaybes, and use it in TcSimplify
    • Simon Peyton Jones's avatar
      Replace fixVarSet with transCloVarSet · 8e2ed2c7
      Simon Peyton Jones authored
      I think the new implementation is a bit more efficient, because
      it uses a work-list, rather than iterating over the entire set
      every time
  7. 23 Dec, 2014 1 commit
    • Simon Peyton Jones's avatar
      Eliminate so-called "silent superclass parameters" · a6f0f5ab
      Simon Peyton Jones authored
      The purpose of silent superclass parameters was to solve the
      awkward problem of superclass dictinaries being bound to bottom.
      See THE PROBLEM in Note [Recursive superclasses] in TcInstDcls
      Although the silent-superclass idea worked,
        * It had non-local consequences, and had effects even in Haddock,
          where we had to discard silent parameters before displaying
          instance declarations
        * It had unexpected peformance costs, shown up by Trac #3064 and its
          test case.  In monad-transformer code, when constructing a Monad
          dictionary you had to pass an Applicative dictionary; and to
          construct that you neede a Functor dictionary. Yet these extra
          dictionaries were often never used.  (All this got much worse when
          we added Applicative as a superclass of Monad.) Test T3064
          compiled *far* faster after silent superclasses were eliminated.
        * It introduced new bugs.  For example SilentParametersOverlapping,
          T5051, and T7862, all failed to compile because of instance overlap
          directly because of the silent-superclass trick.
      So this patch takes a new approach, which I worked out with Dimitrios
      in the closing hours before Christmas.  It is described in detail
      in THE PROBLEM in Note [Recursive superclasses] in TcInstDcls.
      Seems to work great!
      Quite a bit of knock-on effect
       * The main implementation work is in tcSuperClasses in TcInstDcls
         Everything else is fall-out
       * IdInfo.DFunId no longer needs its n-silent argument
         * Ditto IDFunId in IfaceSyn
         * Hence interface file format changes
       * Now that DFunIds do not have silent superclass parameters, printing
         out instance declarations is simpler. There is tiny knock-on effect
         in Haddock, so that submodule is updated
       * I realised that when computing the "size of a dictionary type"
         in TcValidity.sizePred, we should be rather conservative about
         type functions, which can arbitrarily increase the size of a type.
         Hence the new datatype TypeSize, which has a TSBig constructor for
         "arbitrarily big".
       * instDFunType moves from TcSMonad to Inst
       * Interestingly, CmmNode and CmmExpr both now need a non-silent
         (Ord r) in a couple of instance declarations. These were previously
         silent but must now be explicit.
       * Quite a bit of wibbling in error messages
  8. 20 Dec, 2014 1 commit
  9. 16 Dec, 2014 2 commits
    • Peter Wortmann's avatar
      Annotation linting · 07d604fa
      Peter Wortmann authored
      This adds a way by which we can make sure that the Core passes treat
      annotations right: We run them twice and compare the results.
      The main problem here is that Core equivalence is awkward: We do not
      want the comparison to care about the order of, say, top-level or
      recursive bindings. This is important even if GHC generally generates
      the bindings in the right order - after all, if something goes wrong
      we don't want linting to dump out the whole program as the offense.
      So instead we do some heuristic matching - first greedily match
      everything that's easy, then match the rest by label order. This
      should work as long as GHC generates the labels in roughly the same
      order for both pass runs.  In practice it seems to work alright.
      We also check that IdInfos match, as this might cause hard-to-spot
      bugs down the line (I had at least one bug because unfolding guidance
      didn't match!). We especially check unfoldings up until the point
      where it might get us into an infinite loop.
      (From Phabricator D169)
    • Peter Wortmann's avatar
      Source notes (Core support) · 993975d3
      Peter Wortmann authored
      This patch introduces "SourceNote" tickishs that link Core to the
      source code that generated it. The idea is to retain these source code
      links throughout code transformations so we can eventually relate
      object code all the way back to the original source (which we can,
      say, encode as DWARF information to allow debugging).  We generate
      these SourceNotes like other tickshs in the desugaring phase. The
      activating command line flag is "-g", consistent with the flag other
      compilers use to decide DWARF generation.
      Keeping ticks from getting into the way of Core transformations is
      tricky, but doable. The changes in this patch produce identical Core
      in all cases I tested -- which at this point is GHC, all libraries and
      nofib. Also note that this pass creates *lots* of tick nodes, which we
      reduce somewhat by removing duplicated and overlapping source
      ticks. This will still cause significant Tick "clumps" - a possible
      future optimization could be to make Tick carry a list of Tickishs
      instead of one at a time.
      (From Phabricator D169)
  10. 15 Dec, 2014 1 commit
    • Simon Peyton Jones's avatar
      Pattern-synonym matcher and builder Ids must be *LocalIds* · fbb42b2e
      Simon Peyton Jones authored
      This easy-to-make mistake meant that pattern-synonym matcher and
      builder Ids weren't being treated as locally defined by the simpplier.
      That meant that we never looked up them up in the environment, got an
      out-of-date unfolding, which made the Simplifier fall into an infinite
      loop.  This was the cause of Trac #98587, but it was quite tricky to
      In a separate patch I'll make Lint check for locally-bound GlobalIds,
      since they are always an error.
  11. 12 Dec, 2014 1 commit
    • eir@cis.upenn.edu's avatar
      Rewrite `Coercible` solver · 0cc47eb9
      eir@cis.upenn.edu authored
      This is a rewrite of the algorithm to solve for Coercible "instances".
      A preliminary form of these ideas is at
      The basic idea here is that the `EqPred` constructor of `PredTree`
      now is parameterised by a new type `EqRel` (where
      `data EqRel = NomEq | ReprEq`). Thus, every equality constraint can
      now talk about nominal equality (the usual case) or representational
      equality (the `Coercible` case).
      This is a change from the previous
      behavior where `Coercible` was just considered a regular class with
      a special case in `matchClassInst`.
      Because of this change, representational equalities are now
      canonicalized just like nominal ones, allowing more equalities
      to be solved -- in particular, the case at the top of #9117.
      A knock-on effect is that the flattener must be aware of the
      choice of equality relation, because the inert set now stores
      both representational inert equalities alongside the nominal
      inert equalities. Of course, we can use representational equalities
      to rewrite only within another representational equality --
      thus the parameterization of the flattener.
      A nice side effect of this change is that I've introduced a new
      type `CtFlavour`, which tracks G vs. W vs. D, removing some ugliness
      in the flattener.
      This commit includes some refactoring as discussed on D546.
      It also removes the ability of Deriveds to rewrite Deriveds.
      This fixes bugs #9117 and #8984.
      Reviewers: simonpj, austin, nomeata
      Subscribers: carter, thomie
      Differential Revision: https://phabricator.haskell.org/D546
      GHC Trac Issues: #9117, #8984
  12. 03 Dec, 2014 1 commit
  13. 02 Dec, 2014 1 commit
  14. 30 Nov, 2014 1 commit
    • Edward Z. Yang's avatar
      Filter instance visibility based on set of visible orphans, fixes #2182. · 4c834fdd
      Edward Z. Yang authored
      Amazingly, the fix for this very old bug is quite simple: when type-checking,
      maintain a set of "visible orphan modules" based on the orphans list of
      modules which we explicitly imported.  When we import an instance and it
      is an orphan, we check if it is in the visible modules set, and if not,
      ignore it.  A little bit of refactoring for when orphan-hood is calculated
      happens so that we always know if an instance is an orphan or not.
      For GHCi, we preinitialize the visible modules set based on the list of
      interactive imports which are active.
      Future work: Cache the visible orphan modules set for GHCi, rather than
      recomputing it every type-checking round.  (But it's tricky what to do when you
      /remove/ a module: you need a data structure a little more complicated than
      just a set of modules.)
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      Test Plan: new tests and validate
      Reviewers: simonpj, austin
      Subscribers: thomie, carter
      Differential Revision: https://phabricator.haskell.org/D488
      GHC Trac Issues: #2182
  15. 28 Nov, 2014 1 commit
    • Simon Peyton Jones's avatar
      Rename some of the functions in NameSet, to make the uniform with VarSet etc · 7460dafa
      Simon Peyton Jones authored
      For ages NameSet has used different names,
        eg.   addOneToNameSet   rather than    extendNameSet
              nameSetToList     rather than    nameSetElems
      etc.  Other set-like modules use uniform naming conventions.
      This patch makes NameSet follow suit.
      No change in behaviour; this is just renaming.
      I'm doing this just before the fork so that merging is easier.
  16. 21 Nov, 2014 6 commits
    • Alan Zimmerman's avatar
      Add API Annotations · 803fc5db
      Alan Zimmerman authored
      The final design and discussion is captured at
      This is a proof of concept implementation of a completely
      separate annotation structure, populated in the parser,and tied to the
      AST by means of a virtual "node-key" comprising the surrounding
      SrcSpan and a value derived from the specific constructor used for the
      The key parts of the design are the following.
      == The Annotations ==
      In `hsSyn/ApiAnnotation.hs`
      type ApiAnns = (Map.Map ApiAnnKey SrcSpan, Map.Map SrcSpan [Located Token])
      type ApiAnnKey = (SrcSpan,AnnKeywordId)
      -- ---------------------------------------------------------------------
      -- | Retrieve an annotation based on the @SrcSpan@ of the annotated AST
      -- element, and the known type of the annotation.
      getAnnotation :: ApiAnns -> SrcSpan -> AnnKeywordId -> Maybe SrcSpan
      getAnnotation (anns,_) span ann = Map.lookup (span,ann) anns
      -- |Retrieve the comments allocated to the current @SrcSpan@
      getAnnotationComments :: ApiAnns -> SrcSpan -> [Located Token]
      getAnnotationComments (_,anns) span =
        case Map.lookup span anns of
          Just cs -> cs
          Nothing -> []
      -- | Note: in general the names of these are taken from the
      -- corresponding token, unless otherwise noted
      data AnnKeywordId
               = AnnAs
               | AnnBang
               | AnnClass
               | AnnClose -- ^ } or ] or ) or #) etc
               | AnnComma
               | AnnDarrow
               | AnnData
               | AnnDcolon
      == Capturing in the lexer/parser ==
      The annotations are captured in the lexer / parser by extending PState to include a field
      In `parser/Lexer.x`
      data PState = PState {
              annotations :: [(ApiAnnKey,SrcSpan)]
              -- Annotations giving the locations of 'noise' tokens in the
              -- source, so that users of the GHC API can do source to
              -- source conversions.
      The lexer exposes a helper function to add an annotation
      addAnnotation :: SrcSpan -> Ann -> SrcSpan -> P ()
      addAnnotation l a v = P $ \s -> POk s {
        annotations = ((AK l a), v) : annotations s
        } ()
      The parser also has some helper functions of the form
      type MaybeAnn = Maybe (SrcSpan -> P ())
      gl = getLoc
      gj x = Just (gl x)
      ams :: Located a -> [MaybeAnn] -> P (Located a)
      ams a@(L l _) bs = (mapM_ (\a -> a l) $ catMaybes bs) >> return a
      This allows annotations to be captured in the parser by means of
      ctypedoc :: { LHsType RdrName }
              : 'forall' tv_bndrs '.' ctypedoc {% hintExplicitForall (getLoc $1) >>
                                                  ams (LL $ mkExplicitHsForAllTy $2 (noLoc []) $4)
                                                      [mj AnnForall $1,mj AnnDot $3] }
              | context '=>' ctypedoc         {% ams (LL $ mkQualifiedHsForAllTy   $1 $3)
                                                     [mj AnnDarrow $2] }
              | ipvar '::' type               {% ams (LL (HsIParamTy (unLoc $1) $3))
                                                     [mj AnnDcolon $2] }
              | typedoc                       { $1 }
      == Parse result ==
      data HsParsedModule = HsParsedModule {
          hpm_module    :: Located (HsModule RdrName),
          hpm_src_files :: [FilePath],
             -- ^ extra source files (e.g. from #includes).  The lexer collects
             -- these from '# <file> <line>' pragmas, which the C preprocessor
             -- leaves behind.  These files and their timestamps are stored in
             -- the .hi file, so that we can force recompilation if any of
             -- them change (#3589)
          hpm_annotations :: ApiAnns
      -- | The result of successful parsing.
      data ParsedModule =
        ParsedModule { pm_mod_summary   :: ModSummary
                     , pm_parsed_source :: ParsedSource
                     , pm_extra_src_files :: [FilePath]
                     , pm_annotations :: ApiAnns }
      This diff depends on D426
      Test Plan: sh ./validate
      Reviewers: austin, simonpj, Mikolaj
      Reviewed By: simonpj, Mikolaj
      Subscribers: Mikolaj, goldfire, thomie, carter
      Differential Revision: https://phabricator.haskell.org/D438
      GHC Trac Issues: #9628
    • Alan Zimmerman's avatar
      AST changes to prepare for API annotations, for #9628 · 7927658e
      Alan Zimmerman authored
      AST changes to prepare for API annotations
      Add locations to parts of the AST so that API annotations can
      then be added.
      The outline of the whole process is captured here
      This change updates the haddock submodule.
      Test Plan: sh ./validate
      Reviewers: austin, simonpj, Mikolaj
      Reviewed By: simonpj, Mikolaj
      Subscribers: thomie, goldfire, carter
      Differential Revision: https://phabricator.haskell.org/D426
      GHC Trac Issues: #9628
    • eir@cis.upenn.edu's avatar
      Fix #7484, checking for good binder names in Convert. · da2fca9e
      eir@cis.upenn.edu authored
      This commit also refactors a bunch of lexeme-oriented code into
      a new module Lexeme, and includes a submodule update for haddock.
    • Simon Peyton Jones's avatar
      Rejig builders for pattern synonyms, especially unlifted ones · e8762081
      Simon Peyton Jones authored
      When a pattern synonym is for an unlifted pattern, its "builder" would
      naturally be a top-level unlifted binding, which isn't allowed.  So we
      give it an extra Void# argument.
      Our Plan A involved then making *two* Ids for these builders, with
      some consequential fuss in the desugarer.  This was more pain than I
      liked, so I've re-jigged it.
       * There is just one builder for a pattern synonym.
       * It may have an extra Void# arg, but this decision is signalled
         by the Bool in the psBuilder field.
         I did the same for the psMatcher field.
         Both Bools are serialised into interface files, so there is
         absolutely no doubt whether that extra Void# argument is required.
       * I renamed "wrapper" to "builder".  We have too may "wrappers"
       * In order to deal with typecchecking occurrences of P in expressions,
         I refactored the tcInferId code in TcExpr.
      All of this allowed me to revert 5fe872
         "Apply compulsory unfoldings during desugaring, except for `seq` which is special."
      which turned out to be a rather messy hack in DsBinds
    • Simon Peyton Jones's avatar
      Comments only · eac9bbec
      Simon Peyton Jones authored
    • jpm@cs.ox.ac.uk's avatar
      Implement #5462 (deriving clause for arbitrary classes) · 7ed482d9
      jpm@cs.ox.ac.uk authored
      Summary: (this has been submitted on behalf on @dreixel)
      Reviewers: simonpj, hvr, austin
      Reviewed By: simonpj, austin
      Subscribers: goldfire, thomie, carter, dreixel
      Differential Revision: https://phabricator.haskell.org/D476
      GHC Trac Issues: #5462
  17. 18 Nov, 2014 1 commit
  18. 13 Nov, 2014 1 commit
  19. 12 Nov, 2014 3 commits
    • eir@cis.upenn.edu's avatar
      Fix #9788 by giving `coerce` the right type. · 294ac47e
      eir@cis.upenn.edu authored
      No test case added, as the original mistake is just one level
      up from a typo.
    • eir@cis.upenn.edu's avatar
      Fix #9066. · d782694f
      eir@cis.upenn.edu authored
      When splicing in a fixity declaration, look for both term-level things
      and type-level things. This requires some changes elsewhere in the
      code to allow for more flexibility when looking up Exact names, which
      can be assigned the wrong namespace during fixity declaration
      See the ticket for more info.
    • Herbert Valerio Riedel's avatar
      Implement new integer-gmp2 from scratch (re #9281) · c774b28f
      Herbert Valerio Riedel authored
      This is done as a separate `integer-gmp2` backend library because it
      turned out to become a complete rewrite from scratch.
      Due to the different (over)allocation scheme and potentially different
      accounting (via the new `{shrink,resize}MutableByteArray#` primitives),
      some of the nofib benchmarks actually results in increased allocation
      numbers (but not necessarily an increase in runtime!).  I believe the
      allocation numbers could improve if `{resize,shrink}MutableByteArray#`
      could be optimised to reallocate in-place more efficiently.
      Here are the more apparent changes in the latest nofib comparision
      between `integer-gmp` and `integer-gmp2`:
                Program     Size    Allocs   Runtime   Elapsed  TotalMem
             bernouilli    +1.6%    +15.3%     0.132     0.132      0.0%
           cryptarithm1    -2.2%      0.0%     -9.7%     -9.7%      0.0%
                  fasta    -0.7%     -0.0%    +10.9%    +10.9%      0.0%
                  kahan    +0.6%    +38.9%     0.169     0.169      0.0%
                   lcss    -0.7%     -0.0%     -6.4%     -6.4%      0.0%
                 mandel    +1.6%    +33.6%     0.049     0.049      0.0%
               pidigits    +0.8%     +8.5%     +3.9%     +3.9%      0.0%
                  power    +1.4%    -23.8%    -18.6%    -18.6%    -16.7%
              primetest    +1.3%    +50.1%     0.085     0.085      0.0%
                    rsa    +1.6%    +53.4%     0.026     0.026      0.0%
                    scs    +1.2%     +6.6%     +6.5%     +6.6%    +14.3%
                 symalg    +1.0%     +9.5%     0.010     0.010      0.0%
              transform    -0.6%     -0.0%     -5.9%     -5.9%      0.0%
                    Min    -2.3%    -23.8%    -18.6%    -18.6%    -16.7%
                    Max    +1.6%    +53.4%    +10.9%    +10.9%    +14.3%
         Geometric Mean    -0.3%     +1.9%     -0.8%     -0.8%     +0.0%
      (see P35 / https://phabricator.haskell.org/P35 for full report)
      By default, `INTEGER_LIBRARY=integer-gmp2` is active now, which results
      in the package `integer-gmp-` being registered in the package db.
      The previous `integer-gmp-` can be restored by setting
      `INTEGER_LIBRARY=integer-gmp` (but will probably be removed altogether
      for GHC 7.12). In-tree GMP support has been stolen from the old
      `integer-gmp` (while unpatching the custom memory-allocators, as well as
      forcing `-fPIC`)
      A minor hack to `ghc-cabal` was necessary in order to support two different
      `integer-gmp` packages (in different folders) with the same package key.
      There will be a couple of follow-up commits re-implementing some features
      that were dropped to keep D82 minimal, as well as further
      More information can be found via #9281 and
      Reviewed By: austin, rwbarton, simonmar
      Differential Revision: https://phabricator.haskell.org/D82
  20. 08 Nov, 2014 2 commits
    • Gergő Érdi's avatar
    • Gergő Érdi's avatar
      In pattern synonym matchers, support unboxed continuation results (fixes #9783). · 474e535b
      Gergő Érdi authored
      This requires ensuring the continuations have arguments by adding a dummy
      Void# argument when needed. This is so that matching on a pattern synonym
      is lazy even when the result is unboxed, e.g.
          pattern P = ()
          f P = 0#
      In this case, without dummy arguments, the generated matcher's type would be
         $mP :: forall (r :: ?). () -> r -> r -> r
      which is called in `f` at type `() -> Int# -> Int# -> Int#`,
      so it would be strict, in particular, in the failure continuation
      of `patError`.
      We work around this by making sure both continuations have arguments:
        $mP :: forall (r :: ?). () -> (Void# -> r) -> (Void# -> r) -> r
      Of course, if `P` (and thus, the success continuation) has any arguments,
      we are only adding the extra dummy argument to the failure continuation.
  21. 07 Nov, 2014 1 commit
    • David Feuer's avatar
      Improve Applicative definitions · abba3812
      David Feuer authored
      Generally clean up things relating to Applicative and Monad in `GHC.Base`
      and `Control.Applicative` to make `Applicative` feel like a bit more of a
      first-class citizen rather than just playing second fiddle to `Monad`. Use
      `coerce` and GND to improve performance and clarity.
      Change the default definition of `(*>)` to use `(<$)`, in case the
      `Functor` instance optimizes that.
      Moreover, some manually written instances are made into compiler-derived
      Finally, this also adds a few AMP-related laws to the `Applicative` docstring.
      NOTE: These changes result in a 13% decrease in allocation for T9020
      Reviewed By: ekmett, hvr
      Differential Revision: https://phabricator.haskell.org/D432
  22. 06 Nov, 2014 2 commits
  23. 04 Nov, 2014 3 commits
  24. 02 Nov, 2014 1 commit
  25. 24 Oct, 2014 1 commit
    • Edward Z. Yang's avatar
      Implementation of hsig (module signatures), per #9252 · aa479953
      Edward Z. Yang authored
      Module signatures, like hs-boot files, are Haskell modules which omit
      value definitions and contain only signatures.  This patchset implements
      one particular aspect of module signature, namely compiling them against
      a concrete implementation.  It works like this: when we compile an hsig
      file, we must be told (via the -sig-of flag) what module this signature
      is implementing.  The signature is compiled into an interface file which
      reexports precisely the entities mentioned in the signature file.  We also
      verify that the interface is compatible with the implementation.
      This feature is useful in a few situations:
          1. Like explicit import lists, signatures can be used to reduce
          sensitivity to upstream changes.  However, a signature can be defined
          once and then reused by many modules.
          2. Signatures can be used to quickly check if a new upstream version
          is compatible, by typechecking just the signatures and not the actual
          3. A signature can be used to mediate separate modular development,
          where the signature is used as a placeholder for functionality which
          is loaded in later.  (This is only half useful at the moment, since
          typechecking against signatures without implementations is not implemented
          in this patchset.)
      Unlike hs-boot files, hsig files impose no performance overhead.
      This patchset punts on the type class instances (and type families) problem:
      instances simply leak from the implementation to the signature.  You can
      explicitly specify what instances you expect to have, and those will be checked,
      but you may get more instances than you asked for.  Our eventual plan is
      to allow hiding instances, but to consider all transitively reachable instances
      when considering overlap and soundness.
      ToDo: signature merging: when a module is provided by multiple signatures
      for the same base implementation, we should not consider this ambiguous.
      ToDo: at the moment, signatures do not constitute use-sites, so if you
      write a signature for a deprecated function, you won't get a warning
      when you compile the signature.
      Future work: The ability to feed in shaping information so that we can take
      advantage of more type equalities than might be immediately evident.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      Test Plan: validate and new tests
      Reviewers: simonpj, simonmar, hvr, austin
      Subscribers: simonmar, relrod, ezyang, carter, goldfire
      Differential Revision: https://phabricator.haskell.org/D130
      GHC Trac Issues: #9252