Allow the syntax C{} for building an unlabelled constructor C and
setting all of C's fields to bottom. The Haskell report is a bit
vague on whether this is legal, but it turns out to be quite easy to
support.
recConErr then converts its arugment string into a proper message
before printing it as
recConErr then converts its arugment string into a proper message
before printing it as
- M.lhs, line 230: missing field op1 was evaluated
+ M.lhs, line 230: Missing field in record construction op1
+We also handle C{} as valid construction syntax for an unlabelled
+constructor C, setting all of C's fields to bottom.
+
\begin{code}
dsExpr (RecordConOut data_con con_expr rbinds)
= dsExpr con_expr `thenDs` \ con_expr' ->
\begin{code}
dsExpr (RecordConOut data_con con_expr rbinds)
= dsExpr con_expr `thenDs` \ con_expr' ->
(rhs:rhss) -> ASSERT( null rhss )
dsExpr rhs
[] -> mkErrorAppDs rEC_CON_ERROR_ID arg_ty (showSDoc (ppr lbl))
(rhs:rhss) -> ASSERT( null rhss )
dsExpr rhs
[] -> mkErrorAppDs rEC_CON_ERROR_ID arg_ty (showSDoc (ppr lbl))
+ unlabelled_bottom arg_ty = mkErrorAppDs rEC_CON_ERROR_ID arg_ty ""
+
+ labels = dataConFieldLabels data_con
- mapDs mk_arg (zipEqual "dsExpr:RecordCon" arg_tys (dataConFieldLabels data_con)) `thenDs` \ con_args ->
+
+ (if null labels
+ then mapDs unlabelled_bottom arg_tys
+ else mapDs mk_arg (zipEqual "dsExpr:RecordCon" arg_tys labels))
+ `thenDs` \ con_args ->
+
returnDs (mkApps con_expr' con_args)
\end{code}
returnDs (mkApps con_expr' con_args)
\end{code}