readLn

The readLn function combines getLine and readIO. This operation may fail with the same errors as getLine and readIO.

Examples

>>> fmap (+ 5) readLn
> 25
30
>>> readLn :: IO String
> this is not a string literal
*** Exception: user error (Prelude.readIO: no parse)
The readLn function combines getLine and readIO.
read values from stdin, ignoring failed parses
Read values from stdin, ignoring failed parses.
>>> :set -XTypeApplications

>>> S.sum $ S.take 2 (S.readLn @IO @Int)
10<Enter>
12<Enter>
22 :> ()
>>> S.toList $ S.take 2 (S.readLn @IO @Int)
10<Enter>
1@#$%^&*\<Enter>
12<Enter>
[10,12] :> ()
The readLn function combines getLine and readIO.
Read the line the point is on