Haskell related

As much as Haskell is fun to play with, its unique characteristics can make reasoning about its behaviors and debugging a daunting task. So here I’ll document everything I encountered, big and small.

Running time doesn’t scale with input size

I have some code snippet like:

  • When the list is of size 1, we get the result immediately.
  • However, when the size is 2, it takes a long while before we get the result.
  • For some other small size like 5 or 10, the time is proportional to that of size 2.

Answer: because of the laziness, we don’t ever compare the result of calc in case of one element.

Overflowed Spark

If we get too many sparks, those after the pool overflow will be calculated by the main thread. So with a large list, parMap isn’t going to work, and we need manual partition. And the behavior can seem like imbalanced input.