From 0bc61dd521c7211ba4db643036f8517bb8bb48f4 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 19 Feb 2009 15:48:58 +0100 Subject: [PATCH] Support construction of empty tuples. --- Flatten.hs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Flatten.hs b/Flatten.hs index 11738c7..1eaa0ff 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -157,13 +157,18 @@ flattenExpr binds var@(Var id) = Left sig_use -> return ([], sig_use) Right _ -> error "Higher order functions not supported." IdInfo.DataConWorkId datacon -> do - lit <- dataConToLiteral datacon - let ty = CoreUtils.exprType var - sig_id <- genSignalId SigInternal ty - -- Add a name hint to the signal - addNameHint (Name.getOccString id) sig_id - addDef (UncondDef (Right $ Literal lit) sig_id) - return ([], Single sig_id) + if DataCon.isTupleCon datacon && (null $ DataCon.dataConAllTyVars datacon) + then do + -- Empty tuple construction + return ([], Tuple []) + else do + lit <- dataConToLiteral datacon + let ty = CoreUtils.exprType var + sig_id <- genSignalId SigInternal ty + -- Add a name hint to the signal + addNameHint (Name.getOccString id) sig_id + addDef (UncondDef (Right $ Literal lit) sig_id) + return ([], Single sig_id) otherwise -> error $ "Ids other than local vars and dataconstructors not supported: " ++ (showSDoc $ ppr id) -- 2.30.2