简体   繁体   中英

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 ). 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

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).

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.

http://www.frege-lang.org/doc/fregedoc.html -- the library docs. 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. 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. 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 . Dierk's code examples are based on V3.21.500-g88270a0 (which can be seen in the gradle build file).

It seems that the Frege developers decided to change the Frege syntax slightly between those versions. THe result is that you will not be able to run these code snippets in the online REPL anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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