1

I am playing with Elm time example and trying to add more hands. To do it I extract code for hand like this:

view : Model -> Html Msg
view model =
  let
    angle =
      turns (Time.inMinutes model.time)
  in
    svg [ viewBox "0 0 100 100", width "300px" ]
      [ circle [ cx "50", cy "50", r "45", fill "#0B79CE" ] []
      , clockHand angle "#023963"
      ]

clockHand: Float -> String -> Svg -- PROBLEM HERE
clockHand angle color =
  let
    handX =
      toString (50 + 40 * cos angle)

    handY =
      toString (50 + 40 * sin angle)
  in
    line [ x1 "50", y1 "50", x2 handX, y2 handY, stroke color ] []

It works ok without the type declaration for clockHand, but when I add it - compiler returns me this:

-- TOO FEW ARGUMENTS -----------------------------------------------------------

Type Svg.Svg has too few arguments.

80| clockHand: Float -> String -> Svg

                                  ^^^
Expecting 1, but got 0.

Documentation for line tells that it has type

line : List Attribute -> List Svg -> Svg

Just as I was expecting. What did I miss here? What is the correct type? What arguments it is expecting?

Bunyk
  • 7,635
  • 8
  • 47
  • 79

1 Answers1

4

You are looking at the wrong docs. The correct version is here: http://package.elm-lang.org/packages/elm-lang/svg/1.1.1/Svg#line.

The type should be Svg msg rather than Svg.

This changed between Elm 0.16 and 0.17.

Jakub Hampl
  • 39,863
  • 10
  • 77
  • 106