Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inverted arguments by mistake #337

Open
gabriela-sartori opened this issue May 2, 2020 · 0 comments
Open

Inverted arguments by mistake #337

gabriela-sartori opened this issue May 2, 2020 · 0 comments

Comments

@gabriela-sartori
Copy link

Example

module Main exposing (main)

import Html as H

main : H.Html Never
main =
    H.text (String.repeat "Hello World! " 3)

Error

Type Mismatch
Line 7, Column 43
The 2nd argument to `repeat` is not what I expect:

7|     H.text (String.repeat "Hello World! " 3)
                                             ^
This argument is a number of type:

    number

But `repeat` needs the 2nd argument to be:

    String

Hint: I always figure out the argument types from left to right. If an argument
is acceptable, I assume it is “correct” and move on. So the problem may actually
be in one of the previous arguments!

Hint: Try using String.fromInt to convert it to a string?
Type Mismatch
Line 7, Column 27
The 1st argument to `repeat` is not what I expect:

7|     H.text (String.repeat "Hello World! " 3)
                             ^^^^^^^^^^^^^^^
This argument is a string of type:

    String

But `repeat` needs the 1st argument to be:

    Int

Hint: Want to convert a String into an Int? Use the String.toInt function!

Suggestion

Type Mismatch
Line 7, Column 27 and 43
The argument order seems to be inverted at `repeat`:

7|     H.text (String.repeat "Hello World! " 3)
                             ^               ^
These argument are:

    String and number

But `repeat` needs arguments to be:

    number and String

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant