summaryrefslogtreecommitdiff
path: root/compiler/parser
Commit message (Collapse)AuthorAgeFilesLines
...
* Add proper GADTs support to Template HaskellJan Stolarek2015-12-211-2/+2
| | | | | | | | | | | | | | | | Until now GADTs were supported in Template Haskell by encoding them using normal data types. This patch adds proper support for representing GADTs in TH. Test Plan: T10828 Reviewers: goldfire, austin, bgamari Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1465 GHC Trac Issues: #10828
* Fix AnnDotDot in module exportAlan Zimmerman2015-12-211-1/+1
| | | | | | | | The annotation for the ".." in module GADTRecords2 (H1(..)) where was in the wrong place
* Warn about unused type variables in type familiesMichał Sośnicki2015-12-212-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The warnings are enabled with the flag -fwarn-unused-matches, the same one that enables warnings on the term level. Identifiers starting with an underscore are now always parsed as type variables. When the NamedWildCards extension is enabled, the renamer replaces those variables with named wildcards. An additional NameSet nwcs is added to LocalRdrEnv. It's used to keep names of the type variables that should be replaced with wildcards. While renaming HsForAllTy, when a name is explicitly bound it is removed from the nwcs NameSet. As a result, the renamer doesn't replace them in the quantifier body. (Trac #11098) Fixes #10982, #11098 Reviewers: alanz, bgamari, hvr, austin, jstolarek Reviewed By: jstolarek Subscribers: goldfire, mpickering, RyanGlScott, thomie Differential Revision: https://phabricator.haskell.org/D1576 GHC Trac Issues: #10982
* Add Location to RdrName in FieldOccAlan Zimmerman2015-12-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Post #11019, there have been some new instances of RdrName that are not located, in particular ```#!hs data FieldOcc name = FieldOcc { rdrNameFieldOcc :: RdrName , selectorFieldOcc :: PostRn name name } data AmbiguousFieldOcc name = Unambiguous RdrName (PostRn name name) | Ambiguous RdrName (PostTc name name) deriving (Typeable) ``` Add locations to them Updates haddock submodule to match Test Plan: ./validate Reviewers: goldfire, hvr, bgamari, austin Reviewed By: hvr Subscribers: hvr, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1670 GHC Trac Issues: #11258
* Disallow empty where bindings in pattern synonym declarations.Matthew Pickering2015-12-201-1/+7
| | | | | | | | | | | | Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1665 GHC Trac Issues: #10426
* Lexer: update outdated comments [skip ci]Thomas Miedema2015-12-171-4/+4
| | | | | The test for TemplateHaskell was removed in 09015be8d580bc33f5f1960c8e31d00ba7a459a1.
* Expose enabled language extensions to THBen Gamari2015-12-153-42/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This exposes `template-haskell` functions for querying the language extensions which are enabled when compiling a module, - an `isExtEnabled` function to check whether an extension is enabled - an `extsEnabled` function to obtain a full list of enabled extensions To avoid code duplication this adds a `GHC.LanguageExtensions` module to `ghc-boot` and moves `DynFlags.ExtensionFlag` into it. A happy consequence of this is that the ungainly `DynFlags` lost around 500 lines. Moreover, flags corresponding to language extensions are now clearly distinguished from other flags due to the `LangExt.*` prefix. Updates haddock submodule. This fixes #10820. Test Plan: validate Reviewers: austin, spinda, hvr, goldfire, alanz Reviewed By: goldfire Subscribers: mpickering, RyanGlScott, hvr, simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1200 GHC Trac Issues: #10820
* Add kind equalities to GHC.Richard Eisenberg2015-12-114-147/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the ideas originally put forward in "System FC with Explicit Kind Equality" (ICFP'13). There are several noteworthy changes with this patch: * We now have casts in types. These change the kind of a type. See new constructor `CastTy`. * All types and all constructors can be promoted. This includes GADT constructors. GADT pattern matches take place in type family equations. In Core, types can now be applied to coercions via the `CoercionTy` constructor. * Coercions can now be heterogeneous, relating types of different kinds. A coercion proving `t1 :: k1 ~ t2 :: k2` proves both that `t1` and `t2` are the same and also that `k1` and `k2` are the same. * The `Coercion` type has been significantly enhanced. The documentation in `docs/core-spec/core-spec.pdf` reflects the new reality. * The type of `*` is now `*`. No more `BOX`. * Users can write explicit kind variables in their code, anywhere they can write type variables. For backward compatibility, automatic inference of kind-variable binding is still permitted. * The new extension `TypeInType` turns on the new user-facing features. * Type families and synonyms are now promoted to kinds. This causes trouble with parsing `*`, leading to the somewhat awkward new `HsAppsTy` constructor for `HsType`. This is dispatched with in the renamer, where the kind `*` can be told apart from a type-level multiplication operator. Without `-XTypeInType` the old behavior persists. With `-XTypeInType`, you need to import `Data.Kind` to get `*`, also known as `Type`. * The kind-checking algorithms in TcHsType have been significantly rewritten to allow for enhanced kinds. * The new features are still quite experimental and may be in flux. * TODO: Several open tickets: #11195, #11196, #11197, #11198, #11203. * TODO: Update user manual. Tickets addressed: #9017, #9173, #7961, #10524, #8566, #11142. Updates Haddock submodule.
* Refactor ConDeclAlan Zimmerman2015-12-072-60/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ConDecl type in HsDecls is an uneasy compromise. For the most part, HsSyn directly reflects the syntax written by the programmer; and that gives just the right "pegs" on which to hang Alan's API annotations. But ConDecl doesn't properly reflect the syntax of Haskell-98 and GADT-style data type declarations. To be concrete, here's a draft new data type ```lang=hs data ConDecl name | ConDeclGADT { con_names :: [Located name] , con_type :: LHsSigType name -- The type after the ‘::’ , con_doc :: Maybe LHsDocString } | ConDeclH98 { con_name :: Located name , con_qvars :: Maybe (LHsQTyVars name) -- User-written forall (if any), and its implicit -- kind variables -- Non-Nothing needs -XExistentialQuantification , con_cxt :: Maybe (LHsContext name) -- ^ User-written context (if any) , con_details :: HsConDeclDetails name -- ^ Arguments , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. } deriving (Typeable) ``` Note that For GADTs, just keep a type. That's what the user writes. NB:HsType can represent records on the LHS of an arrow: { x:Int,y:Bool} -> T con_qvars and con_cxt are both Maybe because they are both optional (the forall and the context of an existential data type For ConDeclGADT the type variables of the data type do not scope over the con_type; whereas for ConDeclH98 they do scope over con_cxt and con_details. Updates haddock submodule. Test Plan: ./validate Reviewers: simonpj, erikd, hvr, goldfire, austin, bgamari Subscribers: erikd, goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1558 GHC Trac Issues: #11028
* Refactor treatment of wildcardsSimon Peyton Jones2015-12-013-188/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch began as a modest refactoring of HsType and friends, to clarify and tidy up exactly where quantification takes place in types. Although initially driven by making the implementation of wildcards more tidy (and fixing a number of bugs), I gradually got drawn into a pretty big process, which I've been doing on and off for quite a long time. There is one compiler performance regression as a result of all this, in perf/compiler/T3064. I still need to look into that. * The principal driving change is described in Note [HsType binders] in HsType. Well worth reading! * Those data type changes drive almost everything else. In particular we now statically know where (a) implicit quantification only (LHsSigType), e.g. in instance declaratios and SPECIALISE signatures (b) implicit quantification and wildcards (LHsSigWcType) can appear, e.g. in function type signatures * As part of this change, HsForAllTy is (a) simplified (no wildcards) and (b) split into HsForAllTy and HsQualTy. The two contructors appear when and only when the correponding user-level construct appears. Again see Note [HsType binders]. HsExplicitFlag disappears altogether. * Other simplifications - ExprWithTySig no longer needs an ExprWithTySigOut variant - TypeSig no longer needs a PostRn name [name] field for wildcards - PatSynSig records a LHsSigType rather than the decomposed pieces - The mysterious 'GenericSig' is now 'ClassOpSig' * Renamed LHsTyVarBndrs to LHsQTyVars * There are some uninteresting knock-on changes in Haddock, because of the HsSyn changes I also did a bunch of loosely-related changes: * We already had type synonyms CoercionN/CoercionR for nominal and representational coercions. I've added similar treatment for TcCoercionN/TcCoercionR mkWpCastN/mkWpCastN All just type synonyms but jolly useful. * I record-ised ForeignImport and ForeignExport * I improved the (poor) fix to Trac #10896, by making TcTyClsDecls.checkValidTyCl recover from errors, but adding a harmless, abstract TyCon to the envt if so. * I did some significant refactoring in RnEnv.lookupSubBndrOcc, for reasons that I have (embarrassingly) now totally forgotten. It had to do with something to do with import and export Updates haddock submodule.
* Remove deprecated quasiquoter syntax.Matthew Pickering2015-11-291-4/+0
| | | | | | | | | | | | | | In spirit, this reverts 9ba922ee06b048774d7a82964867ff768a78126e The syntax has been deprecated with a warning since 2010. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1530
* Implement new -XTemplateHaskellQuotes pragmaHerbert Valerio Riedel2015-11-291-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | Since f16ddcee0c64a92ab911a7841a8cf64e3ac671fd / D876, `ghc-stage1` supports a subset of `-XTemplateHaskell`, but since we need Cabal to be able detect (so `.cabal` files can be specified accordingly, see also GHC #11102 which omits `TemplateHaskell` from `--supported-extensions`) whether GHC provides full or only partial `-XTemplateHaskell` support, the proper way to accomplish this is to split off the quotation/non-splicing `TemplateHaskell` feature-subset into a new language pragma `TemplateHaskellQuotes`. Moreover, `-XTemplateHaskellQuotes` is considered safe under SafeHaskell This addresses #11121 Reviewers: goldfire, ezyang, dterei, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1511 GHC Trac Issues: #11121
* ApiAnnotations: Make all RdrName occurences LocatedAlan Zimmerman2015-11-232-48/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment the API Annotations can only be used on the ParsedSource, as there are changes made to the RenamedSource that prevent it from being used to round trip source code. It is possible to build a map from every Located Name in the RenamedSource from its location to the Name, which can then be used when resolved names are required when changing the ParsedSource. However, there are instances where the identifier is not located, specifically (GHC.VarPat name) (GHC.HsVar name) (GHC.UserTyVar name) (GHC.HsTyVar name) Replace each of the name types above with (Located name) Updates the haddock submodule. Test Plan: ./validate Reviewers: austin, goldfire, bgamari Reviewed By: bgamari Subscribers: goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1512 GHC Trac Issues: #11019
* Add comment to Parser.y re extra API AnnotationAlan Zimmerman2015-11-221-1/+17
| | | | Document extra AnnRarrow annotation on a HsFunTy
* Refactor HsExpr.RecordCon, RecordUpdSimon Peyton Jones2015-11-181-4/+16
| | | | | | | | | | | | | | This follows Matthew's patch making pattern synoyms work with records. This patch - replaces the (PostTc id [FieldLabel]) field of RecordCon with (PostTc id ConLike) - record-ises both RecordCon and RecordUpd, which both have quite a lot of fields. No change in behaviour
* MonadFail proposal, phase 1David Luposchainsky2015-11-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | This implements phase 1 of the MonadFail proposal (MFP, #10751). - MonadFail warnings are all issued as desired, tunable with two new flags - GHC was *not* made warning-free with `-fwarn-missing-monadfail-warnings` (but it's disabled by default right now) Credits/thanks to - Franz Thoma, whose help was crucial to implementing this - My employer TNG Technology Consulting GmbH for partially funding us for this work Reviewers: goldfire, austin, #core_libraries_committee, hvr, bgamari, fmthoma Reviewed By: hvr, bgamari, fmthoma Subscribers: thomie Projects: #ghc Differential Revision: https://phabricator.haskell.org/D1248 GHC Trac Issues: #10751
* Implement OverloadedLabelsAdam Gundry2015-11-172-1/+25
| | | | | | | | | | | | | | See https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/OverloadedLabels for the big picture. Reviewers: goldfire, simonpj, austin, hvr, bgamari Reviewed By: simonpj, bgamari Subscribers: kosmikus, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1331
* ApiAnnotations : ITopenExpQuote needs SourceTextAlan Zimmerman2015-11-163-10/+30
| | | | | | | | | | | | | | | | | | | | | | | Summary: In the lexer, ITopenExpQuote can be recognised for '[e|' or '[|'. The token definition needs to capture the original SourceText, and pass it through to ExpBr, which also needs a SrcText field. It is easier to simply add a flag to the token identifying the variant and to generate a different AnnKeywordId based on this. Test Plan: ./validate Reviewers: mpickering, bgamari, austin Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1479 GHC Trac Issues: #10276
* ApiAnnotations: Add SourceText for unicode tokensAlan Zimmerman2015-11-163-117/+184
| | | | | | | | | | | | | | | | | | | | | | | Summary: At the moment there is no way to tell if a given token used its unicode variant or its normal one, except to look at the length of the token. This fails for the unicode '*'. Expose the original source text for unicode variants so that API Annotations can capture them specifically. Test Plan: ./validate Reviewers: mpickering, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1473 GHC Trac Issues: #11018
* APIAnnotations:add Locations in hsSyn for layoutAlan Zimmerman2015-11-132-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: At the moment ghc-exactprint, which uses the GHC API Annotations to provide a framework for roundtripping Haskell source code with optional AST edits, has to implement a horrible workaround to manage the points where layout needs to be captured. These are MatchGroup HsDo HsCmdDo HsLet LetStmt HsCmdLet GRHSs To provide a more natural representation, the contents subject to layout rules need to be wrapped in a SrcSpan. This commit does this. Trac ticket #10250 Test Plan: ./validate Reviewers: hvr, goldfire, bgamari, austin, mpickering Reviewed By: mpickering Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1370 GHC Trac Issues: #10250
* mkGadtDecl no longer in P monadJan Stolarek2015-11-112-12/+10
| | | | | | | | | | | | | | | | Since `mkGadtDecl` does not use any of the functions specific to the `P` monad we can extract it from that monad and reuse in other parts of the compiler. Test Plan: ./validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1461
* Remove fun_infix from Funbind, as it is now in MatchAlan Zimmerman2015-11-112-19/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of the changes D538 introduced is to add `m_fun_id_infix` to `Match` ```lang=hs data Match id body = Match { m_fun_id_infix :: (Maybe (Located id,Bool)), -- fun_id and fun_infix for functions with multiple equations -- only present for a RdrName. See note [fun_id in Match] m_pats :: [LPat id], -- The patterns m_type :: (Maybe (LHsType id)), -- A type signature for the result of the match -- Nothing after typechecking m_grhss :: (GRHSs id body) } deriving (Typeable) ``` This was done to track the individual locations and fixity of the `fun_id` for each of the defining equations for a function when there are more than one. For example, the function `(&&&)` is defined with some prefix and some infix equations below. ```lang=hs (&&& ) [] [] = [] xs &&& [] = xs ( &&& ) [] ys = ys ``` This means that the fun_infix is now superfluous in the `FunBind`. This has not been removed as a potentially risky change just before 7.10 RC2, and so must be done after. This ticket captures that task, which includes processing these fields through the renamer and beyond. Ticket #9988 introduced these fields into `Match` through renaming, this ticket it to continue through type checking and then remove it from `FunBind` completely. The split happened so that #9988 could land in 7.10 Trac ticket : #10061 Test Plan: ./validate Reviewers: goldfire, austin, simonpj, bgamari Reviewed By: bgamari Subscribers: simonpj, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1285 GHC Trac Issues: #10061
* Remove unused field in ConDeclJan Stolarek2015-11-111-4/+2
| | | | | | | | | | | | | | | | | We no longer parse old-style GADT syntax but there was some left-over code for emitting deprecation warnings. Updates haddock submodule. Test Plan: ./validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1460
* Associate pattern synonyms with types in module exportsMatthew Pickering2015-11-112-23/+83
| | | | | | | | | | | | | | | | | | | | | | This patch implements #10653. It adds the ability to bundle pattern synonyms with type constructors in export lists so that users can treat pattern synonyms more like data constructors. Updates haddock submodule. Test Plan: ./validate Reviewers: goldfire, austin, bgamari Reviewed By: bgamari Subscribers: simonpj, gridaphobe, thomie Differential Revision: https://phabricator.haskell.org/D1258 GHC Trac Issues: #10653
* Parser: allow empty multi-line deprecation warningsThomas Miedema2015-11-081-0/+1
| | | | | | | | | | | | | | | | | | This should work, {-# DEPRECATED someFunction [] #-} Test Plan: parser/should_compile/T3303 Reviewers: bgamari, austin Reviewed By: austin Subscribers: mpickering Differential Revision: https://phabricator.haskell.org/D1433 GHC Trac Issues: #11044
* Remove PatSynBuilderIdMatthew Pickering2015-11-071-2/+2
| | | | | | | | | | | | | | | | | Summary: It was only used to pass field labels between the typechecker and desugarer. Instead we add an extra field the RecordCon to carry this information. Reviewers: austin, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1443 GHC Trac Issues: #11057
* ApiAnnotations: BooleanFormula is not properly LocatedAlan Zimmerman2015-11-011-14/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment BooleanFormula is defined as data BooleanFormula a = Var a | And [BooleanFormula a] | Or [BooleanFormula a] deriving (Eq, Data, Typeable, Functor, Foldable, Traversable) An API Annotation can only be attached to an item of the form Located a. Replace this with a properly Located version, and attach the appropriate API Annotations to it Updates haddock submodule. Test Plan: ./validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1384 GHC Trac Issues: #11017
* Provide a utility to check API Annotations docsAlan Zimmerman2015-11-011-0/+5
| | | | | | | | | | | | | | | | | | | | | | | A utility to check API Annotations was provided in https://git.haskell.org/ghc.git/commitdiff/43751b2436f370d956d8021b3cdd3 eb77801470b This commit had poor documentation. This patch improves the output generated by the utility as well as supplying better documentation Test Plan: ./validate Reviewers: simonpj, austin, bgamari Reviewed By: austin, bgamari Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1397 GHC Trac Issues: #10917
* Swap prov/req in variable naming in Parser.ySimon Peyton Jones2015-10-301-2/+2
| | | | | This is a follow on to the patch for Trac #10928. It's a local renaming of variables only; no change in behaviour.
* Record pattern synonymsMatthew Pickering2015-10-292-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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"
* Comments onlySimon Peyton Jones2015-10-271-0/+1
|
* Suggest enabling PatternSynonyms (#10943)Moritz Kiefer2015-10-221-5/+9
| | | | | | | | | Suggest enabling PatternSynonyms if we find an invalid signature that looks like a pattern synonym. Reviewed By: austin, thomie Differential Revision: https://phabricator.haskell.org/D1347
* Reject top-level typed TH splices. Fixes #10945Jan Stolarek2015-10-201-4/+11
| | | | | | | | | | | | | | | | | When TemplateHaskell language extension is enabled it is valid to have top-level expressions. Each such expression is treated as a contents of a splice. The problem arises with typed splices. They are not valid at the top level and therefore we should interpret them not as a splice but as a top-level expression (aka. implicit splice). So saying: $$foo is equivalent of: $( $$foo ) This patch makes sure that this is indeed the case. Until now we incorrectly treated typed splices as explicit splices.
* Make Monad/Applicative instances MRP-friendlyHerbert Valerio Riedel2015-10-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This patch refactors pure/(*>) and return/(>>) in MRP-friendly way, i.e. such that the explicit definitions for `return` and `(>>)` match the MRP-style default-implementation, i.e. return = pure and (>>) = (*>) This way, e.g. all `return = pure` definitions can easily be grepped and removed in GHC 8.1; Test Plan: Harbormaster Reviewers: goldfire, alanz, bgamari, quchen, austin Reviewed By: quchen, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1312
* Implement DuplicateRecordFieldsAdam Gundry2015-10-162-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements DuplicateRecordFields, the first part of the OverloadedRecordFields extension, as described at https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields This includes fairly wide-ranging changes in order to allow multiple records within the same module to use the same field names. Note that it does *not* allow record selector functions to be used if they are ambiguous, and it does not have any form of type-based disambiguation for selectors (but it does for updates). Subsequent parts will make overloading selectors possible using orthogonal extensions, as described on the wiki pages. This part touches quite a lot of the codebase, and requires changes to several GHC API datatypes in order to distinguish between field labels (which may be overloaded) and selector function names (which are always unique). The Haddock submodule has been adapted to compile with the GHC API changes, but it will need further work to properly support modules that use the DuplicateRecordFields extension. Test Plan: New tests added in testsuite/tests/overloadedrecflds; these will be extended once the other parts are implemented. Reviewers: goldfire, bgamari, simonpj, austin Subscribers: sjcjoosten, haggholm, mpickering, bgamari, tibbe, thomie, goldfire Differential Revision: https://phabricator.haskell.org/D761
* Rename package key to unit ID, and installed package ID to component ID.Edward Z. Yang2015-10-141-1/+1
| | | | | | Comes with Haddock submodule update. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Parser: revert some error messages to what they were before 7.10Thomas Miedema2015-10-071-31/+0
| | | | | | | | | | | | | | | | | Among doing other things, Phab:D201 (bc2289e13d9586be087bd8136943dc35a0130c88) tried to improve the error messages thrown by the parser. For example a missing else clause now prints "parse error in if statement: else clause empty" instead of "parse error (possibly incorrect indentation or mismatched brackets)". Some error messages got much worse however (see tests), and the result seems to be a net negative. Although not entirely satisfactory, this commits therefore reverts those parser changes. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D1309 GHC Trac Issues: #10498
* Allow non-operator infix pattern synonymsMatthew Pickering2015-10-071-1/+1
| | | | | | | | | | | | | | For example ``` pattern head `Cons` tail = head : tail ``` Reviewed By: goldfire, austin Differential Revision: https://phabricator.haskell.org/D1295 GHC Trac Issues: #10747
* Lexer: delete dead code for binary character literalsThomas Miedema2015-09-301-2/+0
| | | | | | | | | | | | | | | | | | | The Haskell 2010 report chapter 2.6 (Characters and String Literals) says: "Numeric escapes such as \137 are used to designate the character with decimal representation 137; octal (e.g. \o137) and hexadecimal (e.g. \x37) representations are also allowed." Commit 1c0b5fdc9f2b6ea8166cc565383d4cd20432343c added syntax for writing character literals using binary notation (e.g. '\b100100'). But this code can never be reached, because '\b' already represents "backspace". Turn on -fwarn-overlapping-patterns to catch such bugs in the future. Reviewed by: hvr Differential Revision: https://phabricator.haskell.org/D1291
* Replace [PostTc id Type] with PostTc id [Type]Matthew Pickering2015-09-201-1/+2
| | | | | | | | | | | | | | | This gives a clearer indication as to what gets filled in when. It was suggested by Richard on D1152. Test Plan: ./validate Reviewers: austin, goldfire, bgamari Reviewed By: goldfire, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1245
* ApplicativeDo transformationSimon Marlow2015-09-171-2/+2
| | | | | | | | | | | | | | | | Summary: This is an implementation of the ApplicativeDo proposal. See the Note [ApplicativeDo] in RnExpr for details on the current implementation, and the wiki page https://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo for design notes. Test Plan: validate Reviewers: simonpj, goldfire, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D729
* Injective type familiesJan Stolarek2015-09-033-32/+78
| | | | | | | | | | | | | | | | | | | For details see #6018, Phab:D202 and the wiki page: https://ghc.haskell.org/trac/ghc/wiki/InjectiveTypeFamilies This patch also wires-in Maybe data type and updates haddock submodule. Test Plan: ./validate Reviewers: simonpj, goldfire, austin, bgamari Subscribers: mpickering, bgamari, alanz, thomie, goldfire, simonmar, carter Differential Revision: https://phabricator.haskell.org/D202 GHC Trac Issues: #6018
* Comments reformating/correctionsDivam2015-08-181-1/+1
| | | | | | | | | | Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1145
* Replace HsBang type with HsSrcBang and HsImplBangAdam Sandberg Eriksson2015-08-101-2/+2
| | | | | | | | | | | | Updates haddock submodule. Reviewers: tibbe, goldfire, simonpj, austin, bgamari Reviewed By: simonpj, bgamari Subscribers: goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1069
* Removed deprecated syntax for GADT constuctors.Ulya Trofimovich2015-08-032-59/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Old syntax was deprecated 6 years ago in this commit 432b9c9322181a3644083e3c19b7e240d90659e7 by simonpj:"New syntax for GADT-style record declarations, and associated refactoring" discussed in Trac #3306. This patch removes 2 reduce/reduce conflicts in parser. Conflicting productions were: ``` gadt_constr -> con_list '::' sigtype gadt_constr -> oqtycon '{' fielddecls '}' '::' sigtype ``` Recursive inlining of `con_list` and `oqtycon` helped reveal the conflict: ``` gadt_constr -> '(' CONSYM ')' '::' sigtype gadt_constr -> '(' CONSYM ')' '{' fielddecls '}' '::' sigtype ``` between two types of GADT constructors (second form stands for deprecated syntax). Test Plan: `make fasttest`, one breakage TEST="records-fail" (parse error instead of typecheck error due to removal of deprecated syntax). Updated test. Reviewers: simonmar, bgamari, austin, simonpj Reviewed By: simonpj Subscribers: thomie, mpickering, trofi Differential Revision: https://phabricator.haskell.org/D1118 GHC Trac Issues: #3306
* Typos in comments [skip ci]Gabor Greif2015-08-031-1/+1
|
* 4 reduce/reduce parser conflicts resolvedUlya Trofimovich2015-08-031-154/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As GHC documentation (section 7.4.4, Type operators) says: > "There is now some potential ambiguity in import and export lists; for example if you write import M( (+) ) do you mean the function (+) or the type constructor (+)? The default is the former, but with -XExplicitNamespaces (which is implied by -XExplicitTypeOperators) GHC allows you to specify the latter by preceding it with the keyword type" Turns out this ambiguity causes 4 of 6 reduce/reduce conflicts in GHC parser. All 4 conflicts arise from a single production: qcname : qvar | oqtycon Recursive inlining of 'qvar' and 'oqtycon' helps reveal the faulty productions: qcname : ... | '(' QVARSYM ')' | '(' VARSYM ')' | '(' '*' ')' | '(' '-' ')' These productions can either be parsed as variable or type constructor, but variable constuctor is always preferred. My patch removes ambiguity while preserving the existing behaviour: - all unambigous productions are left as-is - ambigous productions for variable constuctors are left - ambigous productions for type constructors are removed (there's no way they could be triggered) Updated comment. Test Plan: Tested with 'make fasttest' Reviewers: austin, simonpj, trofi, bgamari, simonmar Reviewed By: trofi, bgamari, simonmar Subscribers: thomie, mpickering Projects: #ghc Differential Revision: https://phabricator.haskell.org/D1111
* Replace (SourceText,FastString) with StringLiteral data typeAlan Zimmerman2015-08-022-20/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Phab:D907 introduced SourceText for a number of data types, by replacing FastString with (SourceText,FastString). Since this has an Outputable instance, no warnings are generated when ppr is called on it, but unexpected output is generated. See Phab:D1096 for an example of this. Replace the (SourceText,FastString) tuples with a new data type, ```lang=hs data StringLiteral = StringLiteral SourceText FastString ``` Update haddock submodule accordingly Test Plan: ./validate Reviewers: hvr, austin, rwbarton, trofi, bgamari Reviewed By: trofi, bgamari Subscribers: thomie, trofi, rwbarton, mpickering Differential Revision: https://phabricator.haskell.org/D1101 GHC Trac Issues: #10692
* Implementation of StrictData language extensionAdam Sandberg Eriksson2015-07-272-35/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the `StrictData` language extension, which lets the programmer default to strict data fields in datatype declarations on a per-module basis. Specification and motivation can be found at https://ghc.haskell.org/trac/ghc/wiki/StrictPragma This includes a tricky parser change due to conflicts regarding `~` in the type level syntax: all ~'s are parsed as strictness annotations (see `strict_mark` in Parser.y) and then turned into equality constraints at the appropriate places using `RdrHsSyn.splitTilde`. Updates haddock submodule. Test Plan: Validate through Harbormaster. Reviewers: goldfire, austin, hvr, simonpj, tibbe, bgamari Reviewed By: simonpj, tibbe, bgamari Subscribers: lelf, simonpj, alanz, goldfire, thomie, bgamari, mpickering Differential Revision: https://phabricator.haskell.org/D1033 GHC Trac Issues: #8347
* Accept next-docstrings on GADT constructors.Ben Gamari2015-07-231-3/+10
| | | | | | | | | | | | | | | | Accept next docstrings (`-- | Docstring`) on GADT constructors. I have confirmed that this adds no shift/reduce conflicts. Test Plan: haddockA034 Reviewers: austin, simonpj, simonmar Reviewed By: simonmar Subscribers: Fuuzetsu, simonmar, thomie, mpickering, edsko Differential Revision: https://phabricator.haskell.org/D1086