1. 16 Nov, 2016 1 commit
  2. 07 Nov, 2016 1 commit
  3. 18 Oct, 2016 1 commit
    • Simon Peyton Jones's avatar
      Correct order of existentials in pattern synonyms · 5c02b842
      Simon Peyton Jones authored
      Trac #12698 exposed a nasty bug in the typechecking for
      pattern synonmys: the existential type variables weren't
      being put in properly-scoped order.
      
      For some reason TcPatSyn.tcCollectEx was colleting them as a
      set, not as a list!  Easily fixed.
      
      (cherry picked from commit a693d1cb)
      5c02b842
  4. 10 Oct, 2016 1 commit
  5. 02 Oct, 2016 2 commits
  6. 05 Sep, 2016 1 commit
  7. 25 Aug, 2016 2 commits
  8. 25 Jul, 2016 1 commit
  9. 04 Apr, 2016 1 commit
    • Rik Steenkamp's avatar
      Improve printing of pattern synonym types · f75e098a
      Rik Steenkamp authored
      Add the function `pprPatSynType :: PatSyn -> SDoc` for printing pattern
      synonym types, and remove the ambiguous `patSynType` function. Also,
      the types in a `PatSyn` are now tidy.
      
      Haddock submodule updated to reflect the removal of `patSynType` by
      mpickering.
      
      Fixes: #11213.
      
      Reviewers: goldfire, simonpj, austin, mpickering, bgamari
      
      Reviewed By: simonpj, mpickering
      
      Subscribers: bollmann, simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1896
      
      GHC Trac Issues: #11213
      
      (cherry picked from commit 72bd7f7b)
      f75e098a
  10. 27 Feb, 2016 1 commit
  11. 18 Jan, 2016 1 commit
  12. 15 Jan, 2016 1 commit
  13. 29 Dec, 2015 1 commit
    • Adam Gundry's avatar
      Fix panic when using pattern synonyms with DisambiguateRecordFields · 4f69203d
      Adam Gundry authored
      This fixes a `find_tycon` panic when constructing a record pattern
      synonym when `DisambiguateRecordFields` (turned on by `RecordWildCards`)
      is enabled.  The handling of record wild cards in such constructions
      isn't completely satisfactory, but doing better will require the
      `Parent` type to be more informative, as I'll explain on #11228.
      
      Test Plan: New test patsyn/should_compile/T11283.hs
      
      Reviewers: mpickering, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1695
      
      GHC Trac Issues: #11283
      4f69203d
  14. 23 Dec, 2015 2 commits
  15. 22 Dec, 2015 2 commits
    • Ben Gamari's avatar
      Remove another duplicate test · 01b0461e
      Ben Gamari authored
      01b0461e
    • Simon Peyton Jones's avatar
      Fix typechecking for pattern synonym signatures · f40e122b
      Simon Peyton Jones authored
      Various tickets have revealed bad shortcomings in the typechecking of
      pattern type synonyms.  Discussed a lot in (the latter part of)
      Trac #11224.
      
      This patch fixes the most complex issues:
      
      - Both parser and renamer now treat pattern synonyms as an
        ordinary LHsSigType.  Nothing special.  Hooray.
      
      - tcPatSynSig (now in TcPatSyn) typechecks the signature, and
        decomposes it into its pieces.
        See Note [Pattern synonym signatures]
      
      - tcCheckPatSyn has had a lot of refactoring.
        See Note [Checking against a pattern signature]
      
      The result is a lot tidier and more comprehensible.
      Plus, it actually works!
      
      NB: this patch doesn't actually address the precise
          target of #11224, namely "inlining pattern synonym
          does not preserve semantics".  That's an unrelated
          bug, with a separate patch.
      
      ToDo: better documentation in the user manual
      
      Test Plan: Validate
      
      Reviewers: austin, hvr, goldfire
      
      Subscribers: goldfire, mpickering, thomie, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D1685
      
      GHC Trac Issues: #11224
      f40e122b
  16. 20 Dec, 2015 2 commits
  17. 16 Dec, 2015 1 commit
  18. 12 Dec, 2015 1 commit
    • Matthew Pickering's avatar
      Implement -fwarn-missing-pat-syn-sigs · 1883afb2
      Matthew Pickering authored
      This adds a warning when a pattern synonym is not accompanied by a
      signature in the style of `-fwarn-missing-sigs`.
      
      It is turned on by -Wall.
      
      If the user specifies, `-fwarn-missing-exported-signatures` with
      `-fwarn-missing-pat-syn-sigs` then it will only warn when the pattern
      synonym is exported.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1596
      
      GHC Trac Issues: #11053
      1883afb2
  19. 11 Nov, 2015 3 commits
  20. 29 Oct, 2015 1 commit
    • Matthew Pickering's avatar
      Record pattern synonyms · 2a74a64e
      Matthew Pickering authored
      This patch implements an extension to pattern synonyms which allows user
      to specify pattern synonyms using record syntax. Doing so generates
      appropriate selectors and update functions.
      
      === Interaction with Duplicate Record Fields ===
      
      The implementation given here isn't quite as general as it could be with
      respect to the recently-introduced `DuplicateRecordFields` extension.
      
      Consider the following module:
      
          {-# LANGUAGE DuplicateRecordFields #-}
          {-# LANGUAGE PatternSynonyms #-}
      
          module Main where
      
          pattern S{a, b} = (a, b)
          pattern T{a}    = Just a
      
          main = do
            print S{ a = "fst", b = "snd" }
            print T{ a = "a" }
      
      In principle, this ought to work, because there is no ambiguity. But at
      the moment it leads to a "multiple declarations of a" error. The problem
      is that pattern synonym record selectors don't do the same name mangling
      as normal datatypes when DuplicateRecordFields is enabled. They could,
      but this would require some work to track the field label and selector
      name separately.
      
      In particular, we currently represent datatype selectors in the third
      component of AvailTC, but pattern synonym selectors are just represented
      as Avails (because they don't have a corresponding type constructor).
      Moreover, the GlobalRdrElt for a selector currently requires it to have
      a parent tycon.
      
      (example due to Adam Gundry)
      
      === Updating Explicitly Bidirectional Pattern Synonyms ===
      
      Consider the following
      
      ```
      pattern Silly{a} <- [a] where
        Silly a = [a, a]
      
      f1 = a [5] -- 5
      
      f2 = [5] {a = 6} -- currently [6,6]
      ```
      
      === Fixing Polymorphic Updates ===
      
      They were fixed by adding these two lines in `dsExpr`. This might break
      record updates but will be easy to fix.
      
      ```
      + ; let req_wrap = mkWpTyApps (mkTyVarTys univ_tvs)
      
      - , pat_wrap = idHsWrapper }
      +, pat_wrap = req_wrap }
      ```
      
      === Mixed selectors error ===
      
      Note [Mixed Record Field Updates]
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Consider the following pattern synonym.
      
          data MyRec = MyRec { foo :: Int, qux :: String }
      
          pattern HisRec{f1, f2} = MyRec{foo = f1, qux=f2}
      
      This allows updates such as the following
      
          updater :: MyRec -> MyRec
          updater a = a {f1 = 1 }
      
      It would also make sense to allow the following update (which we
      reject).
      
          updater a = a {f1 = 1, qux = "two" } ==? MyRec 1 "two"
      
      This leads to confusing behaviour when the selectors in fact refer the
      same field.
      
          updater a = a {f1 = 1, foo = 2} ==? ???
      
      For this reason, we reject a mixture of pattern synonym and normal
      record selectors in the same update block. Although of course we still
      allow the following.
      
          updater a = (a {f1 = 1}) {foo = 2}
      
          > updater (MyRec 0 "str")
          MyRec 2 "str"
      2a74a64e
  21. 27 Oct, 2015 1 commit
  22. 23 Oct, 2015 1 commit
  23. 08 Oct, 2015 1 commit
  24. 06 Aug, 2015 1 commit
  25. 20 Jan, 2015 1 commit
  26. 19 Jan, 2015 1 commit
  27. 09 Jan, 2015 1 commit
  28. 06 Jan, 2015 1 commit
    • 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
         constraints.
      
       * 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
         TcInstDcls
      
       * 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
      32973bf3
  29. 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
      find!
      
      In a separate patch I'll make Lint check for locally-bound GlobalIds,
      since they are always an error.
      fbb42b2e
  30. 27 Nov, 2014 1 commit
  31. 20 Nov, 2014 1 commit
    • Gergő Érdi's avatar
      Add support for pattern synonym type signatures. · cce6318e
      Gergő Érdi authored
      Syntax is of the form
      
          pattern P :: (Prov b) => (Req a) => a -> b -> Int -> T a
      
      which declares a pattern synonym called `P`, with argument types `a`, `b`,
      and `Int`, and result type `T a`, with provided context `(Prov b)` and required
      context `(Req a)`.
      
      The Haddock submodule is also updated to use this new syntax in generated docs.
      cce6318e
  32. 13 Nov, 2014 2 commits