for the sake of self-checking examples, I got the following code running:
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 perfect (and advice is more than welcome) but the current issue is that when I put the definition of assert into a module util.Assertions then using two assertions fails to 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
It works when I have only one assertion, so the class itself is on the CP and the module import works in principle. What is wrong?
Your
assert
function results in a type of the formm ()
wherem
is aMonad
. The best way to "do nothing" is therefore to justFor the second part of your question I can not really imagine what is wrong. Please arrange your github repo so that I could download it and try for myself. Also, give the compile command you use and the working directory.
(Btw, you should use a terminal emulator that can display Unicode. Under Windows, try
chcp 65001
)