From 0b1c907528af2f843e8870e97170f87208c08822 Mon Sep 17 00:00:00 2001 From: timv Date: Mon, 10 Dec 2012 21:56:59 -0500 Subject: [PATCH] tweaks --- src/Dyna/Analysis/ANF.hs | 2 +- src/Dyna/Backend/Python.hs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Dyna/Analysis/ANF.hs b/src/Dyna/Analysis/ANF.hs index eda63ce..a8e62cc 100644 --- a/src/Dyna/Analysis/ANF.hs +++ b/src/Dyna/Analysis/ANF.hs @@ -319,7 +319,7 @@ normTerm c (t T.:~ s) = normTerm_ (ECFunctor,if c then ADEval else ADQuote) ------------------------------------------------------------------------}}} -- Normalize a Rule {{{ -data FRule = FRule { fr_functor :: DVar -- timv: rename type to FRule? +data FRule = FRule { fr_functor :: DVar , fr_aggregator :: DAgg , fr_side :: [DVar] , fr_result :: DVar diff --git a/src/Dyna/Backend/Python.hs b/src/Dyna/Backend/Python.hs index 38b02c6..a41077f 100644 --- a/src/Dyna/Backend/Python.hs +++ b/src/Dyna/Backend/Python.hs @@ -61,7 +61,7 @@ pdope (OPCheck v val) = hsep ["assert", pretty v, "==", pretty val] pdope (OPGetArgsIf vs id f) = tupled (map pretty vs) <+> equals - <+> functorIndirect "peel" f vs <> (parens $ pretty id) + <+> "peel" <> (parens $ fa f vs <> comma <> pretty id) pdope (OPBuild v vs f) = pretty v <+> equals <+> functorIndirect "build" f vs @@ -76,6 +76,8 @@ pdope (OPIter o m f) = "for" <+> (tupled $ filterBound mo) <+> "in" <+> functorIndirect "chart" f m <> pslice mo <> colon +fa f a = dquotes $ pretty f <> "/" <> (text $ show $ length a) + pslice = brackets . sepBy "," . map (\x -> case x of (MF v) -> ":" ; (MB v) -> pretty v) @@ -90,13 +92,12 @@ pf f vs = pretty f <> (tupled $ map pretty vs) -- XXX This belongs elsewhere. -- --- XXX This guy wants span information. +-- XXX This guy wants span information; he's got it now use it. -- -- timv: might want to fuse these into one circuit -- combinePlans :: [(FRule,[(DFunctAr, Maybe (Cost,Action))])] -> Either String (M.Map DFunctAr [(FRule, Cost, Action)]) -- all plans for functor/arity - -- XXX: are FDR's unique keys? suppose a rule is repeated? combinePlans = go (M.empty) where go m [] = Right m @@ -117,8 +118,6 @@ combinePlans = go (M.empty) nel (Just x) = x --- timv: consider flattening FRUle and ANFState - py (cruxf,cruxa) (FRule h _ _ r span _) dope = "@register" <> (parens $ dquotes $ pretty cruxf <> "/" <> (text $ show cruxa)) `above` "def _(_H, _V):" @@ -171,7 +170,6 @@ processFile_ fileName fh = do displayIO fh $ renderPretty 1.0 100 $ py fa r dope hPutStrLn fh "" --- hPutStrLn fh "" where headVar = "_H" -- 2.50.1