base16-lens: Optics for the Base16 library

[ bsd3, data, library ] [ Propose Tags ]

Prisms and pattern synonyms for the Base16 library

[Skip to Readme]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,
Change log
Dependencies base (>=4.10 && <5), base16 (>=0.2.0 && <0.4), bytestring (>=0.10 && <0.11), lens (>=4.0 && <5), text (>=1.2 && <1.3) [details]
License BSD-3-Clause
Copyright (c) 2020 Emily Pillmore
Author Emily Pillmore
Revised Revision 1 made by topos at 2020-07-13T18:00:10Z
Category Data
Home page
Bug tracker
Source repo head: git clone
Uploaded by topos at 2020-03-30T03:06:53Z
Downloads 1454 total (16 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-03-30 [all 1 reports]

Readme for base16-lens-

[back to package description]


Build Status Hackage

This package provides optics and convenient pattern synonyms for the base16 library.


The pattern synonyms provided in this library are:

pattern Hex :: ByteString -> ByteString
pattern Base16 :: ByteString -> ByteString
pattern Base16Lenient :: ByteString -> ByteString
-- and
pattern Hex :: Text -> Text
pattern Base16 :: Text -> Text
pattern Base16Lenient :: Text -> Text

These provide a convenient high level interface for passing Base16 encoded values.


Prisms for encoding and decoding Text and ByteString values are given as part of the library:

_Hex :: Prism' ByteString ByteString
_Base16 :: Prism' ByteString ByteString
_Base16Lenient :: Iso' ByteString ByteString
-- and
_Hex:: Prism' Text Text
_Base16 :: Prism' Text Text
_Base16Lenient :: Iso' Text Text

If a particular structure has a Lens into some Text or ByteString value they might want to encode (or decode), then composing such a Lens with these Prisms yields an affine Traversal, resulting in a structure which has the focus of its Lens encoded as or decoded from Base16.