Skip to content

Commit fbc91ee

Browse files
authored
Merge pull request #996 from mankyKitty/sc/change-lens-dep-to-microlens
Remove chonky Lens and replace with microlens for smaller footprint.
2 parents 30b200d + 567292c commit fbc91ee

File tree

202 files changed

+1366
-1311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+1366
-1311
lines changed

.ormolu

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Amazonka.Prelude exports Control.Applicative
2+
module Amazonka.Prelude exports Control.Monad
3+
module Amazonka.Prelude exports Data.Function
4+
module Amazonka.Prelude exports Data.Functor
5+
module Amazonka.Prelude exports Data.List.NonEmpty
6+
module Amazonka.Prelude exports Lens.Micro
7+
module Amazonka.Prelude exports Lens.Micro.Pro
8+
module Amazonka.Prelude exports Prelude
9+
module Gen.Prelude exports Control.Applicative
10+
module Gen.Prelude exports Control.Comonad
11+
module Gen.Prelude exports Control.Comonad.Cofree
12+
module Gen.Prelude exports Control.Monad
13+
module Gen.Prelude exports Data.Functor
14+
module Gen.Prelude exports Data.Function
15+
module Gen.Prelude exports Prelude
16+
module Gen.Prelude exports System.FilePath

configs/services/s3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"libraryName": "amazonka-s3",
3-
"extraDependencies": ["text", "lens"],
3+
"extraDependencies": ["text"],
44
"operationPlugins": {
55
"DeleteObjects": ["Request.contentMD5Header", "Request.s3vhost"],
66
"GetBucketLocation": [],

flake.lock

Lines changed: 19 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
{
22
inputs = {
3-
nixpkgs = {
4-
url = "github:nixos/nixpkgs/nixpkgs-unstable";
5-
};
6-
7-
flake-utils = {
8-
url = "github:numtide/flake-utils";
9-
};
3+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4+
flake-utils.url = "github:numtide/flake-utils";
105

116
pre-commit-hooks = {
127
url = "github:cachix/pre-commit-hooks.nix";
138
inputs.nixpkgs.follows = "nixpkgs";
14-
inputs.flake-utils.follows = "flake-utils";
159
};
1610

1711
botocore = {
@@ -103,10 +97,22 @@
10397
ghc92.developPackage {
10498
root = ./gen;
10599
overrides = _hsFinal: hsPrev: with pkgs.haskell.lib; {
106-
ede = dontCheck (dontHaddock hsPrev.ede);
100+
data-fix = doJailbreak hsPrev.data-fix;
101+
ede = dontCheck (hsPrev.callHackageDirect
102+
{
103+
pkg = "ede";
104+
ver = "0.3.4.0";
105+
sha256 = "sha256-bEYTVnVj/TigHgGiiMP/Yz3YE1gg2QYPCPrx6RrpSOo=";
106+
}
107+
{ });
107108
hashable = hsPrev.callHackage "hashable" "1.3.5.0" { };
108109
pandoc = dontHaddock hsPrev.pandoc;
110+
semialign = doJailbreak hsPrev.semialign;
109111
string-qq = dontCheck hsPrev.string-qq;
112+
text-short = doJailbreak hsPrev.text-short;
113+
these = doJailbreak hsPrev.these;
114+
unordered-containers =
115+
hsPrev.callHackage "unordered-containers" "0.2.19.1" { };
110116
};
111117
};
112118

lib/amazonka-core/amazonka-core.cabal

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ common base
3232
-fwarn-unused-packages
3333

3434
default-extensions:
35-
NoImplicitPrelude
3635
ConstraintKinds
3736
DataKinds
3837
DefaultSignatures
@@ -50,6 +49,7 @@ common base
5049
GeneralizedNewtypeDeriving
5150
LambdaCase
5251
NamedFieldPuns
52+
NoImplicitPrelude
5353
OverloadedStrings
5454
PackageImports
5555
PatternSynonyms
@@ -102,21 +102,23 @@ library
102102
Amazonka.Waiter
103103

104104
build-depends:
105-
, aeson ^>=1.5.0.0 || >=2.0 && <2.2 || ^>=2.2
105+
, aeson ^>=1.5.0.0 || ^>=2.0 || ^>=2.1 || ^>=2.2
106106
, attoparsec >=0.11.3
107107
, bytestring >=0.10.8
108108
, case-insensitive >=1.2
109109
, conduit >=1.3
110110
, conduit-extra >=1.3
111-
, containers >=0.5 && <0.7
112-
, crypton >=0.32 && <0.35 || ^>=1.0.0
111+
, containers >=0.5 && <0.7
112+
, crypton >=0.32 && <0.35 || ^>=1.0.0
113113
, deepseq >=1.4
114114
, hashable >=1.2
115-
, http-client >=0.5 && <0.8
116-
, http-conduit >=2.3 && <3
115+
, http-client >=0.5 && <0.8
116+
, http-conduit >=2.3 && <3
117117
, http-types >=0.12
118-
, lens >=4.14
119118
, memory >=0.6
119+
, microlens ^>=0.4.13.1
120+
, microlens-contra ^>=0.1.0.3
121+
, microlens-pro ^>=0.2.0
120122
, regex-posix >=0.96
121123
, resourcet >=1.1
122124
, scientific >=0.3

lib/amazonka-core/src/Amazonka/Core/Lens/Internal.hs

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,29 @@
88
--
99
-- Re-export a number of lens types and combinators for use in service
1010
-- bindings.
11-
module Amazonka.Core.Lens.Internal (module Export) where
12-
13-
import Control.Exception.Lens as Export
14-
( catching,
15-
catching_,
16-
exception,
17-
throwingM,
18-
trying,
19-
_IOException,
11+
module Amazonka.Core.Lens.Internal
12+
( concatOf,
13+
folding,
14+
to,
15+
module Export,
2016
)
21-
import Control.Lens as Export
22-
( AReview,
23-
Choice,
24-
Fold,
25-
Getter,
17+
where
18+
19+
import Lens.Micro as Export
20+
( ASetter,
21+
ASetter',
2622
Getting,
27-
IndexedTraversal',
28-
Iso',
2923
Lens,
3024
Lens',
31-
Optic',
32-
Prism',
33-
Setter',
34-
Traversal',
35-
allOf,
36-
anyOf,
37-
coerced,
38-
concatOf,
25+
SimpleFold,
26+
SimpleGetter,
3927
filtered,
40-
folding,
4128
has,
42-
iso,
4329
lens,
44-
mapping,
4530
non,
46-
prism,
4731
sets,
48-
to,
32+
toListOf,
4933
traversed,
50-
un,
51-
view,
52-
(#),
5334
(%~),
5435
(.~),
5536
(<&>),
@@ -63,3 +44,47 @@ import Control.Lens as Export
6344
_Just,
6445
_last,
6546
)
47+
import qualified Lens.Micro as Lens
48+
import Lens.Micro.Contra as Export
49+
( Fold,
50+
Getter,
51+
fromSimpleFold,
52+
fromSimpleGetter,
53+
)
54+
import Lens.Micro.Extras as Export
55+
( view,
56+
)
57+
import Lens.Micro.Internal as Export
58+
( foldMapOf,
59+
(#.),
60+
)
61+
import Lens.Micro.Pro as Export
62+
( AReview,
63+
Iso',
64+
LensLike',
65+
Prism',
66+
Traversal',
67+
coerced,
68+
iso,
69+
mapping,
70+
preview,
71+
prism,
72+
prism',
73+
review,
74+
(#),
75+
)
76+
import Prelude (Foldable, ($))
77+
78+
-- | 'concatOf' is 'view', with a type signature to make it obvious
79+
-- that it concatenates all focused lists.
80+
concatOf :: Getting [r] s [r] -> s -> [r]
81+
concatOf = view
82+
{-# INLINE concatOf #-}
83+
84+
folding :: (Foldable f) => (s -> f a) -> Fold s a
85+
folding f = fromSimpleFold $ Lens.folding f
86+
{-# INLINE folding #-}
87+
88+
to :: (s -> a) -> Getter s a
89+
to f = fromSimpleGetter $ Lens.to f
90+
{-# INLINE to #-}

lib/amazonka-core/src/Amazonka/Error.hs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-- Portability : non-portable (GHC extensions)
88
module Amazonka.Error where
99

10-
import Amazonka.Core.Lens.Internal (Choice, Fold, Optic', filtered)
10+
import Amazonka.Core.Lens.Internal (Fold, LensLike', filtered)
1111
import Amazonka.Data
1212
import Amazonka.Prelude
1313
import Amazonka.Types
@@ -40,7 +40,7 @@ import Network.HTTP.Types.Status (Status (..))
4040
-- >>> :t trying _NoSuchBucketPolicy
4141
-- MonadCatch m => m a -> m (Either ServiceError a)
4242
_MatchServiceError ::
43-
AsError a =>
43+
(AsError a) =>
4444
Service ->
4545
ErrorCode ->
4646
Fold a ServiceError
@@ -49,7 +49,7 @@ _MatchServiceError s c = _ServiceError . hasService s . hasCode c
4949
statusSuccess :: Status -> Bool
5050
statusSuccess (statusCode -> n) = n >= 200 && n < 300 || n == 304
5151

52-
_HttpStatus :: AsError a => Traversal' a Status
52+
_HttpStatus :: (AsError a) => Traversal' a Status
5353
_HttpStatus = _Error . f
5454
where
5555
f g = \case
@@ -67,21 +67,21 @@ _HttpStatus = _Error . f
6767
(\x -> ServiceError (e {status = x})) <$> g status
6868

6969
hasService ::
70-
(Applicative f, Choice p) =>
70+
(Applicative f) =>
7171
Service ->
72-
Optic' p f ServiceError ServiceError
72+
LensLike' f ServiceError ServiceError
7373
hasService Service {abbrev} = filtered ((abbrev ==) . ServiceError.abbrev)
7474

7575
hasStatus ::
76-
(Applicative f, Choice p) =>
76+
(Applicative f) =>
7777
Int ->
78-
Optic' p f ServiceError ServiceError
78+
LensLike' f ServiceError ServiceError
7979
hasStatus n = filtered ((n ==) . fromEnum . ServiceError.status)
8080

8181
hasCode ::
82-
(Applicative f, Choice p) =>
82+
(Applicative f) =>
8383
ErrorCode ->
84-
Optic' p f ServiceError ServiceError
84+
LensLike' f ServiceError ServiceError
8585
hasCode c = filtered ((c ==) . ServiceError.code)
8686

8787
serviceError ::
@@ -134,9 +134,7 @@ parseJSONError a s h bs =
134134
msg c o =
135135
if c == Just "RequestEntityTooLarge"
136136
then pure (Just "Request body must be less than 1 MB")
137-
else
138-
Just <$> o .: "message"
139-
<|> o .:? "Message"
137+
else Just <$> o .: "message" <|> o .:? "Message"
140138

141139
parseXMLError ::
142140
Abbrev ->

0 commit comments

Comments
 (0)