I'm writing a console application that needs to prompt the user for several things. I'm using the turtle library.
My function looks like this:
askInput :: IO (Maybe Text)
askInput = do
echo "Input something: "
s <- readline
return s
But echo
is implemented using putStrLn
and as a result, will print its argument with a trailing newline.
Is there an input function in the turtle library similar to Python's raw_input
, that combines prompting followed by reading the user input?
You can import from the text
package and use many functions which aren't exported from turtle
. In this case:
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text.IO as Text
main = Text.putStr "Input something: " -- doesn't print newline