If you wanted to make sure it didn't have to do with ghci then you
should have compiled the original code, not tested different
functions.
Look at the sources:
Change code tomain = hSetBuffering stdin LineBuffering >> B.getLine >>= B.putStrLnand it works.