packages feed

base16-lens 0.1.1.0 → 0.1.2.0

raw patch · 7 files changed

+125/−23 lines, 7 filesdep ~base16PVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base16

API changes (from Hackage documentation)

+ Data.ByteString.Base16.Lens: _Base16Lenient :: Iso' ByteString ByteString
+ Data.ByteString.Base16.Lens: pattern Base16Lenient :: ByteString -> ByteString
+ Data.ByteString.Lazy.Base16.Lens: _Base16Lenient :: Iso' ByteString ByteString
+ Data.ByteString.Lazy.Base16.Lens: pattern Base16Lenient :: ByteString -> ByteString
+ Data.Text.Encoding.Base16.Lens: _Base16Lenient :: Iso' Text Text
+ Data.Text.Encoding.Base16.Lens: pattern Base16Lenient :: Text -> Text
+ Data.Text.Lazy.Encoding.Base16.Lens: _Base16Lenient :: Iso' Text Text
+ Data.Text.Lazy.Encoding.Base16.Lens: pattern Base16Lenient :: Text -> Text

Files

CHANGELOG.md view
@@ -1,5 +1,13 @@ # Revision history for base64-lens +## 0.1.2.0++* Add lenient isos and patterns++## 0.1.1.0++* Add lazy optics + patterns+ ## 0.1.0.0  * First version. Released on an unsuspecting world.
README.md view
@@ -11,8 +11,12 @@  ```haskell 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.@@ -25,10 +29,12 @@  ```haskell _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.
base16-lens.cabal view
@@ -1,6 +1,6 @@ cabal-version:      1.24 name:               base16-lens-version:            0.1.1.0+version:            0.1.2.0 synopsis:           Optics for the Base16 library description:        Prisms and pattern synonyms for the Base16 library homepage:           https://github.com/emilypi/base16-lens@@ -38,7 +38,7 @@    build-depends:       base        >=4.10   && <5-    , base16      >=0.1.3  && <0.2+    , base16      >=0.2.0  && <0.3     , bytestring  >=0.10   && <0.11     , lens        >=4.0    && <5     , text        >=1.2    && <1.3
src/Data/ByteString/Base16/Lens.hs view
@@ -9,16 +9,19 @@ -- Stability    : Experimental -- Portability  : non-portable ----- This module contains 'Prism''s for Base16-encoding and+-- This module contains 'Prism''s and 'Iso''s for Base16-encoding and -- decoding 'ByteString' values. -- module Data.ByteString.Base16.Lens ( -- * Prisms   _Hex , _Base16+  -- * Isos+, _Base16Lenient   -- * Patterns , pattern Hex , pattern Base16+, pattern Base16Lenient ) where  @@ -40,7 +43,7 @@ -- -------------------------------------------------------------------------- -- -- Optics --- | A 'Prism'' into the Base16 encoding of a 'ByteString' value+-- | A 'Prism'' into the Base16 encoding of a 'ByteString' value. -- -- >>> _Base16 # "Sun" -- "53756e"@@ -69,6 +72,19 @@     Right a -> Just a {-# INLINE _Hex #-} +-- | A 'Iso'' into the Base16 encoding of a leniently decoded+-- 'ByteString' value.+--+-- >>> _Base16Lenient # "Sun"+-- "53756e"+--+-- >>> "53756e" ^. _Base16Lenient+-- "Sun"+--+_Base16Lenient :: Iso' ByteString ByteString+_Base16Lenient = iso B16.decodeBase16Lenient B16.encodeBase16'+{-# INLINE _Base16Lenient #-}+ -- -------------------------------------------------------------------------- -- -- Patterns @@ -83,3 +99,10 @@ pattern Base16 :: ByteString -> ByteString pattern Base16 a <- (preview _Base16 -> Just a) where     Base16 a = _Base16 # a++-- | Bidirectional pattern synonym for leniently decoded,+-- Base16-encoded 'ByteString' values.+--+pattern Base16Lenient :: ByteString -> ByteString+pattern Base16Lenient a <- (view (from _Base16Lenient) -> a) where+    Base16Lenient a = view _Base16 a
src/Data/ByteString/Lazy/Base16/Lens.hs view
@@ -9,16 +9,19 @@ -- Stability    : Experimental -- Portability  : non-portable ----- This module contains 'Prism''s for Base16-encoding and+-- This module contains 'Prism''s and 'Iso''s for Base16-encoding and -- decoding lazy 'ByteString' values. -- module Data.ByteString.Lazy.Base16.Lens ( -- * Prisms   _Hex , _Base16+  -- * Isos+, _Base16Lenient   -- * Patterns , pattern Hex , pattern Base16+, pattern Base16Lenient ) where  @@ -40,7 +43,7 @@ -- -------------------------------------------------------------------------- -- -- Optics --- | A 'Prism'' into the Base16 encoding of a 'ByteString' value+-- | A 'Prism'' into the Base16 encoding of a 'ByteString' value. -- -- >>> _Base16 # "Sun" -- "53756e"@@ -69,6 +72,18 @@     Right a -> Just a {-# INLINE _Hex #-} +-- | A 'Iso'' into the Base16 encoding of a leniently decoded 'ByteString' value.+--+-- >>> _Base16Lenient # "Sun"+-- "53756e"+--+-- >>> "53756e" ^. _Base16+-- "Sun"+--+_Base16Lenient :: Iso' ByteString ByteString+_Base16Lenient = iso B16L.decodeBase16Lenient B16L.encodeBase16'+{-# INLINE _Base16Lenient #-}+ -- -------------------------------------------------------------------------- -- -- Patterns @@ -83,3 +98,9 @@ pattern Base16 :: ByteString -> ByteString pattern Base16 a <- (preview _Base16 -> Just a) where     Base16 a = _Base16 # a++-- | Bidirectional pattern synonym for Base16-encoded 'ByteString' values.+--+pattern Base16Lenient :: ByteString -> ByteString+pattern Base16Lenient a <- (view (from _Base16Lenient) -> a) where+    Base16Lenient a = view _Base16 a
src/Data/Text/Encoding/Base16/Lens.hs view
@@ -9,16 +9,18 @@ -- Stability    : Experimental -- Portability  : non-portable ----- This module contains 'Prism's Base16-encoding and+-- This module contains 'Prism''s and 'Iso''s Base16-encoding and -- decoding 'Text' values. -- module Data.Text.Encoding.Base16.Lens ( -- * Prisms   _Hex , _Base16+, _Base16Lenient   -- * Patterns , pattern Hex , pattern Base16+, pattern Base16Lenient ) where  import Control.Lens@@ -38,6 +40,20 @@ -- -------------------------------------------------------------------------- -- -- Optics +-- | A 'Prism'' into the Base16 encoding of a 'Text' value+--+-- >>> _Base16 # "Sun"+-- "53756e"+--+-- >>> "53756e" ^? _Base16+-- Just "Sun"+--+_Base16 :: Prism' Text Text+_Base16 = prism' B16T.encodeBase16 $ \s -> case B16T.decodeBase16 s of+    Left _ -> Nothing+    Right a -> Just a+{-# INLINE _Base16 #-}+ -- | A 'Prism'' into the Base16 encoding of a 'Text' value. This is an -- alias for '_Base16'. --@@ -53,19 +69,17 @@     Right a -> Just a {-# INLINE _Hex #-} --- | A 'Prism'' into the Base16 encoding of a 'Text' value+-- | A 'Iso'' into the Base16 encoding of a 'ByteString' value ----- >>> _Base16 # "Sun"+-- >>> _Base16Lenient # "Sun" -- "53756e" ----- >>> "53756e" ^? _Base16--- Just "Sun"+-- >>> "53756e" ^. _Base16Lenient+-- "Sun" ---_Base16 :: Prism' Text Text-_Base16 = prism' B16T.encodeBase16 $ \s -> case B16T.decodeBase16 s of-    Left _ -> Nothing-    Right a -> Just a-{-# INLINE _Base16 #-}+_Base16Lenient :: Iso' Text Text+_Base16Lenient = iso B16T.decodeBase16Lenient B16T.encodeBase16+{-# INLINE _Base16Lenient #-}  -- -------------------------------------------------------------------------- -- -- Patterns@@ -81,3 +95,10 @@ pattern Base16 :: Text -> Text pattern Base16 a <- (preview _Base16 -> Just a) where     Base16 a = _Base16 # a++-- | Bidirectional pattern synonym for leniently decoded,+-- Base16-encoded 'ByteString' values.+--+pattern Base16Lenient :: Text -> Text+pattern Base16Lenient a <- (view (from _Base16Lenient) -> a) where+    Base16Lenient a = view _Base16 a
src/Data/Text/Lazy/Encoding/Base16/Lens.hs view
@@ -9,16 +9,19 @@ -- Stability    : Experimental -- Portability  : non-portable ----- This module contains 'Prism's Base16-encoding and+-- This module contains 'Prism''s and 'Iso''s Base16-encoding and -- decoding lazy 'Text' values. -- module Data.Text.Lazy.Encoding.Base16.Lens ( -- * Prisms-  _Hex-, _Base16+  _Base16+, _Hex+  -- * Isos+, _Base16Lenient   -- * Patterns , pattern Hex , pattern Base16+, pattern Base16Lenient ) where  import Control.Lens@@ -38,7 +41,7 @@ -- -------------------------------------------------------------------------- -- -- Optics --- | A 'Prism'' into the Base16 encoding of a lazy 'Text' value+-- | A 'Prism'' into the Base16 encoding of a lazy 'Text' value. -- -- >>> _Base16 # "Sun" -- "53756e"@@ -53,7 +56,7 @@ {-# INLINE _Base16 #-}  -- | A 'Prism'' into the Base16 encoding of a lazy 'Text' value. This--- function is an alias for '_Base16'+-- function is an alias for '_Base16'. -- -- >>> _Hex # "Sun" -- "53756e"@@ -67,6 +70,19 @@     Right a -> Just a {-# INLINE _Hex #-} +-- | A 'Iso'' into the Base16 encoding of a leniently decoded+-- 'ByteString' value.+--+-- >>> _Base16Lenient # "Sun"+-- "53756e"+--+-- >>> "53756e" ^. _Base16Lenient+-- "Sun"+--+_Base16Lenient :: Iso' Text Text+_Base16Lenient = iso B16TL.decodeBase16Lenient B16TL.encodeBase16+{-# INLINE _Base16Lenient #-}+ -- -------------------------------------------------------------------------- -- -- Patterns @@ -81,3 +97,10 @@ pattern Base16 :: Text -> Text pattern Base16 a <- (preview _Base16 -> Just a) where     Base16 a = _Base16 # a++-- | Bidirectional pattern synonym for leniently decoded,+-- Base16-encoded 'ByteString' values.+--+pattern Base16Lenient :: Text -> Text+pattern Base16Lenient a <- (view (from _Base16Lenient) -> a) where+    Base16Lenient a = view _Base16 a