在 Elm REPL 中的类型注释

10

我既是Elm编程语言的新手,也是函数式编程的新手,并且从未认真使用过Java。我正在阅读Elm文档,并使用REPL进行实验,尝试理解类型注释。

它们似乎非常有用:

type alias Point = { x:Float, y:Float }

origin : Point
origin =
  { x = 0, y = 0 }

现在你的所有点都是特定格式的浮点数!神奇。爱它。我想在REPL中试玩一下它,但REPL似乎无法理解类型定义:

> type alias Point = { x:Float, y:Float }
> origin : Point
-- SYNTAX PROBLEM -------------------------------------------- repl-temp-000.elm

I ran into something unexpected when parsing your code!

7│   origin : Point
            ^
I am looking for one of the following things:

    end of input
    whitespace

这是REPL中的一个bug还是一个功能?

1个回答

11

谢谢。那真的太糟糕了。Eml-reactor非常棒,但我无法在我的Emacs中运行它,也无法通过键入函数名称来检查函数。但是,我会为您帮助我找到https://github.com/elm-community而给予两个赞。 - Dmitri
1
查看emacs的elm-mode。 elm-oracle集成使您具有一些编辑器检查功能。 - Chad Gilbert

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接