aforemny / elm-mdc

Elm port of the Material Components for the Web CSS/JS library
https://aforemny.github.io/elm-mdc
Apache License 2.0
354 stars 43 forks source link

... function expects 2 arguments ... #198

Closed dpinn closed 5 years ago

dpinn commented 5 years ago

This probably isn't a bug with elm-mdc, but I'd like some help understanding the problem, or finding a way around it.

I'm using IntelliJ IDEA with the Elm plugin by Keith Lazuka. When I use Material.Options.styled, I find that the code is highlighted as an error, the message being "The function expects 2 arguments, but it got 3 instead.

two-args

Now, the definition of styled is:

styled :
    (List (Attribute m) -> a)
    -> List (Property c m)
    -> a
styled =
    Internal.Options.styled

... which is clearly a curried wrapper around the Internal.Options.styled call. It should all just work, but it doesn't. Do you use IntelliJ IDEA yourself? Do you have any insight into the cause of the problem. Should I be contacting the Elm plugin author about this?

With many thanks for your work, David

aforemny commented 5 years ago

Hi @dpinn, does the error go away if you write brackets around styled like so:

(Material.Options.styled Html.div [])
    [ text "Hello World" ]

?

Most often styled is used as:

styled
    : (List (Html.Attribute msg) -> List (Html msg) -> Html msg)
    -> List (Options.Property c msg)
    -> List (Html msg)
    -> Html msg

It might be that the IntelliJ plugin has a problem with the type inference a = (List (Html msg) -> Html msg), and it might be worth contacting the author about that.

dpinn commented 5 years ago

Yes, the brackets do make the error go away. Of course elm-format removes them. It does appear that the IntelliJ plugin is having a problem with type inference.