榆树类型Svg.Svg参数太少

时间:2016-08-26 14:39:07

标签: svg elm

我正在玩Elm time example并尝试添加更多牌局。为此,我像这样提取手的代码:

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 ] []

没有clockHand的类型声明就可以正常工作,但是当我添加它时 - 编译器会将此返回给我:

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

Type Svg.Svg has too few arguments.

80| clockHand: Float -> String -> Svg

                                  ^^^
Expecting 1, but got 0.

line的文档告诉它有类型

line : List Attribute -> List Svg -> Svg

就像我期待的那样。我在这里想念的是什么?什么是正确的类型?它期待什么论点?

1 个答案:

答案 0 :(得分:4)

您正在查看错误的文档。正确的版本在这里:http://package.elm-lang.org/packages/elm-lang/svg/1.1.1/Svg#line

类型应为Svg msg而不是Svg

这在Elm 0.16和0.17之间发生了变化。