1

I figured that I can do it on the command line REPL like so:

java -jar frege-repl-1.0.3-SNAPSHOT.jar -hints -warnings

But how can I do the same in http://try.frege-lang.org

Ingo
  • 36,037
  • 5
  • 53
  • 100

1 Answers1

1

Hints and warnings are already enabled by default. For example,

frege> f x = f x
function f :: α -> β
3: application of f will diverge.

Perhaps we can make it better by explicitly saying it as warning or hint (instead of colors distinguishing them) something like:

[Warning] 3: application of f will diverge.

and providing an option to turn them on/off.

Update: There was indeed an issue (Thanks Ingo for pointing that out!) with showing warnings that are generated in a later phase during the compilation. This issue has been fixed and the following examples now correctly display warnings in the REPL:

frege> h x = 0; h false = 42
function h :: Bool -> Int
4: equation or case alternative cannot be reached.

frege> f false = 6
function f :: Bool -> Int
5: function pattern is refutable, consider
adding a case for true
Marimuthu Madasamy
  • 13,126
  • 4
  • 30
  • 52
  • 1
    I see, but how comes that some warnings do not appear. Like `g true = 43` now there should be a warning about the missing equation for `g false ...` – Ingo Oct 08 '14 at 22:22
  • Another one: `h x = 0; h false = 42` should warn that the second equation is never used. – Ingo Oct 08 '14 at 22:24
  • I am not sure why those warnings are not getting displayed. I will take a look tomorrow. – Marimuthu Madasamy Oct 09 '14 at 04:56
  • Note that some warnings and hints, like the above ones, are emitted in the code generation pass. Maybe you fetch the warnings too early? – Ingo Oct 09 '14 at 16:50
  • Thanks! yes, that is exactly the problem. In REPL, for definitions, code generation phase is skipped since we are not going to evaluate anything. For modules and expressions, code generation is always enabled. To fix this issue, I think we should always enable codegen. – Marimuthu Madasamy Oct 09 '14 at 17:46
  • Ohh, I didn't know this. Very clever, indeed. But when I use the function, you have to compile it anyway, haven't you? – Ingo Oct 09 '14 at 20:33
  • yes, compilation always happens. It is just code generation that will not be enabled for definitions until you type an expression later. At that time all the definitions you have entered and successfully compiled will be included along with the expression you just typed in. – Marimuthu Madasamy Oct 09 '14 at 20:53
  • @Ingo I have fixed this issue by enabling code generation always. – Marimuthu Madasamy Oct 15 '14 at 05:12
  • Great! Thank you for doing this. – Ingo Oct 15 '14 at 18:47