bang patterns give fundamentally new capabilities?

Simon Peyton-Jones simonpj at
Sat Dec 2 18:02:28 EST 2006

| I was recently presented with the problem of writing a function like so
| seqInt__ :: forall a . a -> Int# -> Int#
| seqInt__ x y = x `seq` y
| which seems fine, except 'seq' of type forall a b . a -> b -> b cannot
| be applied to an unboxed value.

Actually it works fine.  Did you try it?  Seq is special because its second type argument can be instantiated to an unboxed type.  I see that is not documented in the user manual; it should be.

GHC has a kinding system that looks quite similar to the one you described for jhc.  Here's teh
comment from compiler/Type.lhs

                / \
               /   \
              ??   (#)
             /  \
            *   #

where   *    [LiftedTypeKind]   means boxed type
        #    [UnliftedTypeKind] means unboxed type
        (#)  [UbxTupleKind]     means unboxed tuple
        ??   [ArgTypeKind]      is the lub of *,#
        ?    [OpenTypeKind]     means any type at all

| Also, is there a way to do something similar but for 'lazy' rather than
| 'seq'? I want something of type
| type World__ = State# RealWorld
| {-# NOINLINE newWorld__ #-}
| newWorld__ :: a -> World__
| newWorld__ x = realWord#  -- ???
| except that I need newWorld__ to be lazy in its first argument. I need
| to convince the opimizer that the World__ newWorld__ is returning
| depends on the argument passed to newWorld__.

I don't understand what you meant here.  The definition of newWorld__ that you give is, of course, lazy in x.


More information about the Glasgow-haskell-users mailing list