head
The first element of a non-empty structure.
>>> head (1 :| [2, 3, 4])
1
Extract the first element of the stream.
O(1) Extract the first element of a ByteString, which must be
non-empty. An exception will be thrown in the case of an empty
ByteString.
This is a partial function, consider using
uncons instead.
O(1) Extract the first element of a ByteString, which must be
non-empty.
O(1) Extract the first element of a ByteString, which must be
non-empty.
This is a partial function, consider using
uncons instead.
O(1) Extract the first element of a ShortByteString, which must
be non-empty. An exception will be thrown in the case of an empty
ShortByteString.
This is a partial function, consider using
uncons instead.
O(1) Returns the first character of a
Text, which must
be non-empty. This is a partial function, consider using
uncons
instead.
O(1) Returns the first character of a
Stream
Char, which must be non-empty. This is a partial function,
consider using
uncons.
Properties
head . stream = head
Take a single value from the stream, if available.
Take a single value from the stream, if available.
Subject to fusion
Since 0.3.0
Extract the first element of a list, which must be
non-empty.
>>> head [1, 2, 3]
1
>>> head [1..]
1
>>> head []
*** Exception: Prelude.head: empty list
WARNING: This function is partial. You can use case-matching,
uncons or
listToMaybe instead.
Combinator for the
<head> element.
Example:
head $ span $ toHtml "foo"
Result:
<head><span>foo</span></head>
Return the next byte from the stream, if available.
Since 0.3.0
Retrieve the first element from a
Producer
head xs is the first element of
xs. If
xs is empty, an
error is raised.
<math>(
1).
head obeys the law:
head xs = head (toList xs)
head xs is the first element of
xs.
<math>(
1).
head obeys the law:
head xs = head (toNonEmpty xs)
Get the first element of a container or return
Nothing if the
container is empty
Get the first byte of a byte stream or return
Nothing if the
stream is empty
Get the first element of a non-empty container
Get the first character of a text stream or return
Nothing if
the stream is empty