1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
s = ["A B C D E",
     "| | |-| |",
     "|-| | |-|",
     "| |-| |-|",
     "|-| |-| |",
     "|-| | | |"]

repl (x:' ':xs) ('|':y:ys) =
    let z:zs = repl xs ys in
    case y of
      '-' -> z:' ':x:zs
      _ -> x:' ':z:zs
repl xs _ = xs

main = putStrLn $ (unlines s) ++ foldl1 repl s