Documentation for mapToList is weird
jfmengels opened this issue · comments
The documentation for mapToList
is the following
{-| Apply a function to the elements in the array and collect the result in a List.
Html.text : String -> Html msg
mapToList Html.text : Array String -> List (Html msg)
-}
I believe that the first line is alright, but I don't think the remaining lines make much sense, and it almost feels like a copy-paste gone wrong.
I would have expected to see an example of mapToList
usage, with the input and output.
EDIT: Ok, maybe I now see it. The thing on the left of :
are values and what's on the right is the type, just like a REPL.
I think the style of the example is inconsistent with the rest of the examples in the package. I think something like this would be more helpful
mapToList
String.fromInt
(fromList [ 1, 2, 3 ])
== [ "1", "2", "3" ]
Side-note: Instead of using ==
, you could use https://github.com/stoeffel/elm-verify-examples to make sure the examples are always correct.
Thanks for noticing.
Personally, I'd also prefer to use elm-verify-examples
to make sure the examples are correct.
Q: How would we handle fromList
and empty
in the examples?
import Array
and replacefromList
withArray.fromList
andempty
toArray.empty
orimport Array exposing (fromList, empty)
/(..)
in every example. This would make the examples more consistent with theelm/core
Array
docs or- create a PR for
elm-verify-examples
that allows default imports
I'm leaning towards 1 (I think even the elm/core
docs should use qualified names).
If we agree on one style, I can change to -->
in this PR or the next :)