summaryrefslogtreecommitdiff
path: root/compiler/deSugar/Desugar.hs
diff options
context:
space:
mode:
authorShayan-Najd <sh.najd@gmail.com>2018-11-22 01:23:29 +0000
committerAlan Zimmerman <alan.zimm@gmail.com>2018-11-24 12:30:21 +0200
commit509d5be69c7507ba5d0a5f39ffd1613a59e73eea (patch)
treeb3db08f371014cbf235525843a312f67dea77354 /compiler/deSugar/Desugar.hs
parentad2d7612dbdf0e928318394ec0606da3b85a8837 (diff)
downloadhaskell-509d5be69c7507ba5d0a5f39ffd1613a59e73eea.tar.gz
[TTG: Handling Source Locations] Foundation and Pat
This patch removes the ping-pong style from HsPat (only, for now), using the plan laid out at https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow/HandlingSourceLocations (solution A). - the class `HasSrcSpan`, and its functions (e.g., `cL` and `dL`), are introduced - some instances of `HasSrcSpan` are introduced - some constructors `L` are replaced with `cL` - some patterns `L` are replaced with `dL->L` view pattern - some type annotation are necessarily updated (e.g., `Pat p` --> `Pat (GhcPass p)`) Phab diff: D5036 Trac Issues #15495 Updates haddock submodule
Diffstat (limited to 'compiler/deSugar/Desugar.hs')
-rw-r--r--compiler/deSugar/Desugar.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/compiler/deSugar/Desugar.hs b/compiler/deSugar/Desugar.hs
index c7973ca4f3..0ed35f2d4c 100644
--- a/compiler/deSugar/Desugar.hs
+++ b/compiler/deSugar/Desugar.hs
@@ -8,6 +8,7 @@ The Desugarer: turning HsSyn into Core.
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE ViewPatterns #-}
module Desugar (
-- * Desugaring operations
@@ -379,13 +380,13 @@ Reason
-}
dsRule :: LRuleDecl GhcTc -> DsM (Maybe CoreRule)
-dsRule (L loc (HsRule { rd_name = name
- , rd_act = rule_act
- , rd_tmvs = vars
- , rd_lhs = lhs
- , rd_rhs = rhs }))
+dsRule (dL->L loc (HsRule { rd_name = name
+ , rd_act = rule_act
+ , rd_tmvs = vars
+ , rd_lhs = lhs
+ , rd_rhs = rhs }))
= putSrcSpanDs loc $
- do { let bndrs' = [var | L _ (RuleBndr _ (L _ var)) <- vars]
+ do { let bndrs' = [var | (dL->L _ (RuleBndr _ (dL->L _ var))) <- vars]
; lhs' <- unsetGOptM Opt_EnableRewriteRules $
unsetWOptM Opt_WarnIdentities $
@@ -422,8 +423,8 @@ dsRule (L loc (HsRule { rd_name = name
; return (Just rule)
} } }
-dsRule (L _ (XRuleDecl _)) = panic "dsRule"
-
+dsRule (dL->L _ (XRuleDecl _)) = panic "dsRule"
+dsRule _ = panic "dsRule: Impossible Match" -- due to #15884
warnRuleShadowing :: RuleName -> Activation -> Id -> [Id] -> DsM ()
-- See Note [Rules and inlining/other rules]