Another round of External Core fixes
[ghc-hetmet.git] / compiler / parser / Parser.y.pp
index 167c8b6..32ab991 100644 (file)
@@ -822,7 +822,11 @@ where_inst :: { Located (OrdList (LHsDecl RdrName)) }      -- Reversed
 -- Declarations in binding groups other than classes and instances
 --
 decls  :: { Located (OrdList (LHsDecl RdrName)) }      
-       : decls ';' decl                { LL (unLoc $1 `appOL` unLoc $3) }
+       : decls ';' decl                { let { this = unLoc $3;
+                                    rest = unLoc $1;
+                                    these = rest `appOL` this }
+                              in rest `seq` this `seq` these `seq`
+                                    LL these }
        | decls ';'                     { LL (unLoc $1) }
        | decl                          { $1 }
        | {- empty -}                   { noLoc nilOL }
@@ -1221,12 +1225,13 @@ decl    :: { Located (OrdList (LHsDecl RdrName)) }
                                                return (LL $ unitOL $ LL $ ValD ( 
                                                        PatBind (LL $ BangPat pat) (unLoc $3)
                                                                placeHolderType placeHolderNames)) } }
-       | infixexp opt_sig rhs          {% do { r <- checkValDef $1 $2 $3;
-                                               return $! (LL $! (unitOL $! (LL $ ValD r))) } }
+        | infixexp opt_sig rhs          {% do { r <- checkValDef $1 $2 $3;
+                                                let { l = comb2 $1 $> };
+                                                return $! (sL l (unitOL $! (sL l $ ValD r))) } }
         | docdecl                       { LL $ unitOL $1 }
 
 rhs    :: { Located (GRHSs RdrName) }
-       : '=' exp wherebinds    { L (comb3 $1 $2 $3) $ GRHSs (unguardedRHS $2) (unLoc $3) }
+       : '=' exp wherebinds    { sL (comb3 $1 $2 $3) $ GRHSs (unguardedRHS $2) (unLoc $3) }
        | gdrhs wherebinds      { LL $ GRHSs (reverse (unLoc $1)) (unLoc $2) }
 
 gdrhs :: { Located [LGRHS RdrName] }
@@ -1436,7 +1441,7 @@ list :: { LHsExpr RdrName }
        | texp '|' flattenedpquals      { sL (comb2 $1 $>) $ mkHsDo ListComp (unLoc $3) $1 }
 
 lexps :: { Located [LHsExpr RdrName] }
-       : lexps ',' texp                { LL ($3 : unLoc $1) }
+       : lexps ',' texp                { LL (((:) $! $3) $! unLoc $1) }
        | texp ',' texp                 { LL [$3,$1] }
 
 -----------------------------------------------------------------------------
@@ -1624,9 +1629,10 @@ fbind    :: { HsRecField RdrName (LHsExpr RdrName) }
 -- Implicit Parameter Bindings
 
 dbinds         :: { Located [LIPBind RdrName] }
-       : dbinds ';' dbind              { LL ($3 : unLoc $1) }
+       : dbinds ';' dbind              { let { this = $3; rest = unLoc $1 }
+                              in rest `seq` this `seq` LL (this : rest) }
        | dbinds ';'                    { LL (unLoc $1) }
-       | dbind                         { L1 [$1] }
+       | dbind                         { let this = $1 in this `seq` L1 [this] }
 --     | {- empty -}                   { [] }
 
 dbind  :: { LIPBind RdrName }
@@ -1965,19 +1971,21 @@ getDOCSECTION (L _ (ITdocSection n x)) = (n, x)
 
 -- Utilities for combining source spans
 comb2 :: Located a -> Located b -> SrcSpan
-comb2 = combineLocs
+comb2 a b = a `seq` b `seq` combineLocs a b
 
 comb3 :: Located a -> Located b -> Located c -> SrcSpan
-comb3 a b c = combineSrcSpans (getLoc a) (combineSrcSpans (getLoc b) (getLoc c))
+comb3 a b c = a `seq` b `seq` c `seq`
+    combineSrcSpans (getLoc a) (combineSrcSpans (getLoc b) (getLoc c))
 
 comb4 :: Located a -> Located b -> Located c -> Located d -> SrcSpan
-comb4 a b c d = combineSrcSpans (getLoc a) $ combineSrcSpans (getLoc b) $
-               combineSrcSpans (getLoc c) (getLoc d)
+comb4 a b c d = a `seq` b `seq` c `seq` d `seq`
+    (combineSrcSpans (getLoc a) $ combineSrcSpans (getLoc b) $
+               combineSrcSpans (getLoc c) (getLoc d))
 
 -- strict constructor version:
 {-# INLINE sL #-}
 sL :: SrcSpan -> a -> Located a
-sL span a = span `seq` L span a
+sL span a = span `seq` a `seq` L span a
 
 -- Make a source location for the file.  We're a bit lazy here and just
 -- make a point SrcSpan at line 1, column 0.  Strictly speaking we should