Ticket #3377: TupleSections-compiler.patch

File TupleSections-compiler.patch, 34.5 KB (added by batterseapower, 5 years ago)
Line 
1Fri Jul 17 21:56:44 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
2  * Checkpoint working implementation of tuple sections
3
4Fri Jul 17 22:09:39 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
5  * Improvements to the tuple section parser
6
7Fri Jul 17 22:23:14 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
8  * Support unboxed tuples in tuple sections
9
10Fri Jul 17 22:40:31 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
11  * Documentation for tuple sections
12
13Fri Jul 17 23:31:42 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
14  * Fix validation failure caused by tuple sections
15
16New patches:
17
18[Checkpoint working implementation of tuple sections
19Max Bolingbroke <batterseapower@hotmail.com>**20090717205644
20 Ignore-this: 50eb87a80b944f116d685b704efb5e35
21] {
22hunk ./compiler/deSugar/Coverage.lhs 27
23 import StaticFlags
24 import TyCon
25 import FiniteMap
26+import Maybes
27 
28 import Data.Array
29hunk ./compiler/deSugar/Coverage.lhs 30
30-import Data.Maybe
31 import System.Directory ( createDirectoryIfMissing )
32 
33 import Trace.Hpc.Mix
34hunk ./compiler/deSugar/Coverage.lhs 281
35        liftM2 SectionR
36                (addTickLHsExpr e1)
37                (addTickLHsExpr e2)
38+addTickHsExpr (SectionTup tys mb_es boxity) =
39+        liftM3 SectionTup
40+                (return tys)
41+                (mapM (fmapM_maybe addTickLHsExpr) mb_es)
42+                (return boxity)
43 addTickHsExpr (HsCase e mgs) =
44        liftM2 HsCase
45                (addTickLHsExpr e)
46hunk ./compiler/deSugar/Coverage.lhs 309
47                    ListComp -> Just $ BinBox QualBinBox
48                    _        -> Nothing
49 addTickHsExpr (ExplicitList ty es) =
50-       liftM2 ExplicitList
51+       liftM2 ExplicitList
52                (return ty)
53                (mapM (addTickLHsExpr) es)
54 addTickHsExpr (ExplicitPArr ty es) =
55hunk ./compiler/deSugar/DsExpr.lhs 264
56     return (bindNonRec y_id y_core $
57             Lam x_id (mkCoreAppsDs core_op [Var x_id, Var y_id]))
58 
59+dsExpr (SectionTup tys mb_exprs boxity) = do
60+    let go (lam_vars, args) (ty, Nothing)        = do
61+            -- For every missing expression, we need another lambda in the desugaring.
62+            lam_var <- newSysLocalDs ty
63+            return (lam_var : lam_vars, Var lam_var : args)
64+        go (lam_vars, args) (_, Just expr) = do
65+            -- Expressions that are present don't generate lambdas, just arguments.
66+            core_expr <- dsLExpr expr
67+            return (lam_vars, core_expr : args)
68+    (lam_vars, args) <- foldM go ([], []) (tys `zip` mb_exprs)
69+    return $ mkCoreLams (reverse lam_vars) $ mkConApp (tupleCon boxity (length mb_exprs))
70+                                                      (map Type tys ++ reverse args)
71+
72 dsExpr (HsSCC cc expr) = do
73     mod_name <- getModuleDs
74     Note (SCC (mkUserCC cc mod_name)) <$> dsLExpr expr
75hunk ./compiler/deSugar/DsMeta.hs 686
76 repE (HsPar x)            = repLE x
77 repE (SectionL x y)       = do { a <- repLE x; b <- repLE y; repSectionL a b }
78 repE (SectionR x y)       = do { a <- repLE x; b <- repLE y; repSectionR a b }
79+repE e@(SectionTup _ _ _) = notHandled "Tuple sections" (ppr e)
80 repE (HsCase e (MatchGroup ms _)) = do { arg <- repLE e
81                                       ; ms2 <- mapM repMatchTup ms
82                                       ; repCaseE arg (nonEmptyCoreList ms2) }
83hunk ./compiler/deSugar/Match.lhs 884
84         --   if it seems useful (lams and lets)
85         wrap _ _ = False
86 
87+        liftMaybe2 f (Just x) (Just y) = Just $ f x y
88+        liftMaybe2 _ _        _        = Nothing
89+       
90         -- real comparison is on HsExpr's
91         -- strip parens
92         exp (HsPar (L _ e)) e'   = exp e e'
93hunk ./compiler/deSugar/Match.lhs 918
94             lexp e1 e1' && lexp e2 e2'
95         exp (SectionR e1 e2) (SectionR e1' e2') =
96             lexp e1 e1' && lexp e2 e2'
97+        exp (SectionTup _ mb_es1 _) (SectionTup _ mb_es2 _) =
98+            all ((`orElse` False) . uncurry (liftMaybe2 lexp)) (mb_es1 `zip` mb_es2)
99         exp (HsIf e e1 e2) (HsIf e' e1' e2') =
100             lexp e e' && lexp e1 e1' && lexp e2 e2'
101         exp (ExplicitList _ ls) (ExplicitList _ ls') = lexps ls ls'
102hunk ./compiler/deSugar/Match.lhs 924
103         exp (ExplicitPArr _ ls) (ExplicitPArr _ ls') = lexps ls ls'
104-        exp (ExplicitTuple ls _) (ExplicitTuple ls' _) = lexps ls ls'
105         -- Enhancement: could implement equality for more expressions
106         --   if it seems useful
107         exp _ _  = False
108hunk ./compiler/hsSyn/HsExpr.lhs 27
109 import SrcLoc
110 import Outputable
111 import FastString
112+import Maybes
113 \end{code}
114 
115 
116hunk ./compiler/hsSyn/HsExpr.lhs 124
117                 (LHsExpr id)    -- operator
118   | SectionR    (LHsExpr id)    -- operator
119                 (LHsExpr id)    -- operand
120+  | SectionTup  [PostTcType]         -- types of components
121+                [Maybe (LHsExpr id)] -- At least one of the components is Nothing.
122+                                     -- Used for the TupleSections extension:
123+                                     --
124+                                     -- >>> (1,,3) 2
125+                                     -- (1, 2, 3)
126+                Boxity
127 
128   | HsCase      (LHsExpr id)
129                 (MatchGroup id)
130hunk ./compiler/hsSyn/HsExpr.lhs 161
131   | ExplicitTuple               -- tuple
132                 [LHsExpr id]
133                                 -- NB: Unit is ExplicitTuple []
134-                                -- for tuples, we can get the types
135-                                -- direct from the components
136                 Boxity
137 
138 
139hunk ./compiler/hsSyn/HsExpr.lhs 389
140     pp_infixly v
141       = (sep [pprHsInfix v, pp_expr])
142 
143+ppr_expr (SectionTup _ mb_exprs boxity)
144+  = tupleParens boxity (sep (punctuate comma (map ((`orElse` empty) . fmap ppr_lexpr) mb_exprs)))
145+
146 --avoid using PatternSignatures for stage1 code portability
147 ppr_expr exprType@(HsLam matches)
148   = pprMatches (LambdaExpr `asTypeOf` idType exprType) matches
149hunk ./compiler/hsSyn/HsExpr.lhs 547
150       HsOverLit _          -> pp_as_was
151       HsVar _              -> pp_as_was
152       HsIPVar _            -> pp_as_was
153+      SectionTup _ _ _     -> pp_as_was
154       ExplicitList _ _     -> pp_as_was
155       ExplicitPArr _ _     -> pp_as_was
156       ExplicitTuple _ _    -> pp_as_was
157hunk ./compiler/main/DynFlags.hs 252
158    | Opt_GeneralizedNewtypeDeriving
159    | Opt_RecursiveDo
160    | Opt_PostfixOperators
161+   | Opt_TupleSections
162    | Opt_PatternGuards
163    | Opt_LiberalTypeSynonyms
164    | Opt_Rank2Types
165hunk ./compiler/main/DynFlags.hs 1770
166 xFlags = [
167   ( "CPP",                              Opt_Cpp, const Supported ),
168   ( "PostfixOperators",                 Opt_PostfixOperators, const Supported ),
169+  ( "TupleSections",                    Opt_TupleSections, const Supported ),
170   ( "PatternGuards",                    Opt_PatternGuards, const Supported ),
171   ( "UnicodeSyntax",                    Opt_UnicodeSyntax, const Supported ),
172   ( "MagicHash",                        Opt_MagicHash, const Supported ),
173hunk ./compiler/parser/Parser.y.pp 1340
174         -- (you'd have to write '((+ 3), (4 -))')
175         -- but the less cluttered version fell out of having texps.
176        | '(' texp ')'                  { LL (HsPar $2) }
177-       | '(' texp ',' texps ')'        { LL $ ExplicitTuple ($2 : reverse $4) Boxed }
178-       | '(#' texps '#)'               { LL $ ExplicitTuple (reverse $2)      Unboxed }
179+        | '(' texp tuplesectend         { LL $ mkTuplish (Just $2 : unLoc $3) Boxed }
180+        | '(' commas texp ')'           { LL $ mkTuplish (replicate $2 Nothing ++ [Just $3]) Boxed }
181+        | '(' commas texp tuplesectend  { LL $ mkTuplish (replicate $2 Nothing ++ Just $3 : unLoc $4) Boxed }
182+       | '(#' texps '#)'               { LL $ ExplicitTuple (reverse $2) Unboxed }
183        | '[' list ']'                  { LL (unLoc $2) }
184        | '[:' parr ':]'                { LL (unLoc $2) }
185        | '_'                           { L1 EWildPat }
186hunk ./compiler/parser/Parser.y.pp 1415
187        : texps ',' texp                { $3 : $1 }
188        | texp                          { [$1] }
189 
190+tuplesectend :: { Located [Maybe (LHsExpr RdrName)] }
191+        : commas texp tuplesectend      { sL (comb2 $2 $>) $ replicate ($1 - 1) Nothing ++ Just $2 : unLoc $3 }
192+        | commas texp ')'               { sL (comb2 $2 $>) $ replicate ($1 - 1) Nothing ++ [Just $2] }
193+        | commas ')'                    { sL (comb2 $2 $>) $ replicate $1 Nothing }
194 
195 -----------------------------------------------------------------------------
196 -- List expressions
197hunk ./compiler/parser/Parser.y.pp 1666
198 
199 sysdcon        :: { Located DataCon }  -- Wired in data constructors
200        : '(' ')'               { LL unitDataCon }
201-       | '(' commas ')'        { LL $ tupleCon Boxed $2 }
202+       | '(' commas ')'        { LL $ tupleCon Boxed ($2 + 1) }
203        | '(#' '#)'             { LL $ unboxedSingletonDataCon }
204hunk ./compiler/parser/Parser.y.pp 1668
205-       | '(#' commas '#)'      { LL $ tupleCon Unboxed $2 }
206+       | '(#' commas '#)'      { LL $ tupleCon Unboxed ($2 + 1) }
207        | '[' ']'               { LL nilDataCon }
208 
209 conop :: { Located RdrName }
210hunk ./compiler/parser/Parser.y.pp 1685
211 gtycon         :: { Located RdrName }  -- A "general" qualified tycon
212        : oqtycon                       { $1 }
213        | '(' ')'                       { LL $ getRdrName unitTyCon }
214-       | '(' commas ')'                { LL $ getRdrName (tupleTyCon Boxed $2) }
215+       | '(' commas ')'                { LL $ getRdrName (tupleTyCon Boxed ($2 + 1)) }
216        | '(#' '#)'                     { LL $ getRdrName unboxedSingletonTyCon }
217hunk ./compiler/parser/Parser.y.pp 1687
218-       | '(#' commas '#)'              { LL $ getRdrName (tupleTyCon Unboxed $2) }
219+       | '(#' commas '#)'              { LL $ getRdrName (tupleTyCon Unboxed ($2 + 1)) }
220        | '(' '->' ')'                  { LL $ getRdrName funTyCon }
221        | '[' ']'                       { LL $ listTyCon_RDR }
222        | '[:' ':]'                     { LL $ parrTyCon_RDR }
223hunk ./compiler/parser/Parser.y.pp 1896
224 
225 commas :: { Int }
226        : commas ','                    { $1 + 1 }
227-       | ','                           { 2 }
228+       | ','                           { 1 }
229 
230 -----------------------------------------------------------------------------
231 -- Documentation comments
232hunk ./compiler/parser/RdrHsSyn.lhs 17
233         mkClassDecl, mkTyData, mkTyFamily, mkTySynonym,
234         splitCon, mkInlineSpec,       
235        mkRecConstrOrUpdate, -- HsExp -> [HsFieldUpdate] -> P HsExp
236+       mkTuplish,
237 
238        cvBindGroup,
239         cvBindsAndSigs,
240hunk ./compiler/parser/RdrHsSyn.lhs 63
241 import RdrName         ( RdrName, isRdrTyVar, isRdrTc, mkUnqual, rdrNameOcc,
242                          isRdrDataCon, isUnqual, getRdrName, isQual,
243                          setRdrNameSpace, showRdrName )
244-import BasicTypes      ( maxPrecedence, Activation, RuleMatchInfo,
245+import BasicTypes      ( maxPrecedence, Boxity, Activation, RuleMatchInfo,
246                           InlinePragma(..),  InlineSpec(..),
247                           alwaysInlineSpec, neverInlineSpec )
248 import Lexer           ( P, failSpanMsgP, extension, standaloneDerivingEnabled, bangPatEnabled )
249hunk ./compiler/parser/RdrHsSyn.lhs 81
250 
251 import List            ( isSuffixOf, nubBy )
252 
253+import Data.Maybe
254+
255 #include "HsVersions.h"
256 \end{code}
257 
258hunk ./compiler/parser/RdrHsSyn.lhs 965
259                                                                 -- NOINLINE
260 mkInlineSpec (Just act) match_info inl   = Inline (InlinePragma act match_info) inl
261 
262+mkTuplish :: [Maybe (LHsExpr RdrName)] -> Boxity -> HsExpr RdrName
263+mkTuplish mb_exprs | all isJust mb_exprs = ExplicitTuple (map fromJust mb_exprs)
264+                   | otherwise           = SectionTup [placeHolderType | _ <- mb_exprs] mb_exprs
265 
266 -----------------------------------------------------------------------------
267 -- utilities for foreign declarations
268hunk ./compiler/rename/RnExpr.lhs 47
269 import List            ( nub )
270 import Util            ( isSingleton )
271 import ListSetOps      ( removeDups )
272-import Maybes          ( expectJust )
273+import Maybes          ( expectJust, fmapM_maybe )
274 import Outputable
275 import SrcLoc
276 import FastString
277hunk ./compiler/rename/RnExpr.lhs 242
278   = rnExprs exps                       `thenM` \ (exps', fvs) ->
279     return  (ExplicitPArr placeHolderType exps', fvs)
280 
281-rnExpr (ExplicitTuple exps boxity)
282+rnExpr e@(ExplicitTuple exps boxity)
283   = checkTupSize (length exps)                 `thenM_`
284hunk ./compiler/rename/RnExpr.lhs 244
285-    rnExprs exps                               `thenM` \ (exps', fvs) ->
286+    rnExprs exps                               `thenM` \ (exps', fvs) ->
287     return (ExplicitTuple exps' boxity, fvs)
288 
289hunk ./compiler/rename/RnExpr.lhs 247
290+rnExpr e@(SectionTup tys mb_exps boxity)
291+  = checkTupleSection e                         `thenM_`
292+    checkTupSize (length mb_exps)              `thenM_`
293+    mapM (fmapM_maybe rnLExpr) mb_exps         `thenM` \mb_expsfvs ->
294+    let commuteJustPair Nothing       = (Nothing, Nothing)
295+        commuteJustPair (Just (x, y)) = (Just x, Just y)
296+       
297+        (mb_exps', mb_fvs) = unzip $ map commuteJustPair mb_expsfvs
298+    in return (SectionTup tys mb_exps' boxity, plusFVs [fvs | Just fvs <- mb_fvs])
299+
300 rnExpr (RecordCon con_id _ rbinds)
301   = do { conname <- lookupLocatedOccRn con_id
302        ; (rbinds', fvRbinds) <- rnHsRecFields_Con conname rnLExpr rbinds
303hunk ./compiler/rename/RnExpr.lhs 1206
304 checkTransformStmt ctxt = addErr msg
305   where
306     msg = ptext (sLit "Illegal transform or grouping in") <+> pprStmtContext ctxt
307-   
308+
309+---------
310+checkTupleSection :: HsExpr RdrName -> RnM ()
311+checkTupleSection _
312+  = do { tuple_section <- doptM Opt_TupleSections
313+       ; checkErr tuple_section msg }
314+  where
315+    msg = ptext (sLit "Illegal tuple section: use -XTupleSections")
316+
317 ---------
318 sectionErr :: HsExpr RdrName -> SDoc
319 sectionErr expr
320hunk ./compiler/typecheck/TcExpr.lhs 283
321             ; qtys' <- mapM refineBox qtys     -- c.f. tcArgs
322             ; return (qtys', arg2') }
323     tc_args arg1_ty' _ _ _ = panic "tcExpr SectionR"
324+
325+tcExpr in_expr@(SectionTup _ mb_exprs boxity) res_ty
326+  = do { let kind = case boxity of { Boxed   -> liftedTypeKind
327+                                   ; Unboxed -> argTypeKind }
328+             arity = length mb_exprs
329+       ; tvs <- newBoxyTyVars (replicate arity kind)
330+       ; let tys        = map mkTyVarTy tvs
331+             tup_tc     = tupleTyCon boxity arity
332+             tup_res_ty = mkTyConApp tup_tc tys
333+       ; checkWiredInTyCon tup_tc       -- Ensure instances are available
334+       
335+       ; let go Nothing     ty = return (Just ty, Nothing)
336+             go (Just expr) ty = do
337+                     expr' <- tcMonoExpr expr ty
338+                     return (Nothing, Just expr')
339+       ; (mb_arg_tys, mb_exprs') <- mapAndUnzipM (uncurry go) (mb_exprs `zip` tys)
340+       
341+       ; boxyUnify ([arg_ty | Just arg_ty <- mb_arg_tys] `mkFunTys` tup_res_ty) res_ty
342+       
343+       ; return (SectionTup tys mb_exprs' boxity) }
344 \end{code}
345 
346 \begin{code}
347hunk ./compiler/typecheck/TcHsSyn.lhs 493
348     zonkLExpr env expr         `thenM` \ new_expr ->
349     returnM (SectionR new_op new_expr)
350 
351+zonkExpr env (SectionTup tys mb_exprs boxed)
352+  = zonkTcTypeToTypes env tys                   `thenM` \ new_tys ->
353+    mapM (fmapM_maybe (zonkLExpr env)) mb_exprs `thenM` \ new_mb_exprs ->
354+    returnM (SectionTup new_tys new_mb_exprs boxed)
355+
356 zonkExpr env (HsCase expr ms)
357   = zonkLExpr env expr         `thenM` \ new_expr ->
358     zonkMatchGroup env ms      `thenM` \ new_ms ->
359hunk ./compiler/utils/Maybes.lhs 13
360         MaybeErr(..), -- Instance of Monad
361         failME, isSuccess,
362 
363+        fmapM_maybe,
364         orElse,
365         mapCatMaybes,
366         allMaybes,
367hunk ./compiler/utils/Maybes.lhs 78
368 Nothing  `orElse` y = y
369 \end{code}
370 
371+\begin{code}
372+fmapM_maybe :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b)
373+fmapM_maybe _ Nothing = return Nothing
374+fmapM_maybe f (Just x) = do
375+        x' <- f x
376+        return $ Just x'
377+\end{code}
378+
379 %************************************************************************
380 %*                                                                     *
381 \subsection[MaybeT type]{The @MaybeT@ monad transformer}
382}
383[Improvements to the tuple section parser
384Max Bolingbroke <batterseapower@hotmail.com>**20090717210939
385 Ignore-this: 58618a5a21b7ab68cde92ba3eae9441f
386] {
387hunk ./compiler/parser/Parser.y.pp 1339
388         -- This allows you to write, e.g., '(+ 3, 4 -)', which isn't correct Haskell98
389         -- (you'd have to write '((+ 3), (4 -))')
390         -- but the less cluttered version fell out of having texps.
391-       | '(' texp ')'                  { LL (HsPar $2) }
392-        | '(' texp tuplesectend         { LL $ mkTuplish (Just $2 : unLoc $3) Boxed }
393-        | '(' commas texp ')'           { LL $ mkTuplish (replicate $2 Nothing ++ [Just $3]) Boxed }
394-        | '(' commas texp tuplesectend  { LL $ mkTuplish (replicate $2 Nothing ++ Just $3 : unLoc $4) Boxed }
395+        | '(' mbtexps ')'               { LL $ mkTuplish (unLoc $2) Boxed }
396+        | '(' commas mbtexps ')'        { LL $ mkTuplish (replicate $2 Nothing ++ unLoc $3) Boxed }
397        | '(#' texps '#)'               { LL $ ExplicitTuple (reverse $2) Unboxed }
398        | '[' list ']'                  { LL (unLoc $2) }
399        | '[:' parr ':]'                { LL (unLoc $2) }
400hunk ./compiler/parser/Parser.y.pp 1413
401        : texps ',' texp                { $3 : $1 }
402        | texp                          { [$1] }
403 
404-tuplesectend :: { Located [Maybe (LHsExpr RdrName)] }
405-        : commas texp tuplesectend      { sL (comb2 $2 $>) $ replicate ($1 - 1) Nothing ++ Just $2 : unLoc $3 }
406-        | commas texp ')'               { sL (comb2 $2 $>) $ replicate ($1 - 1) Nothing ++ [Just $2] }
407-        | commas ')'                    { sL (comb2 $2 $>) $ replicate $1 Nothing }
408+mbtexps :: { Located [Maybe (LHsExpr RdrName)] }
409+        : texp commas mbtexps      { LL $ Just $1 : replicate ($2 - 1) Nothing ++ unLoc $3 }
410+        | texp commas              { L1 $ Just $1 : replicate $2 Nothing }
411+        | texp                     { L1 [Just $1] }
412 
413 -----------------------------------------------------------------------------
414 -- List expressions
415hunk ./compiler/parser/RdrHsSyn.lhs 63
416 import RdrName         ( RdrName, isRdrTyVar, isRdrTc, mkUnqual, rdrNameOcc,
417                          isRdrDataCon, isUnqual, getRdrName, isQual,
418                          setRdrNameSpace, showRdrName )
419-import BasicTypes      ( maxPrecedence, Boxity, Activation, RuleMatchInfo,
420+import BasicTypes      ( maxPrecedence, Boxity(..), Activation, RuleMatchInfo,
421                           InlinePragma(..),  InlineSpec(..),
422                           alwaysInlineSpec, neverInlineSpec )
423 import Lexer           ( P, failSpanMsgP, extension, standaloneDerivingEnabled, bangPatEnabled )
424hunk ./compiler/parser/RdrHsSyn.lhs 966
425 mkInlineSpec (Just act) match_info inl   = Inline (InlinePragma act match_info) inl
426 
427 mkTuplish :: [Maybe (LHsExpr RdrName)] -> Boxity -> HsExpr RdrName
428-mkTuplish mb_exprs | all isJust mb_exprs = ExplicitTuple (map fromJust mb_exprs)
429-                   | otherwise           = SectionTup [placeHolderType | _ <- mb_exprs] mb_exprs
430+mkTuplish mb_exprs bxty
431+        | non_section, length mb_exprs == 1, bxty == Boxed = HsPar (fromJust $ head mb_exprs)
432+        | non_section                                      = ExplicitTuple (map fromJust mb_exprs) bxty
433+        | otherwise                                        = SectionTup [placeHolderType | _ <- mb_exprs] mb_exprs bxty
434+  where non_section = all isJust mb_exprs
435 
436 -----------------------------------------------------------------------------
437 -- utilities for foreign declarations
438}
439[Support unboxed tuples in tuple sections
440Max Bolingbroke <batterseapower@hotmail.com>**20090717212314
441 Ignore-this: 5534505d30a27cc53983d76c31639066
442] {
443hunk ./compiler/parser/Parser.y.pp 1341
444         -- but the less cluttered version fell out of having texps.
445         | '(' mbtexps ')'               { LL $ mkTuplish (unLoc $2) Boxed }
446         | '(' commas mbtexps ')'        { LL $ mkTuplish (replicate $2 Nothing ++ unLoc $3) Boxed }
447-       | '(#' texps '#)'               { LL $ ExplicitTuple (reverse $2) Unboxed }
448+       | '(#' mbtexps '#)'             { LL $ mkTuplish (unLoc $2) Unboxed }
449+       | '(#' commas mbtexps '#)'      { LL $ mkTuplish (replicate $2 Nothing ++ unLoc $3) Unboxed }
450        | '[' list ']'                  { LL (unLoc $2) }
451        | '[:' parr ':]'                { LL (unLoc $2) }
452        | '_'                           { L1 EWildPat }
453hunk ./compiler/parser/Parser.y.pp 1410
454        -- View patterns get parenthesized above
455        | exp '->' exp   { LL $ EViewPat $1 $3 }
456 
457-texps :: { [LHsExpr RdrName] }
458-       : texps ',' texp                { $3 : $1 }
459-       | texp                          { [$1] }
460-
461 mbtexps :: { Located [Maybe (LHsExpr RdrName)] }
462         : texp commas mbtexps      { LL $ Just $1 : replicate ($2 - 1) Nothing ++ unLoc $3 }
463         | texp commas              { L1 $ Just $1 : replicate $2 Nothing }
464}
465[Documentation for tuple sections
466Max Bolingbroke <batterseapower@hotmail.com>**20090717214031
467 Ignore-this: 88e88215e5905622464a0e5cdb813f13
468] hunk ./docs/users_guide/glasgow_exts.xml 1272
469 
470 </sect2>
471 
472+<sect2 id="tuple-sections">
473+<title>Tuple sections</title>
474+
475+<para>
476+  The <option>-XTupleSections</option> flag enables Python-style partially applied
477+  tuple constructors. For example, the following program
478+<programlisting>
479+  (, True)
480+</programlisting>
481+  is considered to be an alternative notation for the more unwieldy alternative
482+<programlisting>
483+  \x -> (x, True)
484+</programlisting>
485+You can omit any combination of arguments to the tuple, as in the following
486+<programlisting>
487+  (, "I", , , "Love", , 1337)
488+</programlisting>
489+which translates to
490+<programlisting>
491+  \a b c d -> (a, "I", b, c, "Love", d, 1337)
492+</programlisting>
493+</para>
494+
495+<para>
496+  If you have <link linkend="unboxed-tuples">unboxed tuples</link> enabled, tuple sections
497+  will also be available for them, like so
498+<programlisting>
499+  (# , True #)
500+</programlisting>
501+Because there is no unboxed unit tuple, the following expression
502+<programlisting>
503+  (# #)
504+</programlisting>
505+continues to stand for the unboxed singleton tuple data constructor.
506+</para>
507+
508+</sect2>
509+
510 <sect2 id="disambiguate-fields">
511 <title>Record field disambiguation</title>
512 <para>
513[Fix validation failure caused by tuple sections
514Max Bolingbroke <batterseapower@hotmail.com>**20090717223142
515 Ignore-this: 266893eac2eb1c3eab0b5de55d922a3f
516] hunk ./compiler/rename/RnExpr.lhs 242
517   = rnExprs exps                       `thenM` \ (exps', fvs) ->
518     return  (ExplicitPArr placeHolderType exps', fvs)
519 
520-rnExpr e@(ExplicitTuple exps boxity)
521+rnExpr (ExplicitTuple exps boxity)
522   = checkTupSize (length exps)                 `thenM_`
523     rnExprs exps                               `thenM` \ (exps', fvs) ->
524     return (ExplicitTuple exps' boxity, fvs)
525
526Context:
527
528[Fix Trac #3346: tcSimplify for LHS of RULES with type equalities
529simonpj@microsoft.com**20090717155722
530 Ignore-this: dfdd0f9a62d78d63276a4d558831099c
531]
532[Allow mixed case in the LINE pragma; patch from squadette; fixes #1817
533Ian Lynagh <igloo@earth.li>**20090717133522]
534[Comment only
535simonpj@microsoft.com**20090717120154
536 Ignore-this: f96b11e602fe4b311c1e466af9aa1908
537]
538[Add missing case for eq_note.
539t-peterj@microsoft.com**20090624134407]
540[Rename parameters to make debugging code compile.
541t-peterj@microsoft.com**20090626105440]
542[Comment fix: use the same variable names in the conclusion as in the premise.
543t-peterj@microsoft.com**20090618092235]
544[Typo fixes, from Alexey Mahotkin
545Ian Lynagh <igloo@earth.li>**20090717010817]
546[Use names like '$fOrdInt' for dfuns (and TF instances), rather than '$f21'
547Simon Marlow <marlowsd@gmail.com>**20090716125643
548 Ignore-this: d0b4632cf8ed9e05b67a19aa19ab3e19
549 
550 2 reasons for this:
551   - compilation is more predictable.  Adding or removing an instance
552     is less likely to force unnecessary recompilation due to
553     renumbering other dfun names.
554   - it makes it easier to read Core / C-- / asm
555 
556 The names aren't completely deterministic.  To do that, we'd have to
557 include package and module names, which would make the symbol names
558 long and reduce readability.  So the compromise is that if there's a
559 clash, we disambiguate by adding an integer suffix.  This is fairly
560 unlikely in practice unless you're using overlapping instances.
561 
562 Type family instances are handled in the same way, with the same
563 disambiguation strategy.
564]
565[Use a stable ordering for the export list in the interface
566Simon Marlow <marlowsd@gmail.com>**20090716122601
567 Ignore-this: 847dd7adc8b52e56f28d2478c78c925
568 The export list was ordered according to the whim of FastStrings,
569 which meant that interface fingerprints could change for no good
570 reason, causing spurious recompilation.
571]
572[Don't put all of $CFLAGS into $SRC_CC_OPTS
573Ian Lynagh <igloo@earth.li>**20090716131309
574 Instead, we just put the flags we need in there (e.g. -m64 on OS X 64).
575 This fixes a problem found by Simon M, where we were compiling
576 everything with -g, leading to a bloated RTS.
577]
578[Move showOpt into DynFlags
579Ian Lynagh <igloo@earth.li>**20090716005314]
580[Make the --info values printable with "ghc --print-foo"; trac #3122
581Ian Lynagh <igloo@earth.li>**20090716001718
582 Also, libdir is now part of the --info output, so this subsumes the old
583 --print-libdir flag.
584 The mode parsing was getting rather adhoc, so I've tidied it up a bit
585 in the process.
586]
587[whitespace only
588Simon Marlow <marlowsd@gmail.com>**20090716104217
589 Ignore-this: 38cff291d9ef15c30e3ed685ffc3c9f9
590]
591[refactor: use packageConfigId in place of mkPackageId . package
592Simon Marlow <marlowsd@gmail.com>**20090716104145
593 Ignore-this: f3d73e7bd1b307a67d26585c49f3d89f
594]
595[Fix a flag name in the docs
596Ian Lynagh <igloo@earth.li>**20090714165943]
597[Add the -fno-shared-implib flag
598Ian Lynagh <igloo@earth.li>**20090714165631
599 Patch from
600     Max Bolingbroke <batterseapower@hotmail.com>
601 Rerecorded to avoid conflicts.
602]
603[Derived Foldable instances should use Data.Foldable.foldr
604m.niloc@gmail.com**20090711130647
605 Ignore-this: e3eb841e9535a842a98bb1ae0532c6e8
606]
607[remove Solaris-specific hacks, now unnecessary
608Simon Marlow <marlowsd@gmail.com>**20090713083524
609 Ignore-this: 500077008e463532e0677ee82f5284bb
610]
611[Simplify timestamp restoration
612Matthias Kilian <kili@outback.escape.de>**20090711100244
613 Ignore-this: 7eaede224befa6b5368c91b92366211
614]
615[FIX #3272
616Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090714054559
617 Ignore-this: 225fe4d82d4eed02e9b1377687661bac
618]
619[Fix warnings
620Roman Leshchinskiy <rl@cse.unsw.edu.au>**20090713092032
621 Ignore-this: 3631b87164fc54d82e3a02875dc08f7d
622]
623[Separate length from data in DPH arrays
624Roman Leshchinskiy <rl@cse.unsw.edu.au>**20090713044212
625 Ignore-this: aa2cc3b5ae43bd2c493ce4b330c883cd
626]
627[Stop using -fno-warn-unused-do-bind when compiling the libraries
628Ian Lynagh <igloo@earth.li>**20090709160422
629 They're now fixed to not generate those warnings
630]
631[Remove maybePrefixMatch, using stripPrefix instead
632Ian Lynagh <igloo@earth.li>**20090709160412
633 We already require GHC 6.8 to build, and that included stripPrefix
634 in Data.List.
635]
636[TFs: FIX #2203 (second half)
637Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090710064834
638 Ignore-this: 46a46feaa73f74feb08524b9e7547414
639]
640[TFs: Fix should_compile/Simple8
641Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090710042728
642 Ignore-this: 471ab67e3df1c5245921be5286a45f93
643]
644[workaround new Cygwin bash CRLF behaviour
645Simon Marlow <marlowsd@gmail.com>**20090709132850
646 Ignore-this: 5cfa2cc9d776ebe315c0f6ad7ab56d98
647]
648[Use /usr/bin/test if it exists, and fix test syntax.
649Simon Marlow <marlowsd@gmail.com>**20090709124616
650 Ignore-this: 83a75ba7c3ce2a1d02bddb7bfe414bfe
651 Should fix Solaris build failures
652]
653[Allow mixed case pragmas; #1817. Patch from squadette
654Ian Lynagh <igloo@earth.li>**20090709153737
655 This patch allow you to use "Language CPP", or even "LaNgUaGe CPP",
656 if you wish, as the manual claims you can.
657]
658[don't create inplace/bin/ghc-<version>
659Simon Marlow <marlowsd@gmail.com>**20090706092031
660 Ignore-this: 2584d7bf56e77b27ca5b7b557c152c5e
661]
662[Fix ignored-monadic-result warnings
663Ian Lynagh <igloo@earth.li>**20090707181857]
664[Fix an unused import warning
665Ian Lynagh <igloo@earth.li>**20090707144706]
666[Fix unused import warnings
667Ian Lynagh <igloo@earth.li>**20090707143216]
668[Fix unused import warnings
669Ian Lynagh <igloo@earth.li>**20090707133537]
670[When exporting F(..), all the children of F are also exported
671Ian Lynagh <igloo@earth.li>**20090707133427
672 This fixes the unused imports warning when
673     Foo (F(x,y,z))
674 is imported and
675     Foo (F(..))
676 is exported.
677]
678[Remove unused imports
679Ian Lynagh <igloo@earth.li>**20090707121548]
680[Major patch to fix reporting of unused imports
681simonpj@microsoft.com**20090706112503
682 Ignore-this: 3b5ecdd880474493d73bdbdc0fa0b782
683 
684 This patch, joint work between and Ian and Simon, fixes Trac #1074
685 by reporting unused import declarations much more accuratly than
686 before.  The specification is described at
687 
688 http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/UnusedImports
689 
690 The implementation is both easier to understand than before, and shorter
691 too. 
692 
693 Also fixed are #1148, #2267
694 
695 Also fixed is -ddump-minimal imports, which now works properly, fixing
696 Trac #1792.
697 
698 
699]
700[Trim unused imports detected by new unused-import code
701simonpj@microsoft.com**20090706112201
702 Ignore-this: c6ca46d3a750c1cd1d58ea2c0de9f14f
703]
704[Avoid unnecessary recompilation after ./configure (helps #3228)
705Simon Marlow <marlowsd@gmail.com>**20090707085040
706 Ignore-this: f8b3e7a2a96bc23cd29505ab9c8dbd7d
707 We cache the old versions of files generated by configure, so that if
708 configure touches the file without changing it, we can detect that and
709 restore the timestamp.
710]
711[check for tabs in compiler/ghc.cabal.in (#3344)
712Simon Marlow <marlowsd@gmail.com>**20090707081845
713 Ignore-this: 6073db47eafd52e13e76c58ef738afcf
714]
715[remove tabs
716Simon Marlow <marlowsd@gmail.com>**20090707081823
717 Ignore-this: 3d65831fc019f76cefac03291904842a
718]
719[fix cleaning of libraries (now 'make clean' in libraries/* works again)
720Simon Marlow <marlowsd@gmail.com>**20090703114638
721 Ignore-this: b3af731d50ff5bfbd453f94aa40cb92c
722]
723[FIX #2677
724Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090707055442
725 Ignore-this: e224dd09d0d1c9ec4f3b46c7accb8d57
726]
727[Update driver/Makefile for the new build system
728Ian Lynagh <igloo@earth.li>**20090705204041]
729[Fix generational GC bug (#3348)
730Simon Marlow <marlowsd@gmail.com>**20090706112227
731 Ignore-this: 5938338efa0ad1550968c664a5a76f31
732]
733[Windows fixes to build system: use the 'find' and 'sort' found by configure
734simonpj@microsoft.com**20090706103413
735 Ignore-this: a96197917f388a637118bafefb427495
736 
737 The build system should use 'find' and 'sort' that are discovered by
738 configure, not the ones in your path.  On Windows the ones in your path
739 might well be the non-Unixy Windows versions.
740 
741 This patch fixes the ones I tripped over. There may be more.
742 
743]
744[Follow Cabal changes
745Ian Lynagh <igloo@earth.li>**20090705180414]
746[Update TODO list
747Ian Lynagh <igloo@earth.li>**20090705165009]
748[Make -fext-core a dynamic flag (it was a static flag)
749Ian Lynagh <igloo@earth.li>**20090705132420]
750[Update a few points about shared libs in other sections
751Duncan Coutts <duncan@well-typed.com>**20090704212212
752 And add links to the new shared libs section.
753]
754[Document -dynload flag. Also add it and -shared to the flags reference.
755Duncan Coutts <duncan@well-typed.com>**20090704212119]
756[Add new section on using shared libs
757Duncan Coutts <duncan@well-typed.com>**20090704212003]
758[Document foreign import prim in the user guide
759Duncan Coutts <duncan@well-typed.com>**20090704180547
760 Basically just stat that it exists and refer to the ghc dev wiki
761 for the details, because we don't really want people using it.
762]
763[For now, use -fno-warn-unused-do-bind when building the libraries
764Ian Lynagh <igloo@earth.li>**20090704210654]
765[Make changes to -fwarn-unused-do-bind and -fwarn-wrong-do-bind suggested by SPJ
766Max Bolingbroke <batterseapower@hotmail.com>**20090702150943
767 Ignore-this: 595368298d2e11623c0bd280ff89d8de
768]
769[Support for -fwarn-unused-do-bind and -fwarn-wrong-do-bind, as per #3263
770Max Bolingbroke <batterseapower@hotmail.com>**20090701200344
771 Ignore-this: 511117ffc10d4b656e530b751559b8b8
772]
773[Improved infrastructure for fast-rebuilding of parts of the tree
774Simon Marlow <marlowsd@gmail.com>**20090703074527
775 Ignore-this: ab348d0988d8bbc28c2b4babbd6bbfb8
776 
777 e.g.
778 
779   cd compiler
780   make FAST=YES stage1/build/HscTypes.o
781 
782 builds just the specified .o file, without rebuilding dependencies,
783 and omitting some of the makefile phases.  FAST=YES works anywhere, to
784 omit depenencies and phases.  'make fast' is shorthand for 'make
785 all FAST=YES'.
786]
787[Fix Trac #3342: missed zonking in TcHsSyn
788simonpj@microsoft.com**20090702124331
789 Ignore-this: 9b97b2142dfc665b503f59df7c55dd17
790 
791 The type in a ViewPat wasn't being zonked.  Easily fixed.
792 
793]
794[Type synonym families may be nullary
795Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090702084826
796 Ignore-this: bcfe6ed62c901206daf5a5088890bbea
797]
798[New syntax for GADT-style record declarations, and associated refactoring
799simonpj@microsoft.com**20090702094657
800 Ignore-this: bd9817230d3773b3b01fae3d7f04c57d
801 
802 The main purpose of this patch is to fix Trac #3306, by fleshing out the
803 syntax for GADT-style record declraations so that you have a context in
804 the type.  The new form is
805    data T a where
806      MkT :: forall a. Eq a => { x,y :: !a } -> T a
807 See discussion on the Trac ticket.
808 
809 The old form is still allowed, but give a deprecation warning.
810 
811 When we remove the old form we'll also get rid of the one reduce/reduce
812 error in the grammar. Hurrah!
813 
814 While I was at it, I failed as usual to resist the temptation to do lots of
815 refactoring.  The parsing of data/type declarations is now much simpler and
816 more uniform.  Less code, less chance of errors, and more functionality.
817 Took longer than I planned, though.
818 
819 ConDecl has record syntax, but it was not being used consistently, so I
820 pushed that through the compiler.
821 
822]
823[White space only
824simonpj@microsoft.com**20090702094627
825 Ignore-this: 19f654cbf371c8dcc6517fd4934855b4
826]
827[Comments only
828simonpj@microsoft.com**20090702094531
829 Ignore-this: 384fc2729c7c50a1680775a1f9ff89e4
830]
831[Look through Notes when matching
832simonpj@microsoft.com**20090702094444
833 Ignore-this: 7daea81e905ec6061d3e0fd588d7e61b
834]
835[FIX #3197
836Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090702070905
837 Ignore-this: ebf829f0ae025e82bccdfa4345828ffe
838]
839[Fix #2197 (properly this time)
840Simon Marlow <marlowsd@gmail.com>**20090701122354
841 Ignore-this: 39b6e4b0bcdd8c2f4660f976b7db768d
842 
843 $ ./inplace/bin/ghc-stage2 --interactive
844 GHCi, version 6.11.20090701: http://www.haskell.org/ghc/  :? for help
845 ghc-stage2: GHCi cannot be used when compiled with -prof
846 [1]    32473 exit 1     ./inplace/bin/ghc-stage2 --interactive
847]
848[make GhcProfiled work, and add a "prof" flavour to build.mk
849Simon Marlow <marlowsd@gmail.com>**20090701114211
850 Ignore-this: 386d347e4ad8b6c2bd40a2ba7da31ba6
851 
852 Building a profiled GHC is as simple as adding
853 
854 GhcLibWays += p
855 GhcProfiled = YES
856 
857 to your build.mk and saying 'make'.  Then you have a profiled
858 inplace/bin/ghc-stage2.
859]
860[remove unnecessary $(RM)s
861Simon Marlow <marlowsd@gmail.com>**20090701110609
862 Ignore-this: f326ec8931d0d484a66b67ce1270cc6e
863]
864['make html' in a library builds the Haddock docs
865Simon Marlow <marlowsd@gmail.com>**20090630111137
866 Ignore-this: 781bf10e2d4bca23b7f70c6f0465d120
867]
868[fix GC bug introduced with the C finalizer support
869Simon Marlow <marlowsd@gmail.com>**20090630080834
870 Ignore-this: 3567e3adb5ae4a5dcbce81733487f348
871]
872[Add a configure test for whether or not __mingw_vfprintf exists
873Ian Lynagh <igloo@earth.li>**20090627150501]
874[Fix #3319, and do various tidyups at the same time
875Simon Marlow <marlowsd@gmail.com>**20090626095421
876 Ignore-this: ea54175f6bd49e101d7b33392764f643
877  - converting a THSyn FFI declaration to HsDecl was broken; fixed
878  - pretty-printing of FFI declarations was variously bogus; fixed
879  - there was an unused "library" field in CImport; removed
880]
881[rename cache variable to keep recent autoconfs happy
882Ross Paterson <ross@soi.city.ac.uk>**20090626131410
883 Ignore-this: 187091bbe78f2b14402162acfb98180f
884]
885[TAG 2009-06-25
886Ian Lynagh <igloo@earth.li>**20090625155528]
887Patch bundle hash:
8887fff8869fef84913c865a9c552e6e3ddb83dbe69