Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:18:35+00:00 2026-06-18T06:18:35+00:00

I am new to Haskell. I am extremely confused about modules, what they are,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:18:36+00:00Added an answer on June 18, 2026 at 6:18 am

    In Add.hs you declare the module name:

    -- Notice the module name matches the file name, this is typically required
    module Add where
    
    add :: Integer -> Integer -> Integer
    add x y = x + y
    

    And in Test.hs you tell it which modules the functions come from:

    -- Notice we didn't declare a module name, so it defaults to 'Main'
    import Add
    import Test.QuickCheck
    main = quickCheck (\ x y -> x > 0 && y > 0 ==> add x y > x && add x y > y)
    

    You can now compile and run your tests:

    $ ghc Test.hs
    [1 of 2] Compiling Add              ( Add.hs, Add.o )
    [2 of 2] Compiling Main             ( Test.hs, Test.o )
    Linking Test ...
    $ ./Test
    +++ OK, passed 100 tests.
    

    EDIT:

    And if you are working inside of GHCi, and vs compiling from a terminal as shown above, then you can do:

    ... run "ghci Test.hs" ...
    > main
    +++ OK, passed 100 tests.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Still quite new to Haskell.. I want to read the contents of a file,
I'm new to haskell guys. I'm trying to write a gcd executable file. ghc
I'm extremely new to haskell and was trying to implement a small and a
I am new to Haskell and facing a "cannot construct infinite type" error that
I am new to haskell and I encountered a performance issue that is so
I'm new to haskell and I'm trying to make a function that will multiply
I'm new to Haskell. I understand that functions are curried to become functions that
I'm trying to write a Haskell function that takes makes use of this function:
When starting a new Haskell project which needs language features that are offered by
New to Haskell so sorry if this is very basic This example is taken

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.