-
Notifications
You must be signed in to change notification settings - Fork 71
[WIP] Conversion to microlens
#78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- This was a reduction I made to clean up code, but I'm changing it back, as I'm going to attempt to have this merged into `wreq` proper before I bother forking it.
Unless I am mistaken, this will break every existing user of wreq? |
It's a drop-in replacement. Elaboration: I'm currently converting |
Just discovered: the former |
@fosskers How are you going to deal with Also,
I don't think they would – lens is a strict superset of microlens. They might want to (in order to get rid of the lens dependency), but they wouldn't have to. |
Oh, I see, you used |
Here are the dependencies we still get rid of by switching from lens to microlens+contravariant:
I think adding a contravariant dependency to wreq would be better than spreading fake folds around. |
@fosskers FYI, since microlens-0.3.5 |
Thanks @neongreen. We'd need |
What is wrong with the |
This is type Fold s a =
forall f. (Contravariant f, Applicative f) => (a -> f a) -> s -> f s This is type Fold s a = forall r. Applicative (Const r) => Getting r s a
-- equivalent to
type Fold s a =
forall r. Applicative (Const r) => (a -> Const r a) -> s -> Const r s We can't put a > [1..5] ^.. backwards folded
[5,4,3,2,1] > [1..5] ^.. backwards Lens.Micro.folded
<interactive>:
Couldn't match type ‘Control.Applicative.Backwards.Backwards
(Const (Data.Monoid.Endo [t])) t’
with ‘Const r0 t’
Expected type: Optical
(->)
(->)
(Control.Applicative.Backwards.Backwards
(Const (Data.Monoid.Endo [t])))
[t]
[t]
t
t
Actual type: Lens.Micro.Type.Getting r0 [t] t Actually, it's so unsettling that I'm probably going to remove |
I'm going to cross that bridge once |
Even if the test suite doesn't fail, there still might be code in the wild that would refuse to compile once you switch |
If the user was doing something very |
With the advent of |
I wouldn't call
They already diverged when The reason
I went for 1) because I think it's less painful than the rest. I also just pushed another microlens library that depends on contravariant and has true |
@fosskers if executable size is your main concern, have you tried compiling Aura and dependencies with |
@reiddraper Most of my users prefer a standalone binary of |
@neongreen In using |
Yep, sure. However, people who use wreq shouldn't care about whether wreq uses lens or microlens – and if you suddenly change exported folds to |
I agree. |
@fosskers you will get a full binary, just as you would w/out split objects. It will just be much smaller in size. As a tradeoff, compilation is slower. |
@reiddraper Oh? Slower compilation I can deal with, since I'm footing that time on my side so that my users don't have to. |
@neongreen Just took a look at |
- Although not all of them pass. Not the fault of `microlens`.
- As opposed to the "fake" `Fold` as provided in earlier versions.
This now uses the true |
@bos , this is ready. Note that I haven't attempted to fix the 3 test failures, as those should be a different PR and don't strictly have anything to do with |
Any word, @bos ? |
I am -1 on this. I think it gives little value to the average user of Wreq. At least from my perspective, one of the core ideas of Wreq was to use Lens, so I don't avoiding a Lens dependency is a big deal to most Wreq users. @fosskers did you end up compiling |
Maybe not to most, but to this I haven't, as I use |
@bos Please let me know if you don't intend on merging this, and I'll make a fork. However, I do believe that keeping |
Something to note: Since lenses are just type aliases, and |
@fosskers Did you ever create a full-fledged fork of the project? |
I didn't no - I use |
…rpreter`) As it stands, we also need changes to `entropy`, but I'll manage that separately. Hopefully by reviving haskell#78. Note that the custom setup is only used for `cabal-doctest`, so we really can just safely remove it. This is essentially the same issue as cdepillabout/pretty-simple#82. Seeing as all the TH is just for `makeLenses`, in an ideal world we really ought to just be able to run on the host: see ghc-proposals/ghc-proposals#243. The changes to the two `.hs` files are from dumping the TH splices (and manually (well, with _some_ help from HLS) adding a load of qualified imports). The splices can be found in `dist-newstyle` after adding this to `cabal.project`: ``` package wreq ghc-options: -ddump-splices -dth-dec-file ```
Motivation
General
lens
is a very heavy dependency. This PR moveswreq
off oflens
and ontomicrolens
, a performant subset oflens
which has few dependencies and covers many use cases.Specific
aura
(a package manager) usesaur
which useswreq
to access the Arch Linux AUR api.aura
's executable size would be significantly reduced if the fulllens
dependency were removed.@bos , please let me know if you have no intention of merging this, and I will fork the project.
TODO
lens
lens-aeson
-> microlens-aesonmicrolens
andmicrolens-contra