1. 27 Jan, 2020 1 commit
  2. 04 Jan, 2020 1 commit
  3. 02 Dec, 2019 1 commit
  4. 27 Nov, 2019 1 commit
    • Vladislav Zavialov's avatar
      Whitespace-sensitive bang patterns (#1087, #17162) · 8168b42a
      Vladislav Zavialov authored
      This patch implements a part of GHC Proposal #229 that covers five
      operators:
      
      * the bang operator (!)
      * the tilde operator (~)
      * the at operator (@)
      * the dollar operator ($)
      * the double dollar operator ($$)
      
      Based on surrounding whitespace, these operators are disambiguated into
      bang patterns, lazy patterns, strictness annotations, type
      applications, splices, and typed splices.
      
      This patch doesn't cover the (-) operator or the -Woperator-whitespace
      warning, which are left as future work.
      8168b42a
  5. 15 Jul, 2019 2 commits
  6. 08 May, 2019 1 commit
  7. 03 May, 2019 1 commit
    • Vladislav Zavialov's avatar
      Pattern/expression ambiguity resolution · 52fc2719
      Vladislav Zavialov authored
      This patch removes 'EWildPat', 'EAsPat', 'EViewPat', and 'ELazyPat'
      from 'HsExpr' by using the ambiguity resolution system introduced
      earlier for the command/expression ambiguity.
      
      Problem: there are places in the grammar where we do not know whether we
      are parsing an expression or a pattern, for example:
      
      	do { Con a b <- x } -- 'Con a b' is a pattern
      	do { Con a b }      -- 'Con a b' is an expression
      
      Until we encounter binding syntax (<-) we don't know whether to parse
      'Con a b' as an expression or a pattern.
      
      The old solution was to parse as HsExpr always, and rejig later:
      
      	checkPattern :: LHsExpr GhcPs -> P (LPat GhcPs)
      
      This meant polluting 'HsExpr' with pattern-related constructors. In
      other words, limitations of the parser were affecting the AST, and all
      other code (the renamer, the typechecker) had to deal with these extra
      constructors.
      
      We fix this abstraction leak by parsing into an overloaded
      representation:
      
      	class DisambECP b where ...
      	newtype ECP = ECP { runECP_PV :: forall b. DisambECP b => PV (Located b) }
      
      See Note [Ambiguous syntactic categories] for details.
      
      Now the intricacies of parsing have no effect on the hsSyn AST when it
      comes to the expression/pattern ambiguity.
      52fc2719
  8. 25 Apr, 2019 2 commits
    • Vladislav Zavialov's avatar
      checkPattern error hint is PV context · f85efdec
      Vladislav Zavialov authored
      There is a hint added to error messages reported in checkPattern.
      Instead of passing it manually, we put it in a ReaderT environment inside PV.
      f85efdec
    • Vladislav Zavialov's avatar
      Introduce MonadP, make PV a newtype · 0fc69416
      Vladislav Zavialov authored
      Previously we defined   type PV = P,
      this had the downside that if we wanted to change PV,
      we would have to modify P as well.
      
      Now PV is free to evolve independently from P.
      
      The common operations addError, addFatalError, getBit, addAnnsAt,
      were abstracted into a class called MonadP.
      0fc69416
  9. 25 Mar, 2019 1 commit
    • Takenobu Tani's avatar
      Update Wiki URLs to point to GitLab · 3769e3a8
      Takenobu Tani authored
      This moves all URL references to Trac Wiki to their corresponding
      GitLab counterparts.
      
      This substitution is classified as follows:
      
      1. Automated substitution using sed with Ben's mapping rule [1]
          Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...
          New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...
      
      2. Manual substitution for URLs containing `#` index
          Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...#Zzz
          New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...#zzz
      
      3. Manual substitution for strings starting with `Commentary`
          Old: Commentary/XxxYyy...
          New: commentary/xxx-yyy...
      
      See also !539
      
      [1]: https://gitlab.haskell.org/bgamari/gitlab-migration/blob/master/wiki-mapping.json
      3769e3a8
  10. 15 Mar, 2019 1 commit
  11. 01 Mar, 2019 1 commit
    • Alec Theriault's avatar
      Lexer: turn some fatal errors into non-fatal ones · f37efb11
      Alec Theriault authored
      The following previously fatal lexer errors are now non-fatal:
      
        * errors about enabling `LambdaCase`
        * errors about enabling `NumericUnderscores`
        * errors about having valid characters in primitive strings
      
      See #16270
      f37efb11
  12. 18 Feb, 2019 1 commit
  13. 15 Feb, 2019 1 commit
  14. 13 Feb, 2019 1 commit
  15. 10 Feb, 2019 1 commit
  16. 08 Feb, 2019 1 commit
    • Alan Zimmerman's avatar
      Lexer: Alternate Layout Rule injects actual not virtual braces · c1cf2693
      Alan Zimmerman authored
      When the alternate layout rule is activated via a pragma, it injects
      tokens for { and } to make sure that the source is parsed properly.
      
      But it injects ITocurly and ITccurly, rather than their virtual
      counterparts ITvocurly and ITvccurly.
      
      This causes problems for ghc-exactprint, which tries to print these.
      
      Likewise, any injected ITsemi should have a zero-width SrcSpan.
      
      Test case (the existing T13087.hs)
      
          {-# LANGUAGE AlternativeLayoutRule #-}
          {-# LANGUAGE LambdaCase            #-}
      
          isOne :: Int -> Bool
          isOne = \case 1 -> True
                        _ -> False
      
          main = return ()
      
      Closes #16279
      c1cf2693
  17. 04 Feb, 2019 1 commit
  18. 18 Jan, 2019 1 commit
  19. 17 Jan, 2019 1 commit
    • Alec Theriault's avatar
      'DynFlag'-free version of 'mkParserFlags' · 469fe613
      Alec Theriault authored
      Summary:
      This is a fixed version of the reverted d2fbc33c
      and  5aa29231.
      
      Obtaining a `DynFlags` is difficult, making using the lexer/parser
      for pure parsing/lexing unreasonably difficult, even with `mkPStatePure`.
      This is despite the fact that we only really need
      
          * language extension flags
          * warning flags
          * a handful of boolean options
      
      The new `mkParserFlags'` function makes is easier to directly construct a
      `ParserFlags`. Furthermore, since `pExtsBitmap` is just a footgun, I've gone
      ahead and made `ParserFlags` an abstract type.
      
      Also, we now export `ExtBits` and `getBit` instead of defining/exporting a
      bunch of boilerplate functions that test for a particular 'ExtBits'.
      In the process, I also
      
        * cleaned up an unneeded special case for `ITstatic`
        * made `UsePosPrags` another variant of `ExtBits`
        * made the logic in `reservedSymsFM` match that of `reservedWordsFM`
      
      Test Plan: make test
      
      Reviewers: bgamari, alanz, tdammers
      
      Subscribers: sjakobi, tdammers, rwbarton, mpickering, carter
      
      GHC Trac Issues: #11301
      
      Differential Revision: https://phabricator.haskell.org/D5405
      469fe613
  20. 24 Nov, 2018 1 commit
  21. 23 Nov, 2018 2 commits
  22. 22 Nov, 2018 3 commits
    • Alec Theriault's avatar
      Simplify 'ExtBits' in the lexer · d2fbc33c
      Alec Theriault authored
      The main change is to export 'ExtBits' instead of defining/exporting a
      bunch of boilerplate functions that test for a particular 'ExtBits'.
      In the process, I also
      
        * cleaned up an unneeded special case for 'ITstatic'
        * made 'UsePosPrags' another variant of 'ExtBits'
        * made the logic in 'reservedSymsFM' match that of 'reservedWordsFM'
      
      Test Plan: make test
      
      Reviewers: bgamari, alanz
      
      Subscribers: sjakobi, rwbarton, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D5332
      d2fbc33c
    • Alec Theriault's avatar
      'DynFlag'-free version of 'mkParserFlags' · 5aa29231
      Alec Theriault authored
      Obtaining a `DynFlags` is difficult, making using the lexer/parser
      for pure parsing/lexing unreasonably difficult, even with
      `mkPStatePure`.
      This is despite the fact that we only really need
      
        * language extension flags
        * warning flags
        * a handful of boolean options
      
      The new `mkParserFlags'` function makes is easier to directly construct
      a `ParserFlags`. Furthermore, since `pExtsBitmap` is just a footgun,
      I've gone ahead and made `ParserFlags` an abstract type.
      
      Reviewers: bgamari, alanz, sjakobi
      
      Reviewed By: bgamari, sjakobi
      
      Subscribers: mpickering, sjakobi, rwbarton, carter
      
      GHC Trac Issues: #11301
      
      Differential Revision: https://phabricator.haskell.org/D5269
      5aa29231
    • Simon Jakobi's avatar
      Remove warnings-silencing flags for code generated by Alex · 699e5072
      Simon Jakobi authored
      Current versions of Alex don't seem to produce as many warnings any
      more.
      
      In order to silence a warning and to avoid overlong lines, I've taken
      the liberty of refactoring 'tok_num'.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: erikd, rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5319
      699e5072
  23. 24 Oct, 2018 1 commit
  24. 04 Oct, 2018 1 commit
    • Vladislav Zavialov's avatar
      Parse the (!) type operator and allow type operators in existential context · bd789853
      Vladislav Zavialov authored
      Summary:
      Improve the way `(!)`, `(~)`, and other type operators are handled in the parser,
      fixing two issues at once:
      
      1. `(!)` can now be used as a type operator
         that respects fixity and precedence (#15457)
      2. Existential context of a data constructor
         no longer needs parentheses (#15675)
      
      In addition to that, with this patch it is now trivial to adjust precedence of
      the `{-# UNPACK #-}` pragma, as suggested in
      https://ghc.haskell.org/trac/ghc/ticket/14761#comment:7
      
      There was a small change to API Annotations. Before this patch, `(~)` was a
      strange special case that produced an annotation unlike any other type
      operator. After this patch, when `(~)` or `(!)` are used to specify strictness they
      produce AnnTilde and AnnBang annotations respectively, and when they are used
      as type operators, they produce no annotations.
      
      Test Plan: Validate
      
      Reviewers: simonpj, bgamari, alanz, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: RyanGlScott, rwbarton, mpickering, carter
      
      GHC Trac Issues: #15457, #15675
      
      Differential Revision: https://phabricator.haskell.org/D5180
      bd789853
  25. 21 Aug, 2018 1 commit
    • Ben Sklaroff's avatar
      Fix #line pragmas in nested comments · 02518f9d
      Ben Sklaroff authored
      When parsing a nested comment or nested doc comment in the lexer, if we
      see a line starting with '#' we attempt to parse a #line pragma. This
      fixes how ghc handles output of the C preproccesor (-cpp flag) when the
      original source has C comments or pragmas inside haskell comments.
      
      Updates haddock submodule.
      
      Test Plan: ./validate
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #314
      
      Differential Revision: https://phabricator.haskell.org/D4934
      02518f9d
  26. 16 Jul, 2018 1 commit
    • Vladislav Zavialov's avatar
      Do not imply NoStarIsType by TypeOperators/TypeInType · 65c186f0
      Vladislav Zavialov authored
      Implementation of the "Embrace TypeInType" proposal was done according
      to the spec, which specified that TypeOperators must imply NoStarIsType.
      This implication was meant to prevent breakage and to be removed in 2
      releases.  However, compiling head.hackage has shown that this
      implication only magnified the breakage, so there is no reason to have
      it in the first place.
      
      To remain in compliance with the three-release policy, we add a
      workaround to define the (*) type operator even when -XStarIsType is on.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, RyanGlScott, goldfire, phadej, hvr
      
      Reviewed By: bgamari, RyanGlScott
      
      Subscribers: harpocrates, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4865
      65c186f0
  27. 14 Jun, 2018 1 commit
    • Vladislav Zavialov's avatar
      Embrace -XTypeInType, add -XStarIsType · d650729f
      Vladislav Zavialov authored
      Summary:
      Implement the "Embrace Type :: Type" GHC proposal,
      .../ghc-proposals/blob/master/proposals/0020-no-type-in-type.rst
      
      GHC 8.0 included a major change to GHC's type system: the Type :: Type
      axiom. Though casual users were protected from this by hiding its
      features behind the -XTypeInType extension, all programs written in GHC
      8+ have the axiom behind the scenes. In order to preserve backward
      compatibility, various legacy features were left unchanged. For example,
      with -XDataKinds but not -XTypeInType, GADTs could not be used in types.
      Now these restrictions are lifted and -XTypeInType becomes a redundant
      flag that will be eventually deprecated.
      
      * Incorporate the features currently in -XTypeInType into the
        -XPolyKinds and -XDataKinds extensions.
      * Introduce a new extension -XStarIsType to control how to parse * in
        code and whether to print it in error messages.
      
      Test Plan: Validate
      
      Reviewers: goldfire, hvr, bgamari, alanz, simonpj
      
      Reviewed By: goldfire, simonpj
      
      Subscribers: rwbarton, thomie, mpickering, carter
      
      GHC Trac Issues: #15195
      
      Differential Revision: https://phabricator.haskell.org/D4748
      d650729f
  28. 05 Jun, 2018 1 commit
    • Ryan Scott's avatar
      Introduce DerivingVia · 8ed8b037
      Ryan Scott authored
      This implements the `DerivingVia` proposal put forth in
      https://github.com/ghc-proposals/ghc-proposals/pull/120.
      
      This introduces the `DerivingVia` deriving strategy. This is a
      generalization of `GeneralizedNewtypeDeriving` that permits the user
      to specify the type to `coerce` from.
      
      The major change in this patch is the introduction of the
      `ViaStrategy` constructor to `DerivStrategy`, which takes a type
      as a field. As a result, `DerivStrategy` is no longer a simple
      enumeration type, but rather something that must be renamed and
      typechecked. The process by which this is done is explained more
      thoroughly in section 3 of this paper
      ( https://www.kosmikus.org/DerivingVia/deriving-via-paper.pdf ),
      although I have inlined the relevant parts into Notes where possible.
      
      There are some knock-on changes as well. I took the opportunity to
      do some refactoring of code in `TcDeriv`, especially the
      `mkNewTypeEqn` function, since it was bundling all of the logic for
      (1) deriving instances for newtypes and
      (2) `GeneralizedNewtypeDeriving`
      into one huge broth. `DerivingVia` reuses much of part (2), so that
      was factored out as much as possible.
      
      Bumps the Haddock submodule.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, bgamari, goldfire, alanz
      
      Subscribers: alanz, goldfire, rwbarton, thomie, mpickering, carter
      
      GHC Trac Issues: #15178
      
      Differential Revision: https://phabricator.haskell.org/D4684
      8ed8b037
  29. 03 Jun, 2018 1 commit
    • David Feuer's avatar
      Remove ~# from surface syntax · 5b82ee69
      David Feuer authored
      For some reason, it seems that the `ConstraintKinds` commit
      introduced `~#` into Haskell syntax, in a pretty broken manner.
      Unless and until we have an actual story for unboxed equality,
      it doesn't make sense to expose it. Moreover, the way it was
      donet was wrong enough and small enough that it will probably be
      easier to start over if we do that. Yank it out.
      
      Reviewers: bgamari, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: RyanGlScott, rwbarton, thomie, mpickering, carter
      
      GHC Trac Issues: #15209
      
      Differential Revision: https://phabricator.haskell.org/D4763
      5b82ee69
  30. 02 Jun, 2018 1 commit
    • Ben Gamari's avatar
      vectorise: Put it out of its misery · faee23bb
      Ben Gamari authored
      Poor DPH and its vectoriser have long been languishing; sadly it seems there is
      little chance that the effort will be rekindled. Every few years we discuss
      what to do with this mass of code and at least once we have agreed that it
      should be archived on a branch and removed from `master`. Here we do just that,
      eliminating heaps of dead code in the process.
      
      Here we drop the ParallelArrays extension, the vectoriser, and the `vector` and
      `primitive` submodules.
      
      Test Plan: Validate
      
      Reviewers: simonpj, simonmar, hvr, goldfire, alanz
      
      Reviewed By: simonmar
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D4761
      faee23bb
  31. 01 Feb, 2018 1 commit
    • takano-akio's avatar
      Implement BlockArguments (#10843) · be84823b
      takano-akio authored
      This patch implements the BlockArguments extension, as proposed at
      https://github.com/ghc-proposals/ghc-proposals/pull/90. It also
      fixes #10855 as a side-effect.
      
      This patch adds a large number of shift-reduce conflicts to the parser.
      All of them concern the ambiguity as to where constructs like `if` and
      `let` end. Fortunately they are resolved correctly by preferring shift.
      
      The patch is based on @gibiansky's ArgumentDo implementation (D1219).
      
      Test Plan: ./validate
      
      Reviewers: goldfire, bgamari, alanz, mpickering
      
      Reviewed By: bgamari, mpickering
      
      Subscribers: Wizek, dfeuer, gibiansky, rwbarton, thomie, mpickering, carter
      
      GHC Trac Issues: #10843, #10855
      
      Differential Revision: https://phabricator.haskell.org/D4260
      be84823b
  32. 26 Jan, 2018 1 commit
    • Alec Theriault's avatar
      Option for LINE pragmas to get lexed into tokens · 9a57cfeb
      Alec Theriault authored
      This adds a parser-level switch to have 'LINE' and 'COLUMN'
      pragmas lexed into actual tokens (as opposed to updating the
      position information in the parser).
      
      'lexTokenStream' is the only place where this option is enabled.
      
      Reviewers: bgamari, alexbiehl, mpickering
      
      Reviewed By: mpickering
      
      Subscribers: alanz, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4336
      9a57cfeb
  33. 21 Jan, 2018 1 commit
    • Takenobu Tani's avatar
      Implement underscores in numeric literals (NumericUnderscores extension) · 4a13c5b1
      Takenobu Tani authored
      Implement the proposal of underscores in numeric literals.
      Underscores in numeric literals are simply ignored.
      
      The specification of the feature is available here:
      https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/000
      9-numeric-underscores.rst
      
      For a discussion of the various choices:
      https://github.com/ghc-proposals/ghc-proposals/pull/76
      
      Implementation detail:
      
      * Added dynamic flag
        * `NumericUnderscores` extension flag is added for this feature.
      
      * Alex "Regular expression macros" in Lexer.x
        * Add `@numspc` (numeric spacer) macro to represent multiple
          underscores.
        * Modify `@decimal`, `@decimal`, `@binary`, `@octal`, `@hexadecimal`,
          `@exponent`, and `@bin_exponent` macros to include `@numspc`.
      
      * Alex "Rules" in Lexer.x
        * To be simpler, we have only the definitions with underscores.
          And then we have a separate function (`tok_integral` and `tok_frac`)
          that validates the literals.
      
      * Validation functions in Lexer.x
        * `tok_integral` and `tok_frac` functions validate
          whether contain underscores or not.
          If `NumericUnderscores` extensions are not enabled,
          check that there are no underscores.
        * `tok_frac` function is created by merging `strtoken` and
          `init_strtoken`.
        * `init_strtoken` is deleted. Because it is no longer used.
      
      * Remove underscores from target literal string
        * `parseUnsignedInteger`, `readRational__`, and `readHexRational} use
          the customized `span'` function to remove underscores.
      
      * Added Testcase
        * testcase for NumericUnderscores enabled.
            NumericUnderscores0.hs and NumericUnderscores1.hs
        * testcase for NumericUnderscores disabled.
            NoNumericUnderscores0.hs and NoNumericUnderscores1.hs
        * testcase to invalid pattern for NumericUnderscores enabled.
            NumericUnderscoresFail0.hs and NumericUnderscoresFail1.hs
      
      Test Plan: `validate` including the above testcase
      
      Reviewers: goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: carter, rwbarton, thomie
      
      GHC Trac Issues: #14473
      
      Differential Revision: https://phabricator.haskell.org/D4235
      4a13c5b1
  34. 19 Dec, 2017 1 commit
  35. 02 Nov, 2017 1 commit