Fri Jul 17 21:56:44 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
  * Checkpoint working implementation of tuple sections

Fri Jul 17 22:09:39 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
  * Improvements to the tuple section parser

Fri Jul 17 22:23:14 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
  * Support unboxed tuples in tuple sections

Fri Jul 17 22:40:31 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
  * Documentation for tuple sections

Fri Jul 17 23:31:42 BST 2009  Max Bolingbroke <batterseapower@hotmail.com>
  * Fix validation failure caused by tuple sections

New patches:

[Checkpoint working implementation of tuple sections
Max Bolingbroke <batterseapower@hotmail.com>**20090717205644
 Ignore-this: 50eb87a80b944f116d685b704efb5e35
] {
hunk ./compiler/deSugar/Coverage.lhs 27
 import StaticFlags
 import TyCon
 import FiniteMap
+import Maybes
 
 import Data.Array
hunk ./compiler/deSugar/Coverage.lhs 30
-import Data.Maybe
 import System.Directory ( createDirectoryIfMissing )
 
 import Trace.Hpc.Mix
hunk ./compiler/deSugar/Coverage.lhs 281
 	liftM2 SectionR
 		(addTickLHsExpr e1)
 		(addTickLHsExpr e2)
+addTickHsExpr (SectionTup tys mb_es boxity) =
+        liftM3 SectionTup
+                (return tys)
+                (mapM (fmapM_maybe addTickLHsExpr) mb_es)
+                (return boxity)
 addTickHsExpr (HsCase e mgs) = 
 	liftM2 HsCase
 		(addTickLHsExpr e) 
hunk ./compiler/deSugar/Coverage.lhs 309
 		    ListComp -> Just $ BinBox QualBinBox
 		    _        -> Nothing
 addTickHsExpr (ExplicitList ty es) = 
-	liftM2 ExplicitList 
+	liftM2 ExplicitList
 		(return ty)
 		(mapM (addTickLHsExpr) es)
 addTickHsExpr (ExplicitPArr ty es) =
hunk ./compiler/deSugar/DsExpr.lhs 264
     return (bindNonRec y_id y_core $
             Lam x_id (mkCoreAppsDs core_op [Var x_id, Var y_id]))
 
+dsExpr (SectionTup tys mb_exprs boxity) = do
+    let go (lam_vars, args) (ty, Nothing)        = do
+            -- For every missing expression, we need another lambda in the desugaring.
+            lam_var <- newSysLocalDs ty
+            return (lam_var : lam_vars, Var lam_var : args)
+        go (lam_vars, args) (_, Just expr) = do
+            -- Expressions that are present don't generate lambdas, just arguments.
+            core_expr <- dsLExpr expr
+            return (lam_vars, core_expr : args)
+    (lam_vars, args) <- foldM go ([], []) (tys `zip` mb_exprs)
+    return $ mkCoreLams (reverse lam_vars) $ mkConApp (tupleCon boxity (length mb_exprs))
+                                                      (map Type tys ++ reverse args)
+
 dsExpr (HsSCC cc expr) = do
     mod_name <- getModuleDs
     Note (SCC (mkUserCC cc mod_name)) <$> dsLExpr expr
hunk ./compiler/deSugar/DsMeta.hs 686
 repE (HsPar x)            = repLE x
 repE (SectionL x y)       = do { a <- repLE x; b <- repLE y; repSectionL a b } 
 repE (SectionR x y)       = do { a <- repLE x; b <- repLE y; repSectionR a b } 
+repE e@(SectionTup _ _ _) = notHandled "Tuple sections" (ppr e)
 repE (HsCase e (MatchGroup ms _)) = do { arg <- repLE e
 				       ; ms2 <- mapM repMatchTup ms
 				       ; repCaseE arg (nonEmptyCoreList ms2) }
hunk ./compiler/deSugar/Match.lhs 884
         --   if it seems useful (lams and lets)
         wrap _ _ = False
 
+        liftMaybe2 f (Just x) (Just y) = Just $ f x y
+        liftMaybe2 _ _        _        = Nothing
+        
         -- real comparison is on HsExpr's
         -- strip parens 
         exp (HsPar (L _ e)) e'   = exp e e'
hunk ./compiler/deSugar/Match.lhs 918
             lexp e1 e1' && lexp e2 e2'
         exp (SectionR e1 e2) (SectionR e1' e2') = 
             lexp e1 e1' && lexp e2 e2'
+        exp (SectionTup _ mb_es1 _) (SectionTup _ mb_es2 _) =
+            all ((`orElse` False) . uncurry (liftMaybe2 lexp)) (mb_es1 `zip` mb_es2)
         exp (HsIf e e1 e2) (HsIf e' e1' e2') =
             lexp e e' && lexp e1 e1' && lexp e2 e2'
         exp (ExplicitList _ ls) (ExplicitList _ ls') = lexps ls ls'
hunk ./compiler/deSugar/Match.lhs 924
         exp (ExplicitPArr _ ls) (ExplicitPArr _ ls') = lexps ls ls'
-        exp (ExplicitTuple ls _) (ExplicitTuple ls' _) = lexps ls ls'
         -- Enhancement: could implement equality for more expressions
         --   if it seems useful
         exp _ _  = False
hunk ./compiler/hsSyn/HsExpr.lhs 27
 import SrcLoc
 import Outputable
 import FastString
+import Maybes
 \end{code}
 
 
hunk ./compiler/hsSyn/HsExpr.lhs 124
                 (LHsExpr id)    -- operator
   | SectionR    (LHsExpr id)    -- operator
                 (LHsExpr id)    -- operand
+  | SectionTup  [PostTcType]         -- types of components
+                [Maybe (LHsExpr id)] -- At least one of the components is Nothing.
+                                     -- Used for the TupleSections extension:
+                                     --
+                                     -- >>> (1,,3) 2
+                                     -- (1, 2, 3)
+                Boxity
 
   | HsCase      (LHsExpr id)
                 (MatchGroup id)
hunk ./compiler/hsSyn/HsExpr.lhs 161
   | ExplicitTuple               -- tuple
                 [LHsExpr id]
                                 -- NB: Unit is ExplicitTuple []
-                                -- for tuples, we can get the types
-                                -- direct from the components
                 Boxity
 
 
hunk ./compiler/hsSyn/HsExpr.lhs 389
     pp_infixly v
       = (sep [pprHsInfix v, pp_expr])
 
+ppr_expr (SectionTup _ mb_exprs boxity)
+  = tupleParens boxity (sep (punctuate comma (map ((`orElse` empty) . fmap ppr_lexpr) mb_exprs)))
+
 --avoid using PatternSignatures for stage1 code portability
 ppr_expr exprType@(HsLam matches)
   = pprMatches (LambdaExpr `asTypeOf` idType exprType) matches
hunk ./compiler/hsSyn/HsExpr.lhs 547
       HsOverLit _          -> pp_as_was
       HsVar _              -> pp_as_was
       HsIPVar _            -> pp_as_was
+      SectionTup _ _ _     -> pp_as_was
       ExplicitList _ _     -> pp_as_was
       ExplicitPArr _ _     -> pp_as_was
       ExplicitTuple _ _    -> pp_as_was
hunk ./compiler/main/DynFlags.hs 252
    | Opt_GeneralizedNewtypeDeriving
    | Opt_RecursiveDo
    | Opt_PostfixOperators
+   | Opt_TupleSections
    | Opt_PatternGuards
    | Opt_LiberalTypeSynonyms
    | Opt_Rank2Types
hunk ./compiler/main/DynFlags.hs 1770
 xFlags = [
   ( "CPP",                              Opt_Cpp, const Supported ),
   ( "PostfixOperators",                 Opt_PostfixOperators, const Supported ),
+  ( "TupleSections",                    Opt_TupleSections, const Supported ),
   ( "PatternGuards",                    Opt_PatternGuards, const Supported ),
   ( "UnicodeSyntax",                    Opt_UnicodeSyntax, const Supported ),
   ( "MagicHash",                        Opt_MagicHash, const Supported ),
hunk ./compiler/parser/Parser.y.pp 1340
         -- (you'd have to write '((+ 3), (4 -))')
         -- but the less cluttered version fell out of having texps.
 	| '(' texp ')'			{ LL (HsPar $2) }
-	| '(' texp ',' texps ')'	{ LL $ ExplicitTuple ($2 : reverse $4) Boxed }
-	| '(#' texps '#)'		{ LL $ ExplicitTuple (reverse $2)      Unboxed }
+        | '(' texp tuplesectend         { LL $ mkTuplish (Just $2 : unLoc $3) Boxed }
+        | '(' commas texp ')'           { LL $ mkTuplish (replicate $2 Nothing ++ [Just $3]) Boxed }
+        | '(' commas texp tuplesectend  { LL $ mkTuplish (replicate $2 Nothing ++ Just $3 : unLoc $4) Boxed }
+	| '(#' texps '#)'		{ LL $ ExplicitTuple (reverse $2) Unboxed }
 	| '[' list ']'                  { LL (unLoc $2) }
 	| '[:' parr ':]'                { LL (unLoc $2) }
 	| '_'				{ L1 EWildPat }
hunk ./compiler/parser/Parser.y.pp 1415
 	: texps ',' texp		{ $3 : $1 }
 	| texp				{ [$1] }
 
+tuplesectend :: { Located [Maybe (LHsExpr RdrName)] }
+        : commas texp tuplesectend      { sL (comb2 $2 $>) $ replicate ($1 - 1) Nothing ++ Just $2 : unLoc $3 }
+        | commas texp ')'               { sL (comb2 $2 $>) $ replicate ($1 - 1) Nothing ++ [Just $2] }
+        | commas ')'                    { sL (comb2 $2 $>) $ replicate $1 Nothing }
 
 -----------------------------------------------------------------------------
 -- List expressions
hunk ./compiler/parser/Parser.y.pp 1666
 
 sysdcon	:: { Located DataCon }	-- Wired in data constructors
 	: '(' ')'		{ LL unitDataCon }
-	| '(' commas ')'	{ LL $ tupleCon Boxed $2 }
+	| '(' commas ')'	{ LL $ tupleCon Boxed ($2 + 1) }
 	| '(#' '#)'		{ LL $ unboxedSingletonDataCon }
hunk ./compiler/parser/Parser.y.pp 1668
-	| '(#' commas '#)'	{ LL $ tupleCon Unboxed $2 }
+	| '(#' commas '#)'	{ LL $ tupleCon Unboxed ($2 + 1) }
 	| '[' ']'		{ LL nilDataCon }
 
 conop :: { Located RdrName }
hunk ./compiler/parser/Parser.y.pp 1685
 gtycon 	:: { Located RdrName }	-- A "general" qualified tycon
 	: oqtycon			{ $1 }
 	| '(' ')'			{ LL $ getRdrName unitTyCon }
-	| '(' commas ')'		{ LL $ getRdrName (tupleTyCon Boxed $2) }
+	| '(' commas ')'		{ LL $ getRdrName (tupleTyCon Boxed ($2 + 1)) }
 	| '(#' '#)'			{ LL $ getRdrName unboxedSingletonTyCon }
hunk ./compiler/parser/Parser.y.pp 1687
-	| '(#' commas '#)'		{ LL $ getRdrName (tupleTyCon Unboxed $2) }
+	| '(#' commas '#)'		{ LL $ getRdrName (tupleTyCon Unboxed ($2 + 1)) }
 	| '(' '->' ')'			{ LL $ getRdrName funTyCon }
 	| '[' ']'			{ LL $ listTyCon_RDR }
 	| '[:' ':]'			{ LL $ parrTyCon_RDR }
hunk ./compiler/parser/Parser.y.pp 1896
 
 commas :: { Int }
 	: commas ','			{ $1 + 1 }
-	| ','				{ 2 }
+	| ','				{ 1 }
 
 -----------------------------------------------------------------------------
 -- Documentation comments
hunk ./compiler/parser/RdrHsSyn.lhs 17
         mkClassDecl, mkTyData, mkTyFamily, mkTySynonym,
         splitCon, mkInlineSpec,	
 	mkRecConstrOrUpdate, -- HsExp -> [HsFieldUpdate] -> P HsExp
+	mkTuplish,
 
 	cvBindGroup,
         cvBindsAndSigs,
hunk ./compiler/parser/RdrHsSyn.lhs 63
 import RdrName		( RdrName, isRdrTyVar, isRdrTc, mkUnqual, rdrNameOcc, 
 			  isRdrDataCon, isUnqual, getRdrName, isQual,
 			  setRdrNameSpace, showRdrName )
-import BasicTypes	( maxPrecedence, Activation, RuleMatchInfo,
+import BasicTypes	( maxPrecedence, Boxity, Activation, RuleMatchInfo,
                           InlinePragma(..),  InlineSpec(..),
                           alwaysInlineSpec, neverInlineSpec )
 import Lexer		( P, failSpanMsgP, extension, standaloneDerivingEnabled, bangPatEnabled )
hunk ./compiler/parser/RdrHsSyn.lhs 81
 
 import List		( isSuffixOf, nubBy )
 
+import Data.Maybe
+
 #include "HsVersions.h"
 \end{code}
 
hunk ./compiler/parser/RdrHsSyn.lhs 965
                                                                 -- NOINLINE
 mkInlineSpec (Just act) match_info inl   = Inline (InlinePragma act match_info) inl
 
+mkTuplish :: [Maybe (LHsExpr RdrName)] -> Boxity -> HsExpr RdrName
+mkTuplish mb_exprs | all isJust mb_exprs = ExplicitTuple (map fromJust mb_exprs)
+                   | otherwise           = SectionTup [placeHolderType | _ <- mb_exprs] mb_exprs
 
 -----------------------------------------------------------------------------
 -- utilities for foreign declarations
hunk ./compiler/rename/RnExpr.lhs 47
 import List		( nub )
 import Util		( isSingleton )
 import ListSetOps	( removeDups )
-import Maybes		( expectJust )
+import Maybes		( expectJust, fmapM_maybe )
 import Outputable
 import SrcLoc
 import FastString
hunk ./compiler/rename/RnExpr.lhs 242
   = rnExprs exps		 	`thenM` \ (exps', fvs) ->
     return  (ExplicitPArr placeHolderType exps', fvs)
 
-rnExpr (ExplicitTuple exps boxity)
+rnExpr e@(ExplicitTuple exps boxity)
   = checkTupSize (length exps)			`thenM_`
hunk ./compiler/rename/RnExpr.lhs 244
-    rnExprs exps	 			`thenM` \ (exps', fvs) ->
+    rnExprs exps	 		        `thenM` \ (exps', fvs) ->
     return (ExplicitTuple exps' boxity, fvs)
 
hunk ./compiler/rename/RnExpr.lhs 247
+rnExpr e@(SectionTup tys mb_exps boxity)
+  = checkTupleSection e                         `thenM_`
+    checkTupSize (length mb_exps)		`thenM_`
+    mapM (fmapM_maybe rnLExpr) mb_exps	 	`thenM` \mb_expsfvs ->
+    let commuteJustPair Nothing       = (Nothing, Nothing)
+        commuteJustPair (Just (x, y)) = (Just x, Just y)
+        
+        (mb_exps', mb_fvs) = unzip $ map commuteJustPair mb_expsfvs
+    in return (SectionTup tys mb_exps' boxity, plusFVs [fvs | Just fvs <- mb_fvs])
+
 rnExpr (RecordCon con_id _ rbinds)
   = do	{ conname <- lookupLocatedOccRn con_id
 	; (rbinds', fvRbinds) <- rnHsRecFields_Con conname rnLExpr rbinds
hunk ./compiler/rename/RnExpr.lhs 1206
 checkTransformStmt ctxt = addErr msg
   where
     msg = ptext (sLit "Illegal transform or grouping in") <+> pprStmtContext ctxt
-    
+
+---------
+checkTupleSection :: HsExpr RdrName -> RnM ()
+checkTupleSection _
+  = do	{ tuple_section <- doptM Opt_TupleSections
+	; checkErr tuple_section msg }
+  where
+    msg = ptext (sLit "Illegal tuple section: use -XTupleSections")
+
 ---------
 sectionErr :: HsExpr RdrName -> SDoc
 sectionErr expr
hunk ./compiler/typecheck/TcExpr.lhs 283
 	     ; qtys' <- mapM refineBox qtys	-- c.f. tcArgs 
 	     ; return (qtys', arg2') }
     tc_args arg1_ty' _ _ _ = panic "tcExpr SectionR"
+
+tcExpr in_expr@(SectionTup _ mb_exprs boxity) res_ty
+  = do { let kind = case boxity of { Boxed   -> liftedTypeKind
+                                   ; Unboxed -> argTypeKind }
+             arity = length mb_exprs
+       ; tvs <- newBoxyTyVars (replicate arity kind)
+       ; let tys        = map mkTyVarTy tvs
+             tup_tc     = tupleTyCon boxity arity
+             tup_res_ty = mkTyConApp tup_tc tys
+       ; checkWiredInTyCon tup_tc       -- Ensure instances are available
+       
+       ; let go Nothing     ty = return (Just ty, Nothing)
+             go (Just expr) ty = do
+                     expr' <- tcMonoExpr expr ty
+                     return (Nothing, Just expr')
+       ; (mb_arg_tys, mb_exprs') <- mapAndUnzipM (uncurry go) (mb_exprs `zip` tys)
+       
+       ; boxyUnify ([arg_ty | Just arg_ty <- mb_arg_tys] `mkFunTys` tup_res_ty) res_ty
+       
+       ; return (SectionTup tys mb_exprs' boxity) }
 \end{code}
 
 \begin{code}
hunk ./compiler/typecheck/TcHsSyn.lhs 493
     zonkLExpr env expr		`thenM` \ new_expr ->
     returnM (SectionR new_op new_expr)
 
+zonkExpr env (SectionTup tys mb_exprs boxed)
+  = zonkTcTypeToTypes env tys                   `thenM` \ new_tys ->
+    mapM (fmapM_maybe (zonkLExpr env)) mb_exprs `thenM` \ new_mb_exprs ->
+    returnM (SectionTup new_tys new_mb_exprs boxed)
+
 zonkExpr env (HsCase expr ms)
   = zonkLExpr env expr    	`thenM` \ new_expr ->
     zonkMatchGroup env ms	`thenM` \ new_ms ->
hunk ./compiler/utils/Maybes.lhs 13
         MaybeErr(..), -- Instance of Monad
         failME, isSuccess,
 
+        fmapM_maybe,
         orElse,
         mapCatMaybes,
         allMaybes,
hunk ./compiler/utils/Maybes.lhs 78
 Nothing  `orElse` y = y
 \end{code}
 
+\begin{code}
+fmapM_maybe :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b)
+fmapM_maybe _ Nothing = return Nothing
+fmapM_maybe f (Just x) = do
+        x' <- f x
+        return $ Just x'
+\end{code}
+
 %************************************************************************
 %*									*
 \subsection[MaybeT type]{The @MaybeT@ monad transformer}
}
[Improvements to the tuple section parser
Max Bolingbroke <batterseapower@hotmail.com>**20090717210939
 Ignore-this: 58618a5a21b7ab68cde92ba3eae9441f
] {
hunk ./compiler/parser/Parser.y.pp 1339
         -- This allows you to write, e.g., '(+ 3, 4 -)', which isn't correct Haskell98
         -- (you'd have to write '((+ 3), (4 -))')
         -- but the less cluttered version fell out of having texps.
-	| '(' texp ')'			{ LL (HsPar $2) }
-        | '(' texp tuplesectend         { LL $ mkTuplish (Just $2 : unLoc $3) Boxed }
-        | '(' commas texp ')'           { LL $ mkTuplish (replicate $2 Nothing ++ [Just $3]) Boxed }
-        | '(' commas texp tuplesectend  { LL $ mkTuplish (replicate $2 Nothing ++ Just $3 : unLoc $4) Boxed }
+        | '(' mbtexps ')'               { LL $ mkTuplish (unLoc $2) Boxed }
+        | '(' commas mbtexps ')'        { LL $ mkTuplish (replicate $2 Nothing ++ unLoc $3) Boxed }
 	| '(#' texps '#)'		{ LL $ ExplicitTuple (reverse $2) Unboxed }
 	| '[' list ']'                  { LL (unLoc $2) }
 	| '[:' parr ':]'                { LL (unLoc $2) }
hunk ./compiler/parser/Parser.y.pp 1413
 	: texps ',' texp		{ $3 : $1 }
 	| texp				{ [$1] }
 
-tuplesectend :: { Located [Maybe (LHsExpr RdrName)] }
-        : commas texp tuplesectend      { sL (comb2 $2 $>) $ replicate ($1 - 1) Nothing ++ Just $2 : unLoc $3 }
-        | commas texp ')'               { sL (comb2 $2 $>) $ replicate ($1 - 1) Nothing ++ [Just $2] }
-        | commas ')'                    { sL (comb2 $2 $>) $ replicate $1 Nothing }
+mbtexps :: { Located [Maybe (LHsExpr RdrName)] }
+        : texp commas mbtexps      { LL $ Just $1 : replicate ($2 - 1) Nothing ++ unLoc $3 }
+        | texp commas              { L1 $ Just $1 : replicate $2 Nothing }
+        | texp                     { L1 [Just $1] }
 
 -----------------------------------------------------------------------------
 -- List expressions
hunk ./compiler/parser/RdrHsSyn.lhs 63
 import RdrName		( RdrName, isRdrTyVar, isRdrTc, mkUnqual, rdrNameOcc, 
 			  isRdrDataCon, isUnqual, getRdrName, isQual,
 			  setRdrNameSpace, showRdrName )
-import BasicTypes	( maxPrecedence, Boxity, Activation, RuleMatchInfo,
+import BasicTypes	( maxPrecedence, Boxity(..), Activation, RuleMatchInfo,
                           InlinePragma(..),  InlineSpec(..),
                           alwaysInlineSpec, neverInlineSpec )
 import Lexer		( P, failSpanMsgP, extension, standaloneDerivingEnabled, bangPatEnabled )
hunk ./compiler/parser/RdrHsSyn.lhs 966
 mkInlineSpec (Just act) match_info inl   = Inline (InlinePragma act match_info) inl
 
 mkTuplish :: [Maybe (LHsExpr RdrName)] -> Boxity -> HsExpr RdrName
-mkTuplish mb_exprs | all isJust mb_exprs = ExplicitTuple (map fromJust mb_exprs)
-                   | otherwise           = SectionTup [placeHolderType | _ <- mb_exprs] mb_exprs
+mkTuplish mb_exprs bxty
+        | non_section, length mb_exprs == 1, bxty == Boxed = HsPar (fromJust $ head mb_exprs)
+        | non_section                                      = ExplicitTuple (map fromJust mb_exprs) bxty
+        | otherwise                                        = SectionTup [placeHolderType | _ <- mb_exprs] mb_exprs bxty
+  where non_section = all isJust mb_exprs
 
 -----------------------------------------------------------------------------
 -- utilities for foreign declarations
}
[Support unboxed tuples in tuple sections
Max Bolingbroke <batterseapower@hotmail.com>**20090717212314
 Ignore-this: 5534505d30a27cc53983d76c31639066
] {
hunk ./compiler/parser/Parser.y.pp 1341
         -- but the less cluttered version fell out of having texps.
         | '(' mbtexps ')'               { LL $ mkTuplish (unLoc $2) Boxed }
         | '(' commas mbtexps ')'        { LL $ mkTuplish (replicate $2 Nothing ++ unLoc $3) Boxed }
-	| '(#' texps '#)'		{ LL $ ExplicitTuple (reverse $2) Unboxed }
+	| '(#' mbtexps '#)'		{ LL $ mkTuplish (unLoc $2) Unboxed }
+	| '(#' commas mbtexps '#)'	{ LL $ mkTuplish (replicate $2 Nothing ++ unLoc $3) Unboxed }
 	| '[' list ']'                  { LL (unLoc $2) }
 	| '[:' parr ':]'                { LL (unLoc $2) }
 	| '_'				{ L1 EWildPat }
hunk ./compiler/parser/Parser.y.pp 1410
        -- View patterns get parenthesized above
 	| exp '->' exp   { LL $ EViewPat $1 $3 }
 
-texps :: { [LHsExpr RdrName] }
-	: texps ',' texp		{ $3 : $1 }
-	| texp				{ [$1] }
-
 mbtexps :: { Located [Maybe (LHsExpr RdrName)] }
         : texp commas mbtexps      { LL $ Just $1 : replicate ($2 - 1) Nothing ++ unLoc $3 }
         | texp commas              { L1 $ Just $1 : replicate $2 Nothing }
}
[Documentation for tuple sections
Max Bolingbroke <batterseapower@hotmail.com>**20090717214031
 Ignore-this: 88e88215e5905622464a0e5cdb813f13
] hunk ./docs/users_guide/glasgow_exts.xml 1272
 
 </sect2>
 
+<sect2 id="tuple-sections">
+<title>Tuple sections</title>
+
+<para>
+  The <option>-XTupleSections</option> flag enables Python-style partially applied
+  tuple constructors. For example, the following program
+<programlisting>
+  (, True)
+</programlisting>
+  is considered to be an alternative notation for the more unwieldy alternative
+<programlisting>
+  \x -> (x, True)
+</programlisting>
+You can omit any combination of arguments to the tuple, as in the following
+<programlisting>
+  (, "I", , , "Love", , 1337)
+</programlisting>
+which translates to
+<programlisting>
+  \a b c d -> (a, "I", b, c, "Love", d, 1337)
+</programlisting>
+</para>
+
+<para>
+  If you have <link linkend="unboxed-tuples">unboxed tuples</link> enabled, tuple sections
+  will also be available for them, like so
+<programlisting>
+  (# , True #)
+</programlisting>
+Because there is no unboxed unit tuple, the following expression
+<programlisting>
+  (# #)
+</programlisting>
+continues to stand for the unboxed singleton tuple data constructor.
+</para>
+
+</sect2>
+
 <sect2 id="disambiguate-fields">
 <title>Record field disambiguation</title>
 <para>
[Fix validation failure caused by tuple sections
Max Bolingbroke <batterseapower@hotmail.com>**20090717223142
 Ignore-this: 266893eac2eb1c3eab0b5de55d922a3f
] hunk ./compiler/rename/RnExpr.lhs 242
   = rnExprs exps		 	`thenM` \ (exps', fvs) ->
     return  (ExplicitPArr placeHolderType exps', fvs)
 
-rnExpr e@(ExplicitTuple exps boxity)
+rnExpr (ExplicitTuple exps boxity)
   = checkTupSize (length exps)			`thenM_`
     rnExprs exps	 		        `thenM` \ (exps', fvs) ->
     return (ExplicitTuple exps' boxity, fvs)

Context:

[Fix Trac #3346: tcSimplify for LHS of RULES with type equalities
simonpj@microsoft.com**20090717155722
 Ignore-this: dfdd0f9a62d78d63276a4d558831099c
] 
[Allow mixed case in the LINE pragma; patch from squadette; fixes #1817
Ian Lynagh <igloo@earth.li>**20090717133522] 
[Comment only
simonpj@microsoft.com**20090717120154
 Ignore-this: f96b11e602fe4b311c1e466af9aa1908
] 
[Add missing case for eq_note.
t-peterj@microsoft.com**20090624134407] 
[Rename parameters to make debugging code compile.
t-peterj@microsoft.com**20090626105440] 
[Comment fix: use the same variable names in the conclusion as in the premise.
t-peterj@microsoft.com**20090618092235] 
[Typo fixes, from Alexey Mahotkin
Ian Lynagh <igloo@earth.li>**20090717010817] 
[Use names like '$fOrdInt' for dfuns (and TF instances), rather than '$f21'
Simon Marlow <marlowsd@gmail.com>**20090716125643
 Ignore-this: d0b4632cf8ed9e05b67a19aa19ab3e19
 
 2 reasons for this:
   - compilation is more predictable.  Adding or removing an instance
     is less likely to force unnecessary recompilation due to
     renumbering other dfun names.
   - it makes it easier to read Core / C-- / asm
 
 The names aren't completely deterministic.  To do that, we'd have to
 include package and module names, which would make the symbol names
 long and reduce readability.  So the compromise is that if there's a
 clash, we disambiguate by adding an integer suffix.  This is fairly
 unlikely in practice unless you're using overlapping instances.
 
 Type family instances are handled in the same way, with the same
 disambiguation strategy.
] 
[Use a stable ordering for the export list in the interface
Simon Marlow <marlowsd@gmail.com>**20090716122601
 Ignore-this: 847dd7adc8b52e56f28d2478c78c925
 The export list was ordered according to the whim of FastStrings,
 which meant that interface fingerprints could change for no good
 reason, causing spurious recompilation.
] 
[Don't put all of $CFLAGS into $SRC_CC_OPTS
Ian Lynagh <igloo@earth.li>**20090716131309
 Instead, we just put the flags we need in there (e.g. -m64 on OS X 64).
 This fixes a problem found by Simon M, where we were compiling
 everything with -g, leading to a bloated RTS.
] 
[Move showOpt into DynFlags
Ian Lynagh <igloo@earth.li>**20090716005314] 
[Make the --info values printable with "ghc --print-foo"; trac #3122
Ian Lynagh <igloo@earth.li>**20090716001718
 Also, libdir is now part of the --info output, so this subsumes the old
 --print-libdir flag.
 The mode parsing was getting rather adhoc, so I've tidied it up a bit
 in the process.
] 
[whitespace only
Simon Marlow <marlowsd@gmail.com>**20090716104217
 Ignore-this: 38cff291d9ef15c30e3ed685ffc3c9f9
] 
[refactor: use packageConfigId in place of mkPackageId . package
Simon Marlow <marlowsd@gmail.com>**20090716104145
 Ignore-this: f3d73e7bd1b307a67d26585c49f3d89f
] 
[Fix a flag name in the docs
Ian Lynagh <igloo@earth.li>**20090714165943] 
[Add the -fno-shared-implib flag
Ian Lynagh <igloo@earth.li>**20090714165631
 Patch from
     Max Bolingbroke <batterseapower@hotmail.com>
 Rerecorded to avoid conflicts.
] 
[Derived Foldable instances should use Data.Foldable.foldr
m.niloc@gmail.com**20090711130647
 Ignore-this: e3eb841e9535a842a98bb1ae0532c6e8
] 
[remove Solaris-specific hacks, now unnecessary
Simon Marlow <marlowsd@gmail.com>**20090713083524
 Ignore-this: 500077008e463532e0677ee82f5284bb
] 
[Simplify timestamp restoration
Matthias Kilian <kili@outback.escape.de>**20090711100244
 Ignore-this: 7eaede224befa6b5368c91b92366211
] 
[FIX #3272
Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090714054559
 Ignore-this: 225fe4d82d4eed02e9b1377687661bac
] 
[Fix warnings
Roman Leshchinskiy <rl@cse.unsw.edu.au>**20090713092032
 Ignore-this: 3631b87164fc54d82e3a02875dc08f7d
] 
[Separate length from data in DPH arrays
Roman Leshchinskiy <rl@cse.unsw.edu.au>**20090713044212
 Ignore-this: aa2cc3b5ae43bd2c493ce4b330c883cd
] 
[Stop using -fno-warn-unused-do-bind when compiling the libraries
Ian Lynagh <igloo@earth.li>**20090709160422
 They're now fixed to not generate those warnings
] 
[Remove maybePrefixMatch, using stripPrefix instead
Ian Lynagh <igloo@earth.li>**20090709160412
 We already require GHC 6.8 to build, and that included stripPrefix
 in Data.List.
] 
[TFs: FIX #2203 (second half)
Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090710064834
 Ignore-this: 46a46feaa73f74feb08524b9e7547414
] 
[TFs: Fix should_compile/Simple8
Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090710042728
 Ignore-this: 471ab67e3df1c5245921be5286a45f93
] 
[workaround new Cygwin bash CRLF behaviour
Simon Marlow <marlowsd@gmail.com>**20090709132850
 Ignore-this: 5cfa2cc9d776ebe315c0f6ad7ab56d98
] 
[Use /usr/bin/test if it exists, and fix test syntax.
Simon Marlow <marlowsd@gmail.com>**20090709124616
 Ignore-this: 83a75ba7c3ce2a1d02bddb7bfe414bfe
 Should fix Solaris build failures
] 
[Allow mixed case pragmas; #1817. Patch from squadette
Ian Lynagh <igloo@earth.li>**20090709153737
 This patch allow you to use "Language CPP", or even "LaNgUaGe CPP",
 if you wish, as the manual claims you can.
] 
[don't create inplace/bin/ghc-<version>
Simon Marlow <marlowsd@gmail.com>**20090706092031
 Ignore-this: 2584d7bf56e77b27ca5b7b557c152c5e
] 
[Fix ignored-monadic-result warnings
Ian Lynagh <igloo@earth.li>**20090707181857] 
[Fix an unused import warning
Ian Lynagh <igloo@earth.li>**20090707144706] 
[Fix unused import warnings
Ian Lynagh <igloo@earth.li>**20090707143216] 
[Fix unused import warnings
Ian Lynagh <igloo@earth.li>**20090707133537] 
[When exporting F(..), all the children of F are also exported
Ian Lynagh <igloo@earth.li>**20090707133427
 This fixes the unused imports warning when
     Foo (F(x,y,z))
 is imported and
     Foo (F(..))
 is exported.
] 
[Remove unused imports
Ian Lynagh <igloo@earth.li>**20090707121548] 
[Major patch to fix reporting of unused imports
simonpj@microsoft.com**20090706112503
 Ignore-this: 3b5ecdd880474493d73bdbdc0fa0b782
 
 This patch, joint work between and Ian and Simon, fixes Trac #1074
 by reporting unused import declarations much more accuratly than 
 before.  The specification is described at 
 
 http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/UnusedImports
 
 The implementation is both easier to understand than before, and shorter
 too.  
 
 Also fixed are #1148, #2267
 
 Also fixed is -ddump-minimal imports, which now works properly, fixing 
 Trac #1792.
 
 
] 
[Trim unused imports detected by new unused-import code
simonpj@microsoft.com**20090706112201
 Ignore-this: c6ca46d3a750c1cd1d58ea2c0de9f14f
] 
[Avoid unnecessary recompilation after ./configure (helps #3228)
Simon Marlow <marlowsd@gmail.com>**20090707085040
 Ignore-this: f8b3e7a2a96bc23cd29505ab9c8dbd7d
 We cache the old versions of files generated by configure, so that if
 configure touches the file without changing it, we can detect that and
 restore the timestamp.
] 
[check for tabs in compiler/ghc.cabal.in (#3344)
Simon Marlow <marlowsd@gmail.com>**20090707081845
 Ignore-this: 6073db47eafd52e13e76c58ef738afcf
] 
[remove tabs
Simon Marlow <marlowsd@gmail.com>**20090707081823
 Ignore-this: 3d65831fc019f76cefac03291904842a
] 
[fix cleaning of libraries (now 'make clean' in libraries/* works again)
Simon Marlow <marlowsd@gmail.com>**20090703114638
 Ignore-this: b3af731d50ff5bfbd453f94aa40cb92c
] 
[FIX #2677
Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090707055442
 Ignore-this: e224dd09d0d1c9ec4f3b46c7accb8d57
] 
[Update driver/Makefile for the new build system
Ian Lynagh <igloo@earth.li>**20090705204041] 
[Fix generational GC bug (#3348)
Simon Marlow <marlowsd@gmail.com>**20090706112227
 Ignore-this: 5938338efa0ad1550968c664a5a76f31
] 
[Windows fixes to build system: use the 'find' and 'sort' found by configure
simonpj@microsoft.com**20090706103413
 Ignore-this: a96197917f388a637118bafefb427495
 
 The build system should use 'find' and 'sort' that are discovered by
 configure, not the ones in your path.  On Windows the ones in your path
 might well be the non-Unixy Windows versions.
 
 This patch fixes the ones I tripped over. There may be more.
 
] 
[Follow Cabal changes
Ian Lynagh <igloo@earth.li>**20090705180414] 
[Update TODO list
Ian Lynagh <igloo@earth.li>**20090705165009] 
[Make -fext-core a dynamic flag (it was a static flag)
Ian Lynagh <igloo@earth.li>**20090705132420] 
[Update a few points about shared libs in other sections
Duncan Coutts <duncan@well-typed.com>**20090704212212
 And add links to the new shared libs section.
] 
[Document -dynload flag. Also add it and -shared to the flags reference.
Duncan Coutts <duncan@well-typed.com>**20090704212119] 
[Add new section on using shared libs
Duncan Coutts <duncan@well-typed.com>**20090704212003] 
[Document foreign import prim in the user guide
Duncan Coutts <duncan@well-typed.com>**20090704180547
 Basically just stat that it exists and refer to the ghc dev wiki
 for the details, because we don't really want people using it.
] 
[For now, use -fno-warn-unused-do-bind when building the libraries
Ian Lynagh <igloo@earth.li>**20090704210654] 
[Make changes to -fwarn-unused-do-bind and -fwarn-wrong-do-bind suggested by SPJ
Max Bolingbroke <batterseapower@hotmail.com>**20090702150943
 Ignore-this: 595368298d2e11623c0bd280ff89d8de
] 
[Support for -fwarn-unused-do-bind and -fwarn-wrong-do-bind, as per #3263
Max Bolingbroke <batterseapower@hotmail.com>**20090701200344
 Ignore-this: 511117ffc10d4b656e530b751559b8b8
] 
[Improved infrastructure for fast-rebuilding of parts of the tree
Simon Marlow <marlowsd@gmail.com>**20090703074527
 Ignore-this: ab348d0988d8bbc28c2b4babbd6bbfb8
 
 e.g.
 
   cd compiler
   make FAST=YES stage1/build/HscTypes.o
 
 builds just the specified .o file, without rebuilding dependencies,
 and omitting some of the makefile phases.  FAST=YES works anywhere, to
 omit depenencies and phases.  'make fast' is shorthand for 'make
 all FAST=YES'.
] 
[Fix Trac #3342: missed zonking in TcHsSyn
simonpj@microsoft.com**20090702124331
 Ignore-this: 9b97b2142dfc665b503f59df7c55dd17
 
 The type in a ViewPat wasn't being zonked.  Easily fixed.
 
] 
[Type synonym families may be nullary
Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090702084826
 Ignore-this: bcfe6ed62c901206daf5a5088890bbea
] 
[New syntax for GADT-style record declarations, and associated refactoring
simonpj@microsoft.com**20090702094657
 Ignore-this: bd9817230d3773b3b01fae3d7f04c57d
 
 The main purpose of this patch is to fix Trac #3306, by fleshing out the
 syntax for GADT-style record declraations so that you have a context in 
 the type.  The new form is
    data T a where
      MkT :: forall a. Eq a => { x,y :: !a } -> T a
 See discussion on the Trac ticket.
 
 The old form is still allowed, but give a deprecation warning.
 
 When we remove the old form we'll also get rid of the one reduce/reduce
 error in the grammar. Hurrah!
 
 While I was at it, I failed as usual to resist the temptation to do lots of
 refactoring.  The parsing of data/type declarations is now much simpler and
 more uniform.  Less code, less chance of errors, and more functionality.
 Took longer than I planned, though.
 
 ConDecl has record syntax, but it was not being used consistently, so I
 pushed that through the compiler.
 
] 
[White space only
simonpj@microsoft.com**20090702094627
 Ignore-this: 19f654cbf371c8dcc6517fd4934855b4
] 
[Comments only
simonpj@microsoft.com**20090702094531
 Ignore-this: 384fc2729c7c50a1680775a1f9ff89e4
] 
[Look through Notes when matching
simonpj@microsoft.com**20090702094444
 Ignore-this: 7daea81e905ec6061d3e0fd588d7e61b
] 
[FIX #3197
Manuel M T Chakravarty <chak@cse.unsw.edu.au>**20090702070905
 Ignore-this: ebf829f0ae025e82bccdfa4345828ffe
] 
[Fix #2197 (properly this time)
Simon Marlow <marlowsd@gmail.com>**20090701122354
 Ignore-this: 39b6e4b0bcdd8c2f4660f976b7db768d
 
 $ ./inplace/bin/ghc-stage2 --interactive
 GHCi, version 6.11.20090701: http://www.haskell.org/ghc/  :? for help
 ghc-stage2: GHCi cannot be used when compiled with -prof
 [1]    32473 exit 1     ./inplace/bin/ghc-stage2 --interactive
] 
[make GhcProfiled work, and add a "prof" flavour to build.mk
Simon Marlow <marlowsd@gmail.com>**20090701114211
 Ignore-this: 386d347e4ad8b6c2bd40a2ba7da31ba6
 
 Building a profiled GHC is as simple as adding
 
 GhcLibWays += p
 GhcProfiled = YES
 
 to your build.mk and saying 'make'.  Then you have a profiled
 inplace/bin/ghc-stage2.
] 
[remove unnecessary $(RM)s
Simon Marlow <marlowsd@gmail.com>**20090701110609
 Ignore-this: f326ec8931d0d484a66b67ce1270cc6e
] 
['make html' in a library builds the Haddock docs
Simon Marlow <marlowsd@gmail.com>**20090630111137
 Ignore-this: 781bf10e2d4bca23b7f70c6f0465d120
] 
[fix GC bug introduced with the C finalizer support
Simon Marlow <marlowsd@gmail.com>**20090630080834
 Ignore-this: 3567e3adb5ae4a5dcbce81733487f348
] 
[Add a configure test for whether or not __mingw_vfprintf exists
Ian Lynagh <igloo@earth.li>**20090627150501] 
[Fix #3319, and do various tidyups at the same time
Simon Marlow <marlowsd@gmail.com>**20090626095421
 Ignore-this: ea54175f6bd49e101d7b33392764f643
  - converting a THSyn FFI declaration to HsDecl was broken; fixed
  - pretty-printing of FFI declarations was variously bogus; fixed
  - there was an unused "library" field in CImport; removed
] 
[rename cache variable to keep recent autoconfs happy
Ross Paterson <ross@soi.city.ac.uk>**20090626131410
 Ignore-this: 187091bbe78f2b14402162acfb98180f
] 
[TAG 2009-06-25
Ian Lynagh <igloo@earth.li>**20090625155528] 
Patch bundle hash:
7fff8869fef84913c865a9c552e6e3ddb83dbe69

