Keep source locations in Core (optionally)
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 CCs 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?
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.3 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |