elm-community / array-extra

convenience functions for working with Array

Home Page:http://package.elm-lang.org/packages/elm-community/array-extra/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

commented

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?

  1. import Array and replace fromList with Array.fromList and empty to Array.empty or
  2. import Array exposing (fromList, empty)/(..) in every example. This would make the examples more consistent with the elm/core Array docs or
  3. 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 :)

@lue-bird I've merged in #28.

Bringing in elm-verify-examples would be a great addition to this repo, if that is something you'd be willing to do. Thanks as always for your help!