I am new to Haskell. I am extremely confused about modules, what they are, and how to use them. For example, I created a add.hs file that contains a simple function as follows:
add a b = a + b
There are some test cases in a file called addTestCases.hs, that check for the functionality of add.hs.
I am somehow supposed to load the testcases to GHC, which will automatically run, and find the add.hs function.
I am really not sure how to accomplish this, and would appreciate any clarification, as I have spent a lot of time trying to figure this out.
Many thanks in advance.
In
Add.hsyou declare the module name:And in Test.hs you tell it which modules the functions come from:
You can now compile and run your tests:
EDIT:
And if you are working inside of GHCi, and vs compiling from a terminal as shown above, then you can do: