-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extra newline #37
Comments
I found the bug but I don't know how to fix it. Let me explain. printRows :: forall a . (Rows a) => Bool -> a -> IO ()
printRows b = printRows_ . repr
where printRows_ [] = return ()
printRows_ (x:xs) = do
f x
handle ioExceptionsHandler (continue xs)
f = if b then handleErrors . C8.putStrLn else C8.putStrLn
continue xs = IO.hFlush IO.stdout >> printRows_ xs
ioExceptionsHandler e = case ioe_type e of
ResourceVanished -> return ()
_ -> IO.hPrint IO.stderr e the function
Now, if the expression to be printed out is a ByteString, ghci> P.putStrLn "3\n2\n1\n"
3
2
1
> The right way to use
or as I prefer
But apparently this is misleading. A hack/solution could be to check if the last character of a ByteString is a newline and ignore it. It is a hack but, again, this bug is hardcoded in the way |
Ah! Your explanation makes perfect sense, and guides me towards a more convenient use of the tool. Let's leave the "bug" unfixed and add your explanation as an FAQ. This way, users who encounter this will look it up, and return as better hawkers. |
Or maybe alias |
I don't understand where the extra newline comes from.
In
hsl
, there was no spurious newline:Neither using
ghc -e
:> seq 3 | ghc -e 'interact (unlines . reverse . lines)
3
2
1
>
Without looking at the code, I strongly suspect a
putStrLn
where aputStr
should be.The text was updated successfully, but these errors were encountered: