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 upJson.Decode should expose "key" as a non-infix name for (:=) #567
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Apr 22, 2016
Contributor
How about
decodeName = JD.child "name" JD.stringor something like that? Also possible: field.
|
How about decodeName = JD.child "name" JD.stringor something like that? Also possible: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ThomasWeiser
Apr 22, 2016
Contributor
Musing about the name: Official JSON docs speak of name/value pairs, but name is not a nice name :) Actually, the most used term (beside name) in JSON land seems to be key. This is also the idiom used in Elm's Dict and it already appears as Json.Decode.keyValuePairs.
So I propose: Json.Decode.key as in:
import Json.Decode as JD
decodeName : JD.Decoder String
decodeName = JD.key "name" JD.string|
Musing about the name: Official JSON docs speak of name/value pairs, but name is not a nice name :) Actually, the most used term (beside name) in JSON land seems to be key. This is also the idiom used in Elm's So I propose: import Json.Decode as JD
decodeName : JD.Decoder String
decodeName = JD.key "name" JD.string |
ThomasWeiser
changed the title from
Json.Decode should expose a non-infix name for (:=)
to
Json.Decode should expose `key` as a non-infix name for (:=)
Apr 22, 2016
ThomasWeiser
changed the title from
Json.Decode should expose `key` as a non-infix name for (:=)
to
Json.Decode should expose key as a non-infix name for (:=)
Apr 22, 2016
ThomasWeiser
changed the title from
Json.Decode should expose key as a non-infix name for (:=)
to
Json.Decode should expose `key` as a non-infix name for (:=)
Apr 22, 2016
ThomasWeiser
changed the title from
Json.Decode should expose `key` as a non-infix name for (:=)
to
Json.Decode should expose "key" as a non-infix name for (:=)
Apr 22, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
May 19, 2016
Member
I agree that the API should be changed to be more in line with more recent libraries informed by usage, but I do not want to track API suggestions here.
|
I agree that the API should be changed to be more in line with more recent libraries informed by usage, but I do not want to track API suggestions here. |
ThomasWeiser commentedApr 22, 2016
•
edited
Edited 1 time
-
ThomasWeiser
edited Apr 22, 2016 (most recent)
NoRedInk/elm-decode-pipeline postulates the abstention of infix operators, IMHO for good reasons, at least in library APIs.
Json.Decodeexports the infix operator:=without a non-infix name. I propose to give it also a reasonable non-infix name. Can't make up for a good one at the moment, but think about something likeat1key.Example, using the infix operator:
Evading infix operators currently forces to use
atwith a one-member list:Proposal (edited):