encode

Efficiently serialize a JSON value as a lazy ByteString. This is implemented in terms of the ToJSON class's toEncoding method.
Encode a value using binary serialisation to a lazy ByteString.
Encode a Haskell String to a list of Word8 values, in UTF8 format.
Encode a value using binary serialization to a strict ByteString.
Encode a string into base64 form. The result will always be a multiple of 4 bytes in length.
Encode a string into base64url form. The result will always be a multiple of 4 bytes in length.
Encode a value into its YAML representation.
Convert text into bytes, using the provided codec. If the codec is not capable of representing an input character, an exception will be thrown. Since 0.3.0
Encode a ByteString value in base16 (i.e. hexadecimal). Encoded values will always have a length that is a multiple of 2.

Examples:

encode "foo"  == "666f6f"
Efficiently serialize CSV records as a lazy ByteString.
Efficiently serialize records in an incremental fashion. Equivalent to encodeWith defaultEncodeOptions.
Convert a FilePath to a platform‐specific format, suitable for use with external OS functions. Note: The type platformTextFormat can change depending upon the underlying compilation platform. Consider using toText or encodeString instead. See Rules for more information. Since: 0.3
Convert a FilePath to a platform‐specific format, suitable for use with external OS functions. Note: The type of platformTextFormat can change depending upon the underlying compilation platform. Consider using toText or encodeString instead. See Rules for more information. Since: 0.3
Encode a Haskell value into a string, in JSON format. This is a superset of JSON, as types other than Array and Object are allowed at the top level.
Definition for encoding a given type into a binary representation, using the Encoding Monoid.
Definition for encoding a given type into a binary representation, using the Encoding Monoid.
Encode an IP as Text.
>>> encode (ipv4 10 0 0 25)
"10.0.0.25"
>>> encode (ipv6 0x3124 0x0 0x0 0xDEAD 0xCAFE 0xFF 0xFE00 0x1)
"3124::dead:cafe:ff:fe00:1"
Encode an IPv4 address to Text using dot-decimal notation:
>>> T.putStrLn (IPv4.encode (IPv4.ipv4 192 168 2 47))
192.168.2.47
Encodes the IPv6 address using zero-compression on the leftmost longest string of zeroes in the address. Per RFC 5952 Section 5, this uses mixed notation when encoding an IPv4-mapped IPv6 address:
>>> T.putStrLn $ IPv6.encode $ IPv6.fromWord16s 0xDEAD 0xBEEF 0x0 0x0 0x0 0x0 0x0 0x1234
dead:beef::1234

>>> T.putStrLn $ IPv6.encode $ IPv6.fromWord16s 0x0 0x0 0x0 0x0 0x0 0xFFFF 0x6437 0xA5B4
::ffff:100.55.165.180

>>> T.putStrLn $ IPv6.encode $ IPv6.fromWord16s 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
::
Per Section 4.2.2 of the same RFC, this does not use :: to shorten a single 16-bit 0 field. Only runs of multiple 0 fields are considered.
Encode a Mac address using the default MacCodec defCodec.
>>> T.putStrLn (Mac.encode (Mac 0xA47F247AB423))
a4:7f:24:7a:b4:23
URI encode a String, unicode aware.
Serializes a value to a ByteString. In order to do this, it first allocates a ByteString of the correct size (based on size), and then uses poke to fill it. Safety of this function depends on correctness of the Store instance. If size returns a. The good news is that this isn't an issue if you use well-tested manual instances (such as those from this package) combined with auomatic definition of instances.
Convert data type to the textual representation of TOML values.
Serialize YAML Node(s) using the YAML 1.2 Core schema to a lazy UTF8 encoded ByteString. Each YAML Node produces exactly one YAML Document. Here is an example of encoding a list of strings to produce a list of YAML Documents
>>> encode (["Document 1", "Document 2"] :: [Text])
"Document 1\n...\nDocument 2\n"
If we treat the above list of strings as a single sequence then we will produce a single YAML Document having a single sequence.
>>> encode ([["Document 1", "Document 2"]] :: [[Text]])
"- Document 1\n- Document 2\n"
Alternatively, if you only need a single YAML document in a YAML stream you might want to use the convenience function encode1; or, if you need more control over the encoding, see encodeNode'.