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 7535169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:14:48+00:00 2026-05-30T06:14:48+00:00

I am trying to load the following program gcd a b = if b

  • 0

I am trying to load the following program

gcd a b = if b == 0
         then a
      else gcd b (rem a b)

But I get the error

Prelude> :l euclidean.hs 
[1 of 1] Compiling Main             ( euclidean.hs, interpreted )

euclidean.hs:3:8:
    Ambiguous occurrence `gcd'
    It could refer to either `Main.gcd', defined at euclidean.hs:1:0
                          or `Prelude.gcd', imported from Prelude
Failed, modules loaded: none.

I changed the function name from gcd to main and I get

Couldn't match expected type `IO t'
           against inferred type `a -> a -> a'
    In the expression: main
    When checking the type of the function `main'
Failed, modules loaded: none.

I dont understand this. I am using the workshop step here.

  • 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-05-30T06:14:49+00:00Added an answer on May 30, 2026 at 6:14 am

    The first error should be self-evident–a function called gcd already exists.

    The second one is also simple. In Haskell, main is the entry point of the program. Since the program needs some way to do IO, main has to have a type in the form IO a, usually IO (). What this means is you should call your gcd function something else. (The main function in Haskell is akin to the main method in Java.)

    The usual practice is to call it gcd', which is pronounced “gcd prime”. In this case, naming your function gcd' signifies that it is just a different implementation of gcd.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run jboss. But I get the following error: [javac] C:\Program
I'm trying to load my .mo translations using the following code, but it doesn't
I am trying to load a new view with the following code - (void)tableView:(UITableView
I'm trying to use the following code # LOAD XML FILE $XML = new
I'm trying to parse download pages from www.mediafire.com, but i really often get a
I run into the following problem.I load my shaders from files.The shader program ,when
Hi i'm trying to create an Interactivity.Behavior to load a program's icon in the
I have a problem with out of memory when I'm trying load a few
Trying to load a shared lib out of the current '.' dir in a
While trying to load a Bitmap onto a SWFLoader the Event.COMPLETE event is not

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.