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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:32:46+00:00 2026-05-27T19:32:46+00:00

The compiler says The last statement in a ‘do’ construct must be an expression:

  • 0

The compiler says

The last statement in a 'do' construct must be an expression:
rmax <- getInteger

when attempting to load a file containing the following snippets of code:

getInteger :: IO Integer
getInteger = readLn

main :: IO ()
main = do  
    putStrLn "specify upper limit of results"  
    rmax <- getInteger
    if rmax `notElem` mot
        then do putStrLn "run again and enter a multiple of 10"
        else do print pAllSorted

What does it (the compiler message) mean, and why does it occur here? (whereas it doesn’t in:)

main = do   
    line <- getLine  
    if null line  
        then return ()  
        else do  
            putStrLn $ reverseWords line  
            main  

reverseWords :: String -> String  
reverseWords = unwords . map reverse . words  

(above example taken from http://learnyouahaskell.com/input-and-output)

  • 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-27T19:32:47+00:00Added an answer on May 27, 2026 at 7:32 pm

    Your indentation is probably messed up because of mixed tabs and spaces. In fact, there appears to be a stray tab in the code snippet in your question, which I’m assuming you pasted directly from your source file.

    Most likely, GHC is interpreting the tabs differently from how your editor displays them, so it thinks the do block ends after the line in question.

    As a rule of thumb, it’s best to use only spaces in Haskell. The language defines very specific rules for interpreting tabs that most code editors don’t agree with, but spaces are unambiguous and consistent.

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

Sidebar

Related Questions

Anyone have a link to what the C++ standard says regarding a compiler removing
here are code I'm using to do, but compiler says: An anonymous type cannot
The problem is that the compiler says that there is a redefinition of a
I realize this is wrong (my compiler says so!): Rectangle& Rectangle::Overlap(const Rectangle& rectangle) {
Why I can't do this? compiler says warning C4832: token '.' is illegal after
I have the following code, but the compiler says sender_wrapper is undefined, even though
I'm looking to get the showGUI() method work, the compiler says this is not
I want to create a worker thread using _beginthreadex() . However, the compiler says:
The compiler says it can't find the reference for the function when I do
MSVC compiler says that fopen() is deprecated, and recommends the use of fopen_s() .

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.