Printing patterns in Haskell Write a function Int -&gt; Char -&gt; Char -&gt; [String] that will create the appropriate pattern.
For example: mapM_ putStrLn (pattern 48 '.' '+')
................................................
.+..+..+..+..+..+..+..+..+..+..+..+..+..+..+..+.
+.++.++.++.++.++.++.++.++.++.++.++.++.++.++.++.+
................................................


This idea is inspired by Writing nested for loops to produce certain output (but more general).
I am pretty satisfied with my code to solve this problem:
pattern :: Int -&gt; Char -&gt; Char -&gt; [String]
pattern len a b = map (take len . cycle) [[a], [a, b, a], [b, a, b], [a]]

main :: IO()
main = mapM_ putStrLn (pattern 48 '.' '+')
Seems fine. However, depending on the context and the rest of the program, you can relax pattern's type:

pattern :: Int -&gt; a -&gt; a -&gt; [[a]]


Also, since every putStrLn is basically hPutStrLn stdout, you could first glue all lines together with unlines and then print them with a single action:

main = putStr (unlines (pattern 48 '.' '+'))