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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:41:18+00:00 2026-06-04T01:41:18+00:00

I create a lot of temporary variables in Haskell: main = do let nums”

  • 0

I create a lot of temporary variables in Haskell:

main = do
    let nums'' = [1..10]
    let nums' = a . bunch . of_ . functions $ nums''
    let nums = another . bunch . of_ . functions $ nums'
    print nums

That is, I don’t want to write a long chain of functions like so:

let nums = another . bunch . of_ . functions . a . bunch . of_ . functions $ [1..10]

Because it becomes unreadable to me, so I try to group the functions according to what they do. In the process I end up creating a bunch of ugly temporary variables like nums'' and nums' (I could give them more meaningful names, but the point still stands…every new line means a new variable).
This is a case where a shadowed variable would result in cleaner code. I’d like to do something like:

let nums = [1..10]
nums = a . bunch . of_ . functions $ nums
nums = another . bunch . of_ . functions $ nums

I.e. exactly the same as above but without the temporary variables. Is there any way to do this in Haskell? Maybe the whole thing could be wrapped in a “transaction”:

atomically $ do
  (...this code...)
  return nums

Something that would let Haskell know that the code in this section contains shadowed variables, and it should only worry about the end result. Is this possible?

  • 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-04T01:41:19+00:00Added an answer on June 4, 2026 at 1:41 am

    This style is very common:

    let nums = another
             . bunch
             . of_
             . functions
             . a
             . bunch
             . of_
             . functions
             $ [1..10]
    

    It clearly delineates the code; while . serves the place of the temporary variable name.

    And it avoids the dangerous issues that can happen when you start shadowing variable names — accidentally referring to the wrong x will get you into trouble sooner or later.

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

Sidebar

Related Questions

I’m having a lot of trouble understanding how to create a module that will
Let's say I want to create a lot of custom buttons with the same
I have a form which I create manually (a lot of JavaScript in it...).
I create some panel with a lot of components as images text ... .
I want to create and insert a lot of images into a PDF and
I code in Python a lot, and I frequently create classes. Now, I'm not
I am trying to create a simple shell in Unix. I read a lot
After trying a lot i decided to ask question on stackoverflow, I create a
I have to create a C# program that deals well with reading in huge
I want to create a database structure that will has good efficiency. Now database

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.