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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:40:17+00:00 2026-05-24T15:40:17+00:00

I have functions like: millionsOfCombinations = [[a, b, c, d] | a <- filter

  • 0

I have functions like:

millionsOfCombinations = [[a, b, c, d] | 
  a <- filter (...some filter...) someListOfAs, 
  b <- (...some other filter...) someListOfBs, 
  c <- someListOfCs, d <- someListOfDs]

aLotOfCombinationsOfCombinations = [[comb1, comb2, comb3] | 
  comb1 <- millionsOfCombinations, 
  comb2 <- millionsOfCombinations,
  comb3 <- someList,
  ...around 10 function calls to find if
    [comb1, comb2, comb3] is actually useful]

Evaluating millionsOfCombinations takes 40s. on a very fast workstation. Evaluating aLotOfCombinationsOfCombinations!!0 took 2 days 🙁

How can I speed up this code? So far I’ve had 2 ideas – use a profiler. Tried running myapp +RTS -sstderr after compiling with GHC, but get a blank screen and don’t want to wait days for it to finish.

2nd thought was to somehow cache millionsOfCombinations. Do I understand correctly that for each value in aLotOfCombinationsOfCombinations, millionsOfCombinations gets evaluated multiple times? If that is so, how can I cache the result? Obviously I’ve just started learning Haskell. I know there is a way to do call caching with a monad, but I still don’t understand those things.

  • 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-24T15:40:17+00:00Added an answer on May 24, 2026 at 3:40 pm

    Use the -fforce-recomp, -O2 and -fllvm flags

    If you aren’t already, be sure to use the above flags. I wouldn’t normally mention it, but I’ve seen some questions recently that didn’t know powerful optimization isn’t a default.

    Profile Your Code

    The -sstderr flag isn’t exactly profiling. When people say profiling they’re usually talking about either heap profiling or time profiling via -prof and -auto-all flags.

    Avoid Costly Primitives

    If you need the entire list in memory (i.e. it isn’t going to be optimized away) then consider unboxed vectors. If Int will do instead of Integer, consider that (but Integer is a reasonable default when you don’t know!). Use worker/wrapping transforms at the right times. If you’re leaning heavily on Data.Map, try using Data.HashMap from the unordered-containers library. This list can go on and on, but since you don’t already have an intuition on where your computation time is going the profiling should come first!

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

Sidebar

Related Questions

I have some utility functions like: void myVibratePhone() { AudioServicesPlaySystemSound (kSystemSoundID_Vibrate) ; } that
in writing a scripting engine, I have functions like (psuedo-code) function is_whitespace?(char c){ return
I have multiple setTimeout functions like this: function bigtomedium(visiblespan) { visiblespan.removeClass('big').addClass('medium'); setTimeout(function(){ mediumtosmall(visiblespan);},150); };
I have a mathparser that can do functions like IntPow(3,2). If a user pastes
Suppose I have two functions which look like this: public static void myFunction1(int a,
I have a treeview control that functions like a folder browser. Because loading the
I'm trying to combine a list of functions like so. I have this: Func<int,
I have little doubt about string reading in C. string reading functions like gets,
They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper().
We have scalar functions in our database for returning things like number of tasks

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.