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 upInconsistent type signature of map(N) functions #933
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Dec 28, 2017
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Dec 28, 2017
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rl-king
Dec 30, 2017
Contributor
I noticed this when making a PR for the List.map(N) functions but then realised it's not the only place this occurs. I filled this issue quite specific but this might be part of a larger revision where It's best to find a default way of defining these throughout core in general.
|
I noticed this when making a PR for the List.map(N) functions but then realised it's not the only place this occurs. I filled this issue quite specific but this might be part of a larger revision where It's best to find a default way of defining these throughout |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Mar 7, 2018
Member
I'm not sure I understand this issue. Are you saying you were personally confused? Or that other people might be confused?
|
I'm not sure I understand this issue. Are you saying you were personally confused? Or that other people might be confused? |
evancz
added
the
request
label
Mar 7, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rl-king
Mar 7, 2018
Contributor
Other people might be confused,
Focussing on just the List signatures.
I noticed that that List.map returns a List b but List.map2 returns a List result. That got me wondering if it would be more helpful to understand if the signatures are more similar?
List.map : (a -> b) -> List a -> List b
List.map2 : (a -> b -> c) -> List a -> List b -> List c
vs
List.map : (a -> b) -> List a -> List b
List.map2 : (a -> b -> result) -> List a -> List b -> List result
Also, I can imagine someone that hasn't gotten used to how to read the type signatures yet might read the docs and interpret
List.map2 : (a -> b -> result) -> List a -> List b -> List result
as
List.map2 : (a -> b -> Result) -> List a -> List b -> List Result
|
Other people might be confused, Focussing on just the I noticed that that Also, I can imagine someone that hasn't gotten used to how to read the type signatures yet might read the docs and interpret |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Mar 7, 2018
Member
I'd want to find such a person before making the change.
When I first wrote the docs, I did the traditional a b c thing, and I thought it was really weird looking to see them all in a row. "This one returns c but in that one c is an argument! What?" I also think that people seeing most of these functions will not know about Result yet, so they will just read it as "the result of the function"
Point is, it is that way based on a learning theory, and I would want to disprove the theory by seeing beginners struggle with this before changing. It may be that none of the suggestions that make sense to us actually help with the confusion they are (or are not) experiencing.
|
I'd want to find such a person before making the change. When I first wrote the docs, I did the traditional Point is, it is that way based on a learning theory, and I would want to disprove the theory by seeing beginners struggle with this before changing. It may be that none of the suggestions that make sense to us actually help with the confusion they are (or are not) experiencing. |
rl-king commentedDec 28, 2017
Overview
All
mapfunctions in core which have ananyreturn valueArray.map : (a -> b) -> Array a -> Array bDict.map : (comparable -> a -> b) -> Dict comparable a -> Dict comparable bDecode.map : (a -> value) -> Decoder a -> Decoder valueList.map : (a -> b) -> List a -> List bMaybe.map : (a -> b) -> Maybe a -> Maybe bCmd.map : (a -> msg) -> Cmd a -> Cmd msgSub.map : (a -> msg) -> Sub a -> Sub msgRandom.map : (a -> b) -> Generator a -> Generator bResult.map : (a -> value) -> Result x a -> Result x valueSet.map : (comparable -> comparable2) -> Set comparable -> Set comparable2Task.map : (a -> b) -> Task x a -> Task x bMap(N)
Decode.map2 : (a -> b -> value) -> Decoder a -> Decoder b -> Decoder valueList.map2 : (a -> b -> result) -> List a -> List b -> List resultMaybe.map2 : (a -> b -> value) -> Maybe a -> Maybe b -> Maybe valueRandom.map2 : (a -> b -> c) -> Generator a -> Generator b -> Generator cResult.map2 : (a -> b -> value) -> Result x a -> Result x b -> Result x valueTask.map2 : (a -> b -> result) -> Task x a -> Task x b -> Task x resultNotes
anytypes are actually helpful, likemsgmapandmap(N)resultas a return value inList.map(N)andTask.map(N)could be confusing since aResulttype existsRandom.map(N)is the onlymap(N)that returns a single characterany