Skip to content
Snippets Groups Projects
Commit a0dd958a authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 1999-06-15 10:20:50 by simonmar]

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.
parent 6550e36c
No related branches found
No related tags found
No related merge requests found
......@@ -457,9 +457,12 @@ For record construction we do this (assuming T has three arguments)
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' ->
......@@ -472,8 +475,16 @@ dsExpr (RecordConOut data_con con_expr rbinds)
(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
in
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}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment