找不到Variable Text.Color

时间:2014-09-30 13:01:32

标签: elm

当尝试从Elm教程编译Pong时,我收到错误"找不到变量Text.color"

textGreen = rgb 160 200 160
txt f = leftAligned << f << monospace << Text.color textGreen << toText
msg = "SPACE to start, WS and &uarr;&darr; to move"

错误是指我尝试设置Text.color时提供的第二行。 提前感谢您提供的任何帮助。

1 个答案:

答案 0 :(得分:1)

你导入了Text吗? import Text,您列出的代码将编译。

您的txt功能真的是您期望的类型吗?

> txt f = leftAligned << f << monospace << Text.color textGreen << toText`
<function> : (Text.Text -> Text.Text) -> String -> Graphics.Element.Element

如果是这样,这将编译并运行:

import Text             exposing (monospace, fromString)
import Color            exposing (rgb)
import Graphics.Element exposing (leftAligned)

textGreen = rgb 160 200 160
txt f = leftAligned << f 
                    << monospace 
                    << Text.color textGreen 
                    << fromString
msg = "SPACE to start, WS and &uarr;&darr; to move"

main = txt identity msg