Skip to content

Commit

Permalink
Replace ad-hoc optics with microlens-pro
Browse files Browse the repository at this point in the history
  • Loading branch information
JackKelly-Bellroy committed Aug 20, 2024
1 parent 4b82ede commit 76a69ec
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 114 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision history for aws-arn

## 0.3.2.0 -- 2024-08-20

* Use prisms and isos from `microlens-pro`.

## 0.3.1.0 -- 2023-03-01

* Add `Network.AWS.ARN.S3` with support for S3 bucket and object ARNs.
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ add a new resource:
`test/Network/AWS/ARN/SomeAWSService/Test.hs`

4. Define a `_Foo` `Prism'` that combines the parsing/unparsing
functions above. Use the local definitions of prisms in
`Network.AWS.ARN.Internal.Lens`:
functions above:

```haskell
_Function :: Prism' Text Function
Expand Down
8 changes: 4 additions & 4 deletions aws-arn.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: aws-arn
version: 0.3.1.0
version: 0.3.2.0
synopsis:
Types and optics for manipulating Amazon Resource Names (ARNs)

Expand Down Expand Up @@ -53,15 +53,15 @@ common deps
build-depends:
, base >=4.12 && <4.21
, deriving-compat >=0.5.10 && <0.7
, microlens-pro ^>=0.2
, profunctors >=5.0 && <5.7
, tagged ^>=0.8
, text ^>=1.2.3 || >=2.0 && <2.1 || ^>=2.1
, text ^>=1.2.3 || ^>=2.0 || ^>=2.1

library
import: opts, deps
exposed-modules:
Network.AWS.ARN
Network.AWS.ARN.Internal.Lens
Network.AWS.ARN.Lambda
Network.AWS.ARN.S3

Expand All @@ -81,7 +81,7 @@ test-suite spec
ghc-options: -threaded
build-depends:
, aws-arn
, tasty >=1.4.0.2 && <1.5 || ^>=1.5
, tasty ^>=1.4.0.2 || ^>=1.5
, tasty-hunit ^>=0.10.0.3

build-tool-depends: tasty-discover:tasty-discover >=4.2.2 && <5.1
Expand Down
4 changes: 2 additions & 2 deletions src/Network/AWS/ARN.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ import Data.Ord.Deriving (deriveOrd1)
import Data.Text (Text)
import qualified Data.Text as T
import GHC.Generics (Generic, Generic1)
import Network.AWS.ARN.Internal.Lens (Iso', Prism', iso, prism')
import Lens.Micro.Pro (Iso', Prism', iso, prism')
import Text.Show.Deriving (deriveShow1)

-- $setup
-- >>> :set -XOverloadedStrings
-- >>> import Data.Function ((&))
-- >>> import Network.AWS.ARN.Internal.Lens (from, ix, (.~), (^.), (^?))
-- >>> Lens.Micro.Pro (from, ix, (.~), (^.), (^?))

-- | A parsed ARN. Either use the '_ARN' 'Prism'', or the 'parseARN' and
-- 'renderARN' functions to convert @'Text' \<-\> 'ARN'@. The
Expand Down
97 changes: 0 additions & 97 deletions src/Network/AWS/ARN/Internal/Lens.hs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Network/AWS/ARN/Lambda.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import Data.Maybe (maybeToList)
import Data.Text (Text)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Network.AWS.ARN.Internal.Lens (Prism', prism')
import Lens.Micro.Pro (Prism', prism')

-- $setup
-- >>> :set -XOverloadedStrings
-- >>> import Network.AWS.ARN.Internal.Lens ((^?))
-- >>> import Lens.Micro.Pro ((^?))

-- | An AWS Lambda function name, and optional alias/version qualifier.
--
Expand Down
4 changes: 2 additions & 2 deletions src/Network/AWS/ARN/S3.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import Data.Hashable (Hashable)
import Data.Text (Text)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Network.AWS.ARN.Internal.Lens (Prism', prism')
import Lens.Micro.Pro (Prism', prism')

-- $setup
-- >>> :set -XOverloadedStrings
-- >>> import Network.AWS.ARN.Internal.Lens ((^?))
-- >>> Lens.Micro.Pro ((^?))

-- | An AWS S3 object, made of a bucket and an object key.
--
Expand Down
2 changes: 1 addition & 1 deletion test/Network/AWS/ARN/Lambda/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Network.AWS.ARN.Lambda.Test where

import Data.Text (Text)
import Network.AWS.ARN.Internal.Lens (Lens', set, (^?))
import Lens.Micro.Pro (Lens', set, (^?))
import Network.AWS.ARN.Lambda
import Test.Tasty
import Test.Tasty.HUnit
Expand Down
6 changes: 3 additions & 3 deletions test/Network/AWS/ARN/S3/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Network.AWS.ARN.S3.Test where

import Data.Text (Text)
import Network.AWS.ARN.Internal.Lens (Lens', set, (^?))
import Lens.Micro.Pro (Lens', set, (^?))
import Network.AWS.ARN.S3
import Test.Tasty
import Test.Tasty.HUnit
Expand All @@ -28,8 +28,8 @@ test_all =
set (_Object . rObjectKey) "my/other/object" "bucket-name/my/object"
@?= "bucket-name/my/other/object"
]
]
, testGroup
],
testGroup
"S3 bucket"
[ testGroup
"parsing"
Expand Down
2 changes: 1 addition & 1 deletion test/Network/AWS/ARN/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Network.AWS.ARN.Test where

import Data.List.NonEmpty (NonEmpty (..))
import Data.Text (Text)
import Lens.Micro.Pro (Lens', over, preview, review)
import Network.AWS.ARN
import Network.AWS.ARN.Internal.Lens (Lens', over, preview, review)
import Test.Tasty
import Test.Tasty.HUnit

Expand Down

0 comments on commit 76a69ec

Please sign in to comment.