base16-lens 0.1.0.0 → 0.1.1.0
raw patch · 5 files changed
+230/−14 lines, 5 filesdep ~base16PVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base16
API changes (from Hackage documentation)
+ Data.ByteString.Base16.Lens: _Base16 :: Prism' ByteString ByteString
+ Data.ByteString.Base16.Lens: pattern Base16 :: ByteString -> ByteString
+ Data.ByteString.Lazy.Base16.Lens: _Base16 :: Prism' ByteString ByteString
+ Data.ByteString.Lazy.Base16.Lens: _Hex :: Prism' ByteString ByteString
+ Data.ByteString.Lazy.Base16.Lens: pattern Base16 :: ByteString -> ByteString
+ Data.ByteString.Lazy.Base16.Lens: pattern Hex :: ByteString -> ByteString
+ Data.Text.Encoding.Base16.Lens: _Base16 :: Prism' Text Text
+ Data.Text.Encoding.Base16.Lens: pattern Base16 :: Text -> Text
+ Data.Text.Lazy.Encoding.Base16.Lens: _Base16 :: Prism' Text Text
+ Data.Text.Lazy.Encoding.Base16.Lens: _Hex :: Prism' Text Text
+ Data.Text.Lazy.Encoding.Base16.Lens: pattern Base16 :: Text -> Text
+ Data.Text.Lazy.Encoding.Base16.Lens: pattern Hex :: Text -> Text
Files
- base16-lens.cabal +5/−3
- src/Data/ByteString/Base16/Lens.hs +28/−5
- src/Data/ByteString/Lazy/Base16/Lens.hs +85/−0
- src/Data/Text/Encoding/Base16/Lens.hs +29/−6
- src/Data/Text/Lazy/Encoding/Base16/Lens.hs +83/−0
base16-lens.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.24 name: base16-lens-version: 0.1.0.0+version: 0.1.1.0 synopsis: Optics for the Base16 library description: Prisms and pattern synonyms for the Base16 library homepage: https://github.com/emilypi/base16-lens@@ -17,7 +17,7 @@ README.md tested-with:- GHC ==8.2.2 || ==8.4.3 || ==8.4.4 || ==8.6.3 || ==8.6.5 || ==8.8.1+ GHC ==8.2.2 || ==8.4.3 || ==8.4.4 || ==8.6.3 || ==8.6.5 || ==8.8.3 source-repository head type: git@@ -32,11 +32,13 @@ library exposed-modules: Data.ByteString.Base16.Lens+ Data.ByteString.Lazy.Base16.Lens Data.Text.Encoding.Base16.Lens+ Data.Text.Lazy.Encoding.Base16.Lens build-depends: base >=4.10 && <5- , base16 >= 0.1.1 && <0.2+ , base16 >=0.1.3 && <0.2 , bytestring >=0.10 && <0.11 , lens >=4.0 && <5 , text >=1.2 && <1.3
src/Data/ByteString/Base16/Lens.hs view
@@ -2,12 +2,12 @@ {-# LANGUAGE ViewPatterns #-} -- | -- Module : Data.Text.Encoding.Base16.Lens--- Copyright : (c) 2019 Emily Pillmore--- License : BSD-style+-- Copyright : (c) 2019 Emily Pillmore+-- License : BSD-style ----- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>--- Stability : Experimental--- Portability : non-portable+-- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>+-- Stability : Experimental+-- Portability : non-portable -- -- This module contains 'Prism''s for Base16-encoding and -- decoding 'ByteString' values.@@ -15,8 +15,10 @@ module Data.ByteString.Base16.Lens ( -- * Prisms _Hex+, _Base16 -- * Patterns , pattern Hex+, pattern Base16 ) where @@ -40,6 +42,21 @@ -- | A 'Prism'' into the Base16 encoding of a 'ByteString' value --+-- >>> _Base16 # "Sun"+-- "53756e"+--+-- >>> "53756e" ^? _Base16+-- Just "Sun"+--+_Base16 :: Prism' ByteString ByteString+_Base16 = prism' B16.encodeBase16' $ \s -> case B16.decodeBase16 s of+ Left _ -> Nothing+ Right a -> Just a+{-# INLINE _Base16 #-}++-- | A 'Prism'' into the Base16 encoding of a 'ByteString' value. This is an+-- alias for '_Base16'.+-- -- >>> _Hex # "Sun" -- "53756e" --@@ -60,3 +77,9 @@ pattern Hex :: ByteString -> ByteString pattern Hex a <- (preview _Hex -> Just a) where Hex a = _Hex # a++-- | Bidirectional pattern synonym for Base16-encoded 'ByteString' values.+--+pattern Base16 :: ByteString -> ByteString+pattern Base16 a <- (preview _Base16 -> Just a) where+ Base16 a = _Base16 # a
+ src/Data/ByteString/Lazy/Base16/Lens.hs view
@@ -0,0 +1,85 @@+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE ViewPatterns #-}+-- |+-- Module : Data.Text.Encoding.Base16.Lens+-- Copyright : (c) 2019 Emily Pillmore+-- License : BSD-style+--+-- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>+-- Stability : Experimental+-- Portability : non-portable+--+-- This module contains 'Prism''s for Base16-encoding and+-- decoding lazy 'ByteString' values.+--+module Data.ByteString.Lazy.Base16.Lens+( -- * Prisms+ _Hex+, _Base16+ -- * Patterns+, pattern Hex+, pattern Base16+) where+++import Control.Lens++import Data.ByteString.Lazy (ByteString)+import qualified Data.ByteString.Lazy.Base16 as B16L+++-- $setup+--+-- >>> import Control.Lens+-- >>> import Data.ByteString.Lazy.Base16.Lens+--+-- >>> :set -XOverloadedStrings+-- >>> :set -XTypeApplications+++-- -------------------------------------------------------------------------- --+-- Optics++-- | A 'Prism'' into the Base16 encoding of a 'ByteString' value+--+-- >>> _Base16 # "Sun"+-- "53756e"+--+-- >>> "53756e" ^? _Base16+-- Just "Sun"+--+_Base16 :: Prism' ByteString ByteString+_Base16 = prism' B16L.encodeBase16' $ \s -> case B16L.decodeBase16 s of+ Left _ -> Nothing+ Right a -> Just a+{-# INLINE _Base16 #-}++-- | A 'Prism'' into the Base16 encoding of a lazy 'ByteString' value. This function+-- is an alias of '_Base16'.+--+-- >>> _Hex # "Sun"+-- "53756e"+--+-- >>> "53756e" ^? _Hex+-- Just "Sun"+--+_Hex :: Prism' ByteString ByteString+_Hex = prism' B16L.encodeBase16' $ \s -> case B16L.decodeBase16 s of+ Left _ -> Nothing+ Right a -> Just a+{-# INLINE _Hex #-}++-- -------------------------------------------------------------------------- --+-- Patterns++-- | Bidirectional pattern synonym for Base16-encoded lazy 'ByteString' values.+--+pattern Hex :: ByteString -> ByteString+pattern Hex a <- (preview _Hex -> Just a) where+ Hex a = _Hex # a++-- | Bidirectional pattern synonym for Base16-encoded lazy 'ByteString' values.+--+pattern Base16 :: ByteString -> ByteString+pattern Base16 a <- (preview _Base16 -> Just a) where+ Base16 a = _Base16 # a
src/Data/Text/Encoding/Base16/Lens.hs view
@@ -2,12 +2,12 @@ {-# LANGUAGE ViewPatterns #-} -- | -- Module : Data.Text.Encoding.Base16.Lens--- Copyright : (c) 2020 Emily Pillmore--- License : BSD-style+-- Copyright : (c) 2020 Emily Pillmore+-- License : BSD-style ----- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>--- Stability : Experimental--- Portability : non-portable+-- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>+-- Stability : Experimental+-- Portability : non-portable -- -- This module contains 'Prism's Base16-encoding and -- decoding 'Text' values.@@ -15,8 +15,10 @@ module Data.Text.Encoding.Base16.Lens ( -- * Prisms _Hex+, _Base16 -- * Patterns , pattern Hex+, pattern Base16 ) where import Control.Lens@@ -36,7 +38,8 @@ -- -------------------------------------------------------------------------- -- -- Optics --- | A 'Prism'' into the Base16 encoding of a 'Text' value+-- | A 'Prism'' into the Base16 encoding of a 'Text' value. This is an+-- alias for '_Base16'. -- -- >>> _Hex # "Sun" -- "53756e"@@ -50,6 +53,20 @@ Right a -> Just a {-# INLINE _Hex #-} +-- | 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 #-}+ -- -------------------------------------------------------------------------- -- -- Patterns @@ -58,3 +75,9 @@ pattern Hex :: Text -> Text pattern Hex a <- (preview _Hex -> Just a) where Hex a = _Hex # a++-- | Bidirectional pattern synonym for Base16-encoded 'Text' values.+--+pattern Base16 :: Text -> Text+pattern Base16 a <- (preview _Base16 -> Just a) where+ Base16 a = _Base16 # a
+ src/Data/Text/Lazy/Encoding/Base16/Lens.hs view
@@ -0,0 +1,83 @@+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE ViewPatterns #-}+-- |+-- Module : Data.Text.Encoding.Base16.Lens+-- Copyright : (c) 2020 Emily Pillmore+-- License : BSD-style+--+-- Maintainer : Emily Pillmore <emilypi@cohomolo.gy>+-- Stability : Experimental+-- Portability : non-portable+--+-- This module contains 'Prism's Base16-encoding and+-- decoding lazy 'Text' values.+--+module Data.Text.Lazy.Encoding.Base16.Lens+( -- * Prisms+ _Hex+, _Base16+ -- * Patterns+, pattern Hex+, pattern Base16+) where++import Control.Lens++import Data.Text.Lazy (Text)+import qualified Data.Text.Lazy.Encoding.Base16 as B16TL+++-- $setup+--+-- >>> import Control.Lens+-- >>> import Data.Text.Lazy.Encoding.Base16.Lens+--+-- >>> :set -XOverloadedStrings+-- >>> :set -XTypeApplications++-- -------------------------------------------------------------------------- --+-- Optics++-- | A 'Prism'' into the Base16 encoding of a lazy 'Text' value+--+-- >>> _Base16 # "Sun"+-- "53756e"+--+-- >>> "53756e" ^? _Base16+-- Just "Sun"+--+_Base16 :: Prism' Text Text+_Base16 = prism' B16TL.encodeBase16 $ \s -> case B16TL.decodeBase16 s of+ Left _ -> Nothing+ Right a -> Just a+{-# INLINE _Base16 #-}++-- | A 'Prism'' into the Base16 encoding of a lazy 'Text' value. This+-- function is an alias for '_Base16'+--+-- >>> _Hex # "Sun"+-- "53756e"+--+-- >>> "53756e" ^? _Hex+-- Just "Sun"+--+_Hex :: Prism' Text Text+_Hex = prism' B16TL.encodeBase16 $ \s -> case B16TL.decodeBase16 s of+ Left _ -> Nothing+ Right a -> Just a+{-# INLINE _Hex #-}++-- -------------------------------------------------------------------------- --+-- Patterns++-- | Bidirectional pattern synonym for Base16-encoded lazy 'Text' values.+--+pattern Hex :: Text -> Text+pattern Hex a <- (preview _Hex -> Just a) where+ Hex a = _Hex # a++-- | Bidirectional pattern synonym for Base16-encoded lazy 'Text' values.+--+pattern Base16 :: Text -> Text+pattern Base16 a <- (preview _Base16 -> Just a) where+ Base16 a = _Base16 # a