[GHC] #14476: Keep source locations in Core (optionally)
GHC
ghc-devs at haskell.org
Thu Nov 16 17:01:44 UTC 2017
#14476: Keep source locations in Core (optionally)
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner: (none)
Type: feature | Status: new
request |
Priority: normal | Milestone:
Component: Compiler | Version: 8.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
The people working on liquid haskell have to maintain their own copy of
the desugarer because of one little change they have to do: Add lots and
lots of `CC`s to keep source spans around. Their current patch is
{{{
diff --git a/src/Language/Haskell/Liquid/Desugar/DsExpr.hs
b/src/Language/Haskell/Liquid/Desugar/DsExpr.hs
index 396095e9a..9ba60c56f 100644
--- a/src/Language/Haskell/Liquid/Desugar/DsExpr.hs
+++ b/src/Language/Haskell/Liquid/Desugar/DsExpr.hs
@@ -221,14 +221,13 @@ dsUnliftedBind bind body = pprPanic "dsLet:
unlifted" (ppr bind $$ ppr body)
dsLExpr :: LHsExpr Id -> DsM CoreExpr
dsLExpr (L loc e)
- = putSrcSpanDs loc $
- do { core_expr <- dsExpr e
- -- uncomment this check to test the hsExprType function in TcHsSyn
- -- ; MASSERT2( exprType core_expr `eqType` hsExprType e
- -- , ppr e <+> dcolon <+> ppr (hsExprType e) $$
- -- ppr core_expr <+> dcolon <+> ppr (exprType
core_expr) )
- ; return core_expr }
+ = do ce <- putSrcSpanDs loc $ dsExpr e
+ m <- getModule
+ return $ Tick (srcSpanTick m loc) ce
+srcSpanTick :: Module -> SrcSpan -> Tickish a
+srcSpanTick m loc
+ = ProfNote (AllCafsCC m loc) False True
-- | Variant of 'dsLExpr' that ensures that the result is not levity
-- polymorphic. This should be used when the resulting expression will
-- be an argument to some other function.
}}}
It would make their live easier if they could just use GHC’s desugarer,
and it might open the path to making Liquid Haskell a proper GHC plugin
instead of a separate program, which could facilitate adoption.
Would it be ok to add a flag to GHC that enables this behaviour? Or is
there another way of doing this?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14476>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list