import Data.List gS (%) s =g where g (a:b:l) = s a++a%b++g (b:l); g [b]=s b e a b|a>b=" > "|a<b=" < " d a b|a>b='V'|a<b='^' c a b="\n"++i (i (zipWith d a b)) ++ "\n" i = intersperse ' ' main=interact$gS c (gS e (:[])).lines
Note that non-ascii characters in the above source code will be escaped (such as \x9f).