From: sof Date: Wed, 5 May 1999 08:31:00 +0000 (+0000) Subject: [project @ 1999-05-05 08:31:00 by sof] X-Git-Tag: Approximately_9120_patches~6259 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=5bbb0b70ca11162bd96e7e1809ba1e4340755c22;p=ghc-hetmet.git [project @ 1999-05-05 08:31:00 by sof] Allow record pattern "F{}" on any old constructor, not just with those that have labelled fields. --- diff --git a/ghc/compiler/deSugar/Match.lhs b/ghc/compiler/deSugar/Match.lhs index d9de19c..71e1749 100644 --- a/ghc/compiler/deSugar/Match.lhs +++ b/ghc/compiler/deSugar/Match.lhs @@ -460,12 +460,22 @@ tidy1 v (LazyPat pat) match_result tidy1 v (RecPat data_con pat_ty tvs dicts rpats) match_result = returnDs (ConPat data_con pat_ty tvs dicts pats, match_result) where - pats = map mk_pat tagged_arg_tys + {- + Special case to handle C{}, where C is a constructor + that hasn't got any labelled fields - the Haskell98 report + doesn't seem to make that constraint (not that I think it + should). + -- sof 5/99 + -} + pats + | null con_flabels = map (WildPat) con_arg_tys' + | otherwise = map mk_pat tagged_arg_tys -- Boring stuff to find the arg-tys of the constructor (_, inst_tys, _) = splitAlgTyConApp pat_ty con_arg_tys' = dataConArgTys data_con inst_tys - tagged_arg_tys = con_arg_tys' `zip` (dataConFieldLabels data_con) + con_flabels = dataConFieldLabels data_con + tagged_arg_tys = con_arg_tys' `zip` con_flabels -- mk_pat picks a WildPat of the appropriate type for absent fields, -- and the specified pattern for present fields