[Haskell-cafe] Defining a Strict language pragma

Johan Tibell johan.tibell at gmail.com
Mon Nov 5 23:52:56 CET 2012


Hi all,

I would like to experiment with writing some modules (e.g. low-level
modules that do a lot of bit twiddling) in a strict subset of Haskell. The
idea is to remove boilerplate bangs (!) and instead declare the whole
module strict. I believe this would both make code that needs to be strict
more declarative (you say what you want once, instead of putting bangs
everywhere), less noisy, and more predictable (no need to reason about
laziness in places where you know you don't want it). The idea is to
introduce a new language pragma

{-# LANGUAGE Strict #-}

that has the above described effect.

The tricky part is to define the semantics of this pragma in terms of
Haskell, instead of in terms of Core. While we also need the latter, we
cannot describe the feature to users in terms of Core. The hard part is to
precisely define the semantics, especially in the presence of separate
compilation (i.e. we might import lazy functions).

I'd like to get the Haskell communities input on this. Here's a strawman:

 * Every function application f _|_ = _|_, if f is defined in this module
[1]. This also applies to data type constructors (i.e. the code acts if all
fields are preceded by a bang).

 * lets and where clauses act like (strict) case statements.

 * It's still possible to define strict arguments, using "~". In essence
the Haskell lazy-by-default with opt-out via "!" is replaced with
strict-by-default with opt-out via "~".

Thoughts?

Cheers,
  Johan

1. I could see the very opposite choice be made: function applications to
functions defined in other modules are also strict. We should try to think
about the implications of either policy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121105/8ac9a251/attachment.htm>


More information about the Haskell-Cafe mailing list