简体   繁体   English

Frege REPL中的代码问题

[英]Problems with Code in the Frege REPL

While trying to learn Frege I copied some code from Dierk's Real World Frege to the online REPL an tried to execute it (see also How to execute a compiled code snipped in Frege online repl ). 在尝试学习Frege的同时,我将Dierk的Real World Frege中的一些代码复制到了在线REPL中,试图执行它(另请参阅如何执行在Frege在线repl中剪切的编译代码 )。 The scripts I've tried don't compile :-( 我试过的脚本不编译:-(

What am I doing wrong? 我究竟做错了什么?

Here are examples of what does not compile: 以下是无法编译的示例:

println ( 2 *-3 )       -- unlike haskell, this will work!

and the whole ValuesAndVariables.fr code 以及整个ValuesAndVariables.fr代码

It is unavoidable that over the course of more than a year, an evolving language (and its libraries) change so that older code will not compile anymore. 不可避免的是,在一年多的时间里,一种不断发展的语言(及其库)发生了变化,以至于旧的代码将不再编译。

It would be nice, if we could see an example, instead of a generalization like "most". 如果我们能够看到一个例子,那将是很好的,而不是像“大多数”这样的概括。

The next best thing would be to have an issue in Dierks project that points to the error(s). 接下来最好的事情是在Dierks项目中出现一个指向错误的问题。

But the very best would be en effort to find out what is wrong. 但最好的是努力找出问题所在。 This would also intensify your learning process. 这也会加强你的学习过程。

Here are two ressources that could help: 这里有两个可以帮助的资源:

https://github.com/Frege/frege/wiki/New-or-Changed-Features -- the release notes for every release, contains a summary of things that have changed between releases, and especially the reasons why code would not compile anymore and how to correct it. https://github.com/Frege/frege/wiki/New-or-Changed-Features - 每个版本的发行说明,包含发行版之间已更改的内容摘要,尤其是代码无法编译的原因再也不知道如何纠正它。

http://www.frege-lang.org/doc/fregedoc.html -- the library docs. http://www.frege-lang.org/doc/fregedoc.html - 图书馆文档。 May explain possible errors like import not found, or missing identifiers. 可以解释可能的错误,例如未找到导入或缺少标识符。

Go, give it a try. 去吧,试一试。 And I'm convinced Dierk will be happy to accept pull requests. 而且我确信迪尔克很乐意接受拉动请求。

Edit: Fixes for announced errors. 编辑:修复已公布的错误。

The error in: 错误:

println ( 2 *-3 ) 

stems indeed from a syntactical change. 确实源于语法上的变化。 It is, as of recently, demanded that adjacent operators be separated by at least one space. 最近,要求相邻的操作员被至少一个空间隔开。 Hence 于是

println (2 * -3)

However, the error message you got here was: 但是,您在此处收到的错误消息是:

can't resolve `*-`, did you mean `-` perhaps?

which could have triggered the idea that it tries to interpret *- as a single operator. 这可能触发了它试图解释*-作为单个运算符的想法。

The other error in ValuesAndVariables1.fr is indeed a show stopper for a beginner. ValuesAndVariables1.fr的另一个错误确实是初学者的表演限制。 The background is that we have one pi that has type Double and one that has type Float and potentially many more through type class Floating , so one needs to tell which one to print. 背景是我们有一个pi类型为Double ,一个类型为Float ,可能还有更多类型为Floating ,因此需要告诉哪一个要打印。 The following will work: 以下将有效:

import Prelude.Math    -- unless already imported
println Float.pi
println (pi :: Double)

the online REPL at http://try.frege-lang.org is currently based on Frege V3.23.370-g898bc8c . http://try.frege-lang.org上的在线REPL目前基于Frege V3.23.370-g898bc8c。 Dierk's code examples are based on V3.21.500-g88270a0 (which can be seen in the gradle build file). Dierk的代码示例基于V3.21.500-g88270a0(可以在gradle构建文件中看到)。

It seems that the Frege developers decided to change the Frege syntax slightly between those versions. 似乎Frege开发人员决定在这些版本之间略微改变Frege语法。 THe result is that you will not be able to run these code snippets in the online REPL anymore. 结果是您将无法再在在线REPL中运行这些代码片段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM