How to use several built-in statements in Frege

for self-test examples, I got the following code:

assert :: Bool -> Bool -> String -> IO () assert actual expected description | expected == actual = do { print "" } -- need a better way to do nothing | otherwise = error description main _ = do assert (odd 2) false "2 is not odd" assert (odd 3) true "3 is odd" 

I know this is not ideal (and tips are more than welcome), but the current problem is that when I put the assert definition in the util.Assertions module, then using two statements will not compile with

 build/realworld/chapter2/FunctionApplication.java:168: error: cannot access ? Assertions.?._assert?.apply( ^ class file for util.Assertions$? not found 1 error E .../Real_World_Frege/chapter2/FunctionApplication.fr:24: java compiler errors are most likely caused by erronous native definitions 

This works when I have only one statement, so the class itself is on CP, and importing the module works in principle. What's wrong?

+2
source share
1 answer

The assert function leads to the type of the form m () , where m is Monad . Therefore, the best way to do nothing is simply

 return () 

In the second part of your question, I cannot imagine what is wrong. Please organize a github repository so that I can download and try it. Also, give the compilation command that you are using and the working directory.

(Btw, you should use a terminal emulator that can display Unicode. On Windows, try chcp 65001 )

+2
source

Source: https://habr.com/ru/post/1502264/


All Articles