Elm 类型 Svg.Svg 的参数太少
Elm Type Svg.Svg has too few arguments
我正在玩 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
的类型声明它工作正常,但是当我添加它时 - 编译器 returns 我这样说:
-- 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
正如我所期待的那样。我在这里错过了什么?什么是正确的类型?它期待什么参数?
您看错了文档。正确的版本在这里:http://package.elm-lang.org/packages/elm-lang/svg/1.1.1/Svg#line.
类型应该是 Svg msg
而不是 Svg
。
这在 Elm 0.16 和 0.17 之间发生了变化。
我正在玩 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
的类型声明它工作正常,但是当我添加它时 - 编译器 returns 我这样说:
-- 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
正如我所期待的那样。我在这里错过了什么?什么是正确的类型?它期待什么参数?
您看错了文档。正确的版本在这里:http://package.elm-lang.org/packages/elm-lang/svg/1.1.1/Svg#line.
类型应该是 Svg msg
而不是 Svg
。
这在 Elm 0.16 和 0.17 之间发生了变化。