{- Improved text editing for input CSE 341 The standard getLine action doesn't handle backspace, control-w, and so forth when you are running with ghci; but it does when you use runhaskell or compile the program. If you really want editing to work when you are using ghci, here is an alternative action, getInputLine, from System.Console.Haskeline This is the same print_one_trig_fact program as in BasicInputOutput. -} module BetterInput where import System.Console.Haskeline import Data.Maybe {- return a string consisting of a number and its sin and cos -} trig_facts :: Float -> String trig_facts x = "x=" ++ show x ++ " sin(x)=" ++ show (sin x) ++ " cos(x)=" ++ show(cos x) {- prompt for one number and print the trig_facts for it -} print_one_trig_fact = do m <- runInputT defaultSettings (getInputLine "Please enter a number: ") let x = read (fromJust m) putStrLn (trig_facts x)