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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:55:01+00:00 2026-05-22T20:55:01+00:00

Just started learning Haskell. I have an empty source file with this inside: pe

  • 0

Just started learning Haskell.

I have an empty source file with this inside:

pe :: (Integral a) => a -> a
pe y = sum [x | x <- [1..y-1], x `mod` 3 == 0 || x `mod` 5 == 0]

Now if I ghci this, I can call pe like so:

*Main> pe 1000
233168

How do I call it from within my source file? If I have

pe 1000

it returns a cryptic error:

GHC stage restriction: `pe'
   is used in a top-level splice or annotation,
   and must be imported, not defined locally
 In the expression: pe 1000

Do I need to declare it in main or something?

  • 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-22T20:55:02+00:00Added an answer on May 22, 2026 at 8:55 pm

    Yes, you need to hook it up to your main function. For example,

    main = print (pe 1000)
    

    If you want to have multiple calls, you can combine them with do-notation:

    main = do
        print (pe 500)
        print (pe 1000)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I just started learning haskell and I'm trying to use this if statement:
I just started learning objective c. I have this little problems and questions, hope
I have just started learning Erlang and am trying out some Project Euler problems
I have just started writing my own JavaScript Framework (just for the learning experience),
I am a beginner in Haskell so please bear with me. (Just started learning
I just started learning JavaScript and am wondering why this simple snippet hangs when
I've just started learning about thread safety. This is making me code a lot
Hello i have just started learning mvc2 and im having a problem with the
I just started learning Haskell and I ran into a problem in 2-adic type
I just started learning XSLT,now I am following some on-line tutorial of it,and I

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.