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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:34:42+00:00 2026-05-29T05:34:42+00:00

To me a Closure is a (nested?) function with co-located data. When you write

  • 0

To me a Closure is a (nested?) function with co-located data.

When you write software in Haskell and look it through afterwards, you frequently find closures that you have created unintentionally.

I do not quite get this right for myself. In what situations would I intentionally want to code closures? After all, in all examples I find the amount of co-located data is trivial/small and thus it does not quite seem to me as if in practice that would ever justify their (intentional) creation. Is there any Haskell module that would support me in intentionally creating closures and e.g. storing them in a map?

  • 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-29T05:34:43+00:00Added an answer on May 29, 2026 at 5:34 am

    In Haskell, functions are an essential part of the language, largely because Haskell is based on the Lambda Calculus.

    In the Lambda Calculus, there are functions that have “free variables”, meaning that they use variables that were not passed as direct parameters to them. Functions with free variables are what you would call “closures” in this case.

    Because functions with free variables are so common in LC, they also form an integral part of the Haskell language. For example, when you write this:

    f a b c = a * b + c
    

    … you could also be writing this, with the exact same result:

    f a b = \ c -> a * b + c
    

    … or even:

    f a b = let product = a * b in \ c -> product + c
    

    … further equivalent changes:

    f a = \ b -> let product = a * b in \ c -> product + c
    

    This is because Haskell essentially creates functions with free variables everywhere, and thus, closures are created all the time. Some of these might be optimized away by the compiler, but it is safe to assume that there will be more closures used than you might ever be able to discover on your own.

    So, don’t try to locate closures; they are nothing special in Haskell and are used all the time.

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

Sidebar

Related Questions

In JavaScript, I know that a closure is can be defined as a nested
I got an unexpected closure when creating a nested class. I suspect that this
Given a function, I'm trying to find out the names of the nested functions
How can I tell closure compiler that an anonymous function should not be removed
I am trying to use a closure to ensure that a function can only
In JavaScript nested functions are very useful: closures, private methods and what have you..
I'm teaching myself Clojure. In a non-FP language, I could easily enough write nested
This is mostly an out-of-curiosity question. Consider the following functions var closure ; function
Google Closure Compiler in advanced optimization mode uses a file to define externs that
What is closure? It is supposed to be included in Java 7. (Closures were

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.