I am trying to produce an interactive Haskell program using the interact
function with map
.
Here's what I get in ghci (as far as I can tell, that's the way all tutorials explain interact
usage -- except the result).
*Module> interact $ unlines . map (++ "!") . lines
tteesstt
!
Note that what actually happens is that every character I type is instantly repeated and after I press Return the exclamation mark appears. I was, however, expecting this:
*Module> interact $ unlines . map (++ "!") . lines
test
test!
It works perfectly if I use the same program structure, but filter
instead of map
.