-
Notifications
You must be signed in to change notification settings - Fork 10
added modify #19
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
added modify #19
Conversation
|
I don't think we need this since |
|
yes but you have to supply the type constructor as an argument:
Personally I've never needed the |
|
Over only requires the extra argument because it can't infer what newtype you are expecting as an input. Note that you don't need to specify the return newtype. If they are both the same, you have the same inference properties as |
|
Any chance of getting this merged? The argument against it is that |
|
I personally wouldn't use this, for the same reason I use |
|
My problem with this is that it would leave this library in a sort of inconsistent state where it can't quite decide what approach it is taking. At the moment, almost all of the functions provided by this library are very general, in that they take two If we want to revisit that stance, then we should do it for the whole library, not just one function at a time, otherwise I worry that we will end up with a library which is more of a pain to use overall. For the avoidance of doubt I do think I could get behind this, as I also don't think I've ever used many of these functions in ways that made use of their full generality. |
In Slack @natefaubion suggested I could create |
Hm, I don't think I find this convincing.
It wouldn't (well, shouldn't) be a one function library, though; most of the other functions of this library also have two ala :: forall f t a s b. Functor f => Newtype t a => Newtype s b => (a -> t) -> ((b -> s) -> f t) -> f awould become ala :: forall f t a s b. Functor f => Newtype t a => (a -> t) -> ((a -> t) -> f t) -> f awhich I suspect still works for most use cases. It works for all of the examples given in the docs, at least: ala Additive foldMap [1,2,3,4] -- 10
ala Multiplicative foldMap [1,2,3,4] -- 24
ala Conj foldMap [true, false] -- false
ala Disj foldMap [true, false] -- true |
I don't agree with this at all, and I don't find either of these convincing 😄. I use |
With pattern matching you can do about all that this library does. Like @natefaubion, I use |
|
I was agreeing with Gary and Harry on this until I read Nate's comment. I think there is a place for I've also fixed the merge conflicts here. |
adds a
modifycombinator that simply unwraps the given newtype, applies a monomorphic function to it, and wraps it back in the newtype.