{- ######################################################################## module ReadLine calls the readline function in the GNU readline library. (This can also be done in GHC but (a) it's not in GHC 4.02; (b) it's not in Hugs; (c) it's a good exercise for Green Card. ####################################################################### -} module ReadLine(readLine) where import StdDIS import Addr %#include "readline.h" %#include "stdlib.h" %fun readline :: String -> IO Addr -- readline routine itself readLine :: String -> IO String readLine prompt = do addr <- readline prompt if addr == nullAddr then ioError(userError "Cannot read from terminal") else return () res <- unmarshall_string_ addr free addr return res