]> hydra-www.ietfng.org Git - dyna2/commitdiff
Simplified code produced by Python codegen.
authortimv <tim.f.vieira@gmail.com>
Mon, 3 Jun 2013 01:07:53 +0000 (21:07 -0400)
committertimv <tim.f.vieira@gmail.com>
Mon, 3 Jun 2013 01:07:53 +0000 (21:07 -0400)
   for (X, Z, Value) in chart[:,Y,:,:]

is now

   for (X, _, Z, Value) in chart[:,Y,:,:]

src/Dyna/Backend/Python/Backend.hs

index 2dc3094ab3c51293dba79ab43856e7161d0a80a7..75c9da6a6f052d38922f263e97cbdf7d1235629d 100644 (file)
@@ -59,7 +59,7 @@ isFree v = nSub (v^.mv_mi) nfree
 
 builtins :: BackendPossible PyDopeBS
 builtins (f,is,o) = case () of
-  _ | all isGround is 
+  _ | all isGround is
     -> maybe (Left False) gencall $ M.lookup (f,length is) constants
         where
          gencall pc = case () of
@@ -166,7 +166,12 @@ tupledOrUnderscore vs = if length vs > 0
 
 pslice vs = brackets $
        sepBy "," (map (\x -> if nGround (x^.mv_mi) then pretty (x^.mv_var) else ":") vs)
-       <> "," -- add a list comma to ensure getitem is always passed a tuple.
+       <> "," -- add a comma to ensure getitem is always passed a tuple.
+
+piterate vs = parens $
+       sepBy "," (map (\x -> if nGround (x^.mv_mi) then "_" else pretty (x^.mv_var)) vs)
+       <> "," -- add a comma to ensure tuple.
+
 
 filterGround = map (^.mv_var) . filter (not.nGround.(^.mv_mi))
 
@@ -198,7 +203,7 @@ pdope_ (OPIter v vs f _ (Just (PDBS c))) = pretty (v^.mv_var)
 
 pdope_ (OPIter o m f _ Nothing) =
       let mo = m ++ [o] in
-          "for" <+> (tupledOrUnderscore $ filterGround mo)
+          "for" <+> piterate mo --(tupledOrUnderscore $ filterGround mo)
                 <+> "in" <+> functorIndirect "chart" f m <> pslice mo <> colon
 
     -- XXX Ought to make i and vs conditional on... doing debugging or the