read -package:base-prelude

The read function reads input from a string, which must be completely consumed by the input process. read fails with an error if the parse is unsuccessful, and it is therefore discouraged from being used in real applications. Use readMaybe or readEither for safe alternatives.
>>> read "123" :: Int
123
>>> read "hello" :: Int
*** Exception: Prelude.read: no parse
Read up to the specified number of bytes starting from a specified offset, returning the number of bytes actually read. This function should only block if there is no data available. If there is not enough data available, then the function should just return the available data. A return value of zero indicates that the end of the data stream (e.g. end of file) has been reached.
Yield the element at the given position. Will throw an exception if the index is out of range.

Examples

>>> import qualified Data.Vector.Mutable as MV

>>> v <- MV.generate 10 (\x -> x*x)

>>> MV.read v 3
9
Yield the element at the given position. Will throw an exception if the index is out of range.

Examples

>>> import qualified Data.Vector.Mutable as MV

>>> v <- MV.generate 10 (\x -> x*x)

>>> MV.read v 3
9
Yield the element at the given position. Will throw an exception if the index is out of range.

Examples

>>> import qualified Data.Vector.Primitive.Mutable as MVP

>>> v <- MVP.generate 10 (\x -> x*x)

>>> MVP.read v 3
9
Yield the element at the given position. Will throw an exception if the index is out of range.

Examples

>>> import qualified Data.Vector.Storable.Mutable as MVS

>>> v <- MVS.generate 10 (\x -> x*x)

>>> MVS.read v 3
9
Yield the element at the given position. Will throw an exception if the index is out of range.

Examples

>>> import qualified Data.Vector.Unboxed.Mutable as MVU

>>> v <- MVU.generate 10 (\x -> x*x)

>>> MVU.read v 3
9
Parse Readable values, only forwarding the value if the parse succeeds
Reads one value from an InputStream. Returns either a value wrapped in a Just, or Nothing if the end of the stream is reached.
Make a stream of strings into a stream of parsed values, skipping bad cases
>>> S.sum_ $ S.read $ S.takeWhile (/= "total") S.stdinLn :: IO Int
1000<Enter>
2000<Enter>
total<Enter>
3000
Convert a data stream in the tar file format into an internal data structure. Decoding errors are reported by the Fail constructor of the Entries type.
  • The conversion is done lazily.
Try to read the given number of bytes from an SSL connection. On EOF an empty ByteString is returned. If the connection dies without a graceful SSL shutdown, an exception is raised. NOTE: The returned bytestring could be shorter than the size requested, see: https://www.openssl.org/docs/man3.0/man3/SSL_read.html
Get the current value of the counter.
Get the current statistical summary for the event being tracked.
Get the current value of the gauge.
Get the current value of the label.
Convert an Array into a stream. Pre-release
Read a stream from the supplied IPv4 host address and port number. Pre-release
Generate a byte stream from a socket.
>>> read = Socket.readWith defaultChunkSize
Pre-release
Deprecated: Please use reader instead
Parse Text to a value
Control.Monad.ST.runST (do arr <- new_ 10; Monad.zipWithM_ (write arr) [9,8..0] ['a'..]; read arr 3)
O(1) Yield the element at a given type-safe position using Finite.