Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upPlease add `apply` and `pure` to Json.Decode #416
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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)|
The equivalent of Adding the equivalent of Furthermore, it should be pretty easy to define in terms of andMap : Decoder (a -> b) -> Decoder a -> Decoder b
andMap decodeFunc decodeValue =
decodeFunc `andThen` \func -> decodeVaue `andThen` \value -> succeed (func value) |
evancz
closed this
Sep 29, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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: My point was that it's a foundational primitive that is trivial to add to the library. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Sep 29, 2015
Member
Adding the equivalent of
applyis 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.
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 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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
|
jasonzoladz commentedSep 29, 2015
It would be nice to have
pureandapplydefined in Json.Decode, as it seems way more natural thanobject6. (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:
"
puretakes a function/value and puts it a box.applytakes a function in a box, and a value in a box, and returns a value in a box." What am I missing?