@@ -352,7 +352,13 @@ printLn x = putStrLn (show x)
352352||| Read one line of input from stdin, without the trailing newline
353353partial
354354getLine : IO' ffi String
355−getLine = prim_read
355+getLine = do x <- prim_read
356+ return (reverse (trimNL (reverse x)))
357+ where trimNL : String -> String
358+ trimNL str with (strM str)
359+ trimNL "" | StrNil = ""
360+ trimNL (strCons '\n' xs) | StrCons _ _ = xs
361+ trimNL (strCons x xs) | StrCons _ _ = strCons x xs
356362
357363||| Write a single character to stdout
358364partial
@@ -548,7 +554,5 @@ readFile fn = do h <- openFile fn Read
548554 readFile' h contents =
549555 do x <- feof h
550556 if not x then do l <- fread h
551− case contents of
552− "" => readFile' h l
553− _ => readFile' h (contents ++ "\n" ++ l)
557+ readFile' h (contents ++ l)
554558 else return contents