-
Notifications
You must be signed in to change notification settings - Fork 40
(WIP) A mess of new concepts #45
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
base: master
Are you sure you want to change the base?
Conversation
|
Idea: |
|
Nope: the correct linear rank-1 form of a lens is |
78ccfa9 to
e6d2834
Compare
|
note to self: try having both |
e6d2834 to
95814ce
Compare
95814ce to
dad3c10
Compare
|
@Divesh-Otwani Apologies for leaving this (and other branches) in such a state. Feel free to get in touch with me if you'd like some help tidying it up or just a better idea of what was going through my head with some of the stuff I left unfinished! |
|
@b-mehta Thanks -- will get in touch! |
|
For most of the things introduced here, see #79 . Which covers the same ground except:
I'm not convinced the getters with I'm leaving the PR open, still, as an inspiration as I'm trying to tackle the traversal story. See also #190 (and soon more). |
WIP:
Changes introduced:
Prelude.Traversable tin whichor
Data.Traversable tin whichSo, there should be two notions of a
Traversal, and there must be two versions of theWanderingtype class. Here, due to lack of imagination, they are prefixedPandD.More linearity for
getandset. Naturally, these two cannot be linear as usually written:getdiscards part of its argument, andsetthrows away the old information. However they can be given type signatures which reflect these facts and are stronger than just non-linear arrows.Setting is easy to deal with: we can just return the original value that was replaced, then running
sndafterwards recovers the non-linearset. The idea is thatset'can have a type signature that promises more, but degrades nicely to the standard one.Getting is a little more complex: We define a 'wastebasket' of resources,
Top, which has the property thatforall x. x ->. Topis inhabited (uniquely). It thus forms a (linear) monoid.The use of
Tophere is that arrowsa ->. (Top, b)are something of an intermediate betweena ->. banda -> b; they promise thatais not used more than once, but can't promise that all ofais used. For example, we can define(a,b) ->. (Top, b), which gets the second component and 'throws away' the first component. Again, if the extra linearity promise isn't helpful, post-composing withsndwill recover the usualget.(Aside: the writer monad writing to
Tophas its Kleisli arrows as the above arrows, so we can nicely compose these functions: maybe there is some use to a promise that the argument is used no more than once)To write: the
lensconstructor and a deconstructor?Pair. Wrapped semigroups