Implementing Strict Core

Johan Tibell johan.tibell at
Wed May 8 18:03:48 CEST 2013

On Wed, May 8, 2013 at 1:14 AM, Simon Peyton-Jones
<simonpj at> wrote:
> I don’t know any way to make a compositional story about nested !
> annotations in types.  As various of you have pointed out, it looks
> attractive and then runs out of steam.


> Putting !’s on data constructor arguments works because it’s not really part
> of the type at all; rather, it just says “give this contstructor a wrapper
> that makes it strict”.  I think one could make a similar story for functions
> in general, so that
>           f :: !a -> a -> ![a] -> Int
>           f a b c = e
> would mean “add a wrapper to f that makes it strict”; thus
>           f a b c = a `seq` c `seq` e
> But it’s not at all clear that this is worth the fuss.

I don't know either, but it might be worth experimenting with, if the
cost is not too high. This touches on more squishy usability issues
that are hard to get hard data on.

I recently ran a mini-survey (results to be published soon) where
people did indicate they spend more time on performance than
correctness. I'd like to address that issue, as I think it's important
for real world use of Haskell. I don't know the best way to do so. I
think the key is to help programmers deal with laziness in a more
effective manner. Having to think hard about laziness all the time or
risk getting a performance bug doesn't sound like a good idea to me*.

This is just one idea of tackling this problem. Another idea would to
add a {-# LANGUAGE Strict #-} pragma that would make a module strict
by default and optionally lazy using e.g. ~x patterns.

* After all, people could argue that we don't need higher level
languages at all and people should just "think harder" when writing C.
If we accept that's a bad argument for correctness I think we should
reject it as a way to deal with performance issues too.

-- Johan

More information about the ghc-devs mailing list