Safe Haskell | None |
---|---|
Language | Haskell2010 |
Binary (as opposed to textual) data is encountered in weird corners of the
Haskell ecosystem. We tend to forget (for example) that the content
recieved from a web server is not text until we convert it from UTF-8 (if
that's what it is); and of course that glosses over the fact that something
of content-type image/jpeg
is not text in any way, shape, or form.
Bytes also show up when working with crypto algorithms, taking hashes, and when doing serialization to external binary formats. Although we frequently display these in terminals (and in URLs!) as text, but we take for granted that we have actually deserialized the data or rendered the it in hexidecimal or base64 or...
This module presents a simple wrapper around various representations of binary data to make it easier to interoperate with libraries supplying or consuming bytes.
Documentation
A block of data in binary form.
Instances
Eq Bytes Source # | |
Ord Bytes Source # | |
Show Bytes Source # | |
Generic Bytes Source # | |
Hashable Bytes Source # | |
Defined in Core.Text.Bytes | |
Render Bytes Source # | |
Key Bytes Source # | |
Defined in Core.Data.Structures | |
type Rep Bytes Source # | |
Defined in Core.Text.Bytes type Rep Bytes = D1 (MetaData "Bytes" "Core.Text.Bytes" "unbeliever-0.7.3.0-3b0ma8uLQlp9wydwBiHNN0" False) (C1 (MetaCons "StrictBytes" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 ByteString))) | |
type Token Bytes Source # | |
Defined in Core.Text.Bytes |
Conversion to and from various types containing binary data into our convenience Bytes type.
As often as not these conversions are expensive; these methods are here just to wrap calling the relevant functions in a uniform interface.
Instances
Binary ByteString Source # | from Data.ByteString.Lazy |
Defined in Core.Text.Bytes fromBytes :: Bytes -> ByteString Source # intoBytes :: ByteString -> Bytes Source # | |
Binary ByteString Source # | from Data.ByteString Strict |
Defined in Core.Text.Bytes fromBytes :: Bytes -> ByteString Source # intoBytes :: ByteString -> Bytes Source # | |
Binary [Word8] Source # | from Data.Word |
hOutput :: Handle -> Bytes -> IO () Source #
Output the content of the Bytes
to the specified Handle
.
hOutput h b
output
provides a convenient way to write a Bytes
to a file or socket handle from within the Program
monad.
Don't use this function to write to stdout
if you are using any of the
other output or logging facililities of this libarary as you will corrupt
the ordering of output on the user's terminal. Instead do:
write (intoRope b)
on the assumption that the bytes in question are UTF-8 (or plain ASCII) encoded.