Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pretty print: line up sequences of alet bindings

  • Loading branch information...
commit 5c20f02f05d0ce0811351962a4420b653ee8f5d1 1 parent 0530748
@tmcdonell tmcdonell authored
Showing with 19 additions and 6 deletions.
  1. +19 −6 Data/Array/Accelerate/Pretty/Print.hs
View
25 Data/Array/Accelerate/Pretty/Print.hs
@@ -23,8 +23,9 @@ module Data.Array.Accelerate.Pretty.Print (
) where
-- standard libraries
+import Prelude hiding ( exp )
+import Data.List
import Text.PrettyPrint
-import Prelude hiding (exp)
-- friends
import Data.Array.Accelerate.Array.Sugar
@@ -52,11 +53,23 @@ prettyPreAcc
-> PreOpenAcc acc aenv a
-> Doc
prettyPreAcc pp alvl wrap (Alet acc1 acc2)
- = wrap
- $ sep [ hang (text "let a" <> int alvl <+> char '=') 2 $
- pp alvl noParens acc1
- , text "in" <+> pp (alvl + 1) noParens acc2
- ]
+ | not (isAlet acc1') && isAlet acc2'
+ = wrap $ sep [ text "let" <+> a <+> equals <+> acc1' <+> text "in"
+ , acc2' ]
+ --
+ | otherwise
+ = wrap $ sep [ hang (text "let" <+> a <+> equals) 2 acc1'
+ , text "in" <+> acc2' ]
+ where
+ -- TLM: derp, can't unwrap into a PreOpenAcc to pattern match on Alet
+ --
+ isAlet doc = "let" `isPrefixOf` render doc
+
+ acc1' = pp alvl noParens acc1
+ acc2' = pp (alvl+1) noParens acc2
+ a = char 'a' <> int alvl
+
+
prettyPreAcc _ alvl _ (Avar idx)
= text $ 'a' : show (alvl - idxToInt idx - 1)
prettyPreAcc pp alvl wrap (Aprj ix arrs)
Please sign in to comment.
Something went wrong with that request. Please try again.