GHCi :sprint command

The :sprint The s stands for “simple,” the idea being that :sprint is in some sense a simplified version of the :print command, since :sprint does less work. command in GHCi prints a value without forcing any evaluation. This is useful for experimenting to find out which parts of a data structure are evaluated.

In this example, first we define a list from a to z. Initially, none of it has been evaluated, so when we :sprint it, all we see is _.

If we do something that causes part of the list to be evaluated (like looking at the element at index 2), then :sprint now gives us the part of the list that has been evaluated so far.

And so on.

Taking the length of a list is a common way to accidentally force evaluation of the entire thing.

Type Classes offers courses and projects to get you started and make you an expert in FP with Haskell. For $29/month, you get access to the complete archive and all the latest content.