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

The Archive Base Latest Questions

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

Should I be able to expect a Haskell compiler be smart enough to optimize

  • 0

Should I be able to expect a Haskell compiler be smart enough to optimize the following definition:

h x y = p (m x) (n y)

into something like this:

h x = let z = m x in \y -> p z (n y)

? This could be convenient if m were expensive to evaluate, and I used h‘s definition in the following way:

main = print $ map (h 2) hugeList
  • 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-13T21:22:55+00:00Added an answer on June 13, 2026 at 9:22 pm

    But what if m is cheap to evaluate, but its result expensive to store? Say m x = [x .. ] and p needs to traverse different prefixes of that list, depending on n y. If then m 2 is shared in map (h 2) hugeList, and any of the list elements requires a long prefix, you have huge memory requirements even if all subsequent elements only require the first element of the list to return the result.

    So an automatic sharing of m x can also be a pessimisation, hence you should not expect all compilers to automatically share it.

    Generally, it is difficult for the compiler to decide whether sharing is beneficial or even detrimental, so you should make sharing explicit where you really want it. (Nevertheless, expect compilers to introduce sharing even where you do not want it sometimes.)

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

Sidebar

Related Questions

I know I should be able to solve this myself, but I've been banging
I assume I should be able to do it like so: var date =
It seems like I should be able to perform bit shift in C/C++ by
This is something I'd expect to be quite straightforward, but after a couple of
I would like an EasyMock mock to be able to expect an empty list
In my application users should be able to define dates when they are available.
WPF is great in that I should be able to use {StaticResource MyBackground} instead
Some requirements for a mobile chat room: Should be able to work seamlessly with
I'm writing a factory class that should be able to return singleton instances of
I'm writing a simulation in which a creature object should be able to move

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.