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

  • Home
  • SEARCH
  • 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 9178651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:36:11+00:00 2026-06-17T17:36:11+00:00

I am taking a class that introduces Haskell. I am completely new to this

  • 0

I am taking a class that introduces Haskell.
I am completely new to this language.

when I compile it, it says:

[1 of 1] Compiling Main             ( hw1.hs, interpreted )
hw1.hs:11:1: parse error (possibly incorrect indentation)
Failed, modules loaded: none.

Could anybody explain what I’ve done wrong?
Thank you very much.

p.s.
I got a snippet of the code (called primes) from online.
I do not understand that code, if anyone could elaborate on it, that’d be nice.
I don’t understand what the function, sieve, does. Is it a built-in haskell function?

  • 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-17T17:36:12+00:00Added an answer on June 17, 2026 at 5:36 pm

    In addition to what @ertes said about the backticks, there’s some more things wrong. Two of them are easily fixable, fortunately!

    First of all, the let in let num = [1..] should be deleted: in an .hs file you don’t need these (but you do in GHCi, that might be confusing at first). This is what gave you the indentation error. Once you fix that, you’ll get some type errors.

    Secondly, in partC and partD, you write t <- [zip num fibs/primes]. This means that t is bound to each element of the one-element list [zip num ...] in turn. zip num fibs/primes is already a list so you don’t need the brackets. After fixing this, the program compiles, but doesn’t work properly.

    Lastly, if you try to determine whether a number (in your case fst t, again in partC and partD) is prime or a Fibonacci number by checking whether it’s an element of primes or fibs, that will work when the number is actually in the list, but it won’t return False if it’s not. This is because elem doesn’t ‘know’ that the lists you’re looking through are sorted in ascending order. For example, if you try to evaluate elem 4 primes it’s going to check whether 4 is equal to 2,3,5,7,11, and so on – who knows, a 4 might eventually turn up! To fix this you’ll have to write a slightly smarter elem-like function.

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

Sidebar

Related Questions

In the data structures class that I am currently taking, we have been tasked
I have some C# class libraries, that were designed without taking into account things
I'm very new to Unix, and currently taking a class learning the basics of
Basically, I've been taking a class on C programming, within that class we use
I have this function which adds any class that derives from Object to a
I have a class that looks roughly like this: template<std::size_t dim> class Foo {
So I am taking a digital image processing class that requires implementing some image
I'm a blind college student who is taking an introduction to programming class that
I just convinced two teammates in a class that I'm taking to start using
I am currently taking a Programming Fundamentals college class that deals with the C

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.