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

Please add `apply` and `pure` to Json.Decode #416

Closed
jasonzoladz opened this Issue Sep 29, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@jasonzoladz

jasonzoladz commented Sep 29, 2015

It would be nice to have pure and apply defined in Json.Decode, as it seems way more natural than object6. (And it saves the boilerplate of defining them every time.)

I assume (perhaps wrongly?) that they have not been included due to accessibility concerns. (Obviously, you need not discuss Applicatives.) Since the language supports partial application and ADTs, isn't the pedagogy simply:

"pure takes a function/value and puts it a box. apply takes a function in a box, and a value in a box, and returns a value in a box." What am I missing?

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 29, 2015

Member

The equivalent of pure already exists and is called succeed. I felt that the name pure actively misleads people about what is happening.

Adding the equivalent of apply is planned. In the meantime, these are the guidelines for adding stuff like this and I suspect there's already a *-extras package out there that has it.

Furthermore, it should be pretty easy to define in terms of andThen.

andMap : Decoder (a -> b) -> Decoder a -> Decoder b
andMap decodeFunc decodeValue =
    decodeFunc `andThen` \func -> decodeVaue `andThen` \value -> succeed (func value)
Member

evancz commented Sep 29, 2015

The equivalent of pure already exists and is called succeed. I felt that the name pure actively misleads people about what is happening.

Adding the equivalent of apply is planned. In the meantime, these are the guidelines for adding stuff like this and I suspect there's already a *-extras package out there that has it.

Furthermore, it should be pretty easy to define in terms of andThen.

andMap : Decoder (a -> b) -> Decoder a -> Decoder b
andMap decodeFunc decodeValue =
    decodeFunc `andThen` \func -> decodeVaue `andThen` \value -> succeed (func value)

@evancz evancz closed this Sep 29, 2015

@jasonzoladz

This comment has been minimized.

Show comment
Hide comment
@jasonzoladz

jasonzoladz Sep 29, 2015

I know that it's easily defined:
apply = object2 (<|)

My point was that it's a foundational primitive that is trivial to add to the library.

jasonzoladz commented Sep 29, 2015

I know that it's easily defined:
apply = object2 (<|)

My point was that it's a foundational primitive that is trivial to add to the library.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 29, 2015

Member

Adding the equivalent of apply is planned. In the meantime...

It is very hard to respond to the volume of API suggestions for core in a piecemeal way. Adding 100 trivial things to core is not a trivial thing, especially if you care about how all those things work together conceptually across all the different packages. Adding something like apply is planned. It wasn't in the first version, but many folks have wanted it since then. So it's in the plan to add it.

Member

evancz commented Sep 29, 2015

Adding the equivalent of apply is planned. In the meantime...

It is very hard to respond to the volume of API suggestions for core in a piecemeal way. Adding 100 trivial things to core is not a trivial thing, especially if you care about how all those things work together conceptually across all the different packages. Adding something like apply is planned. It wasn't in the first version, but many folks have wanted it since then. So it's in the plan to add it.

@jasonzoladz

This comment has been minimized.

Show comment
Hide comment
@jasonzoladz

jasonzoladz Sep 30, 2015

Thanks Evan. I appreciate the reply.

On Tuesday, September 29, 2015, Evan Czaplicki notifications@github.com
wrote:

Adding the equivalent of apply is planned. In the meantime...

It is very hard to respond to the volume of API suggestions for core in a
piecemeal way. This is planned. It wasn't in the first version, but many
folks have wanted it since then. So it's in the plan to add it.


Reply to this email directly or view it on GitHub
https://github.com/elm-lang/core/issues/416#issuecomment-144222334.

jasonzoladz commented Sep 30, 2015

Thanks Evan. I appreciate the reply.

On Tuesday, September 29, 2015, Evan Czaplicki notifications@github.com
wrote:

Adding the equivalent of apply is planned. In the meantime...

It is very hard to respond to the volume of API suggestions for core in a
piecemeal way. This is planned. It wasn't in the first version, but many
folks have wanted it since then. So it's in the plan to add it.


Reply to this email directly or view it on GitHub
https://github.com/elm-lang/core/issues/416#issuecomment-144222334.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment