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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:54:22+00:00 2026-06-14T00:54:22+00:00

Prelude> mapM putStrLn [a, b] a b [(),()] Prelude> mapM_ putStrLn [a, b] a

  • 0
Prelude> mapM putStrLn ["a", "b"]
a
b
[(),()]
Prelude> mapM_ putStrLn ["a", "b"]
a
b

Why first version shows third line and second does not and where does third line comes from. I would not expect it.

  • 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-14T00:54:23+00:00Added an answer on June 14, 2026 at 12:54 am

    If you put the mapM version in a standalone program, compile it with ghc, and run it, you don’t get a third line from it, either:

    $ cat demo.hs
    main = mapM putStrLn [ "a", "b" ]
    $ ghc demo.hs
    $ ./demo
    a
    b
    $
    

    That [(),()] you see in ghci is just the return value of the mapM call; ghci automatically displays the value of every expression you enter. (This is why ghci is called a Read-Evaluate-Print Loop, or REPL; the “Print” part is what you’re seeing here.)

    While mapM creates a list containing the return value of every putStrLn call (so you get one () for each element in the list), mapM_ discards those return values and returns IO (), which ghci doesn’t bother to display. So you don’t see an extra line from ghci in that case.

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

Sidebar

Related Questions

I'm wondering why Prelude> head $ reverse $ [1..10000000] ++ [99] 99 does not
From prelude : foldl1 : it takes the first 2 items of the list
Why does Haskell's sort of Data.List ignore the third digit? Prelude>sort [1,200,234,30] [1,200,234,30] EDIT:
i have ubuntu 8.10, running glassfish v3 (not prelude). first deployment of any jruby
I by prelude mean this object: http://gkz.github.com/prelude-ls/ Seems not good idea to bind prelude
When I :load a Haskell script into GHCi, it changes the prompt from Prelude>
Can anybody explain how does foldr work? Take these examples: Prelude> foldr (-) 54
Here's a short transcript from GHCi: Prelude> :t read read :: Read a =>
Look at this output from ghci: Prelude> :t Data.Map.lookup Data.Map.lookup :: Ord k =>
Why is [Char] an instance of Ord , but not of Enum ? Prelude>

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.