Unit unboxed tuples

Simon Peyton-Jones simonpj at microsoft.com
Fri Dec 23 13:46:38 CET 2011


Dear GHC users

I've just discovered something very peculiar with unboxed tuples in GHC.

                f2 x = (# True, False #)
                f1 x = (# True #)
                f0 x = (# #)

What types do these functions have?
                f2 :: a -> (# Bool, Bool #)
                f1 :: a -> (# Bool #)
BUT
                f0 :: a -> b -> (# b #)

I think this is stupid.  It should be

                f0 :: a -> (# #)

But in fact even that type isn't what you expect (ie the analogue of  f :: a -> () )
Here are the kinds of the type constructors:

                (,,) :: * -> * -> * -> *
                (,) :: * -> * -> *
                () :: *

                (# ,, #) :: * -> * -> * -> #
                (# , #) :: *  -> * -> #
BUT
                (#  #) :: * -> #

In both respects unboxed unit tuples are behaving differently to boxed ones. This seems bonkers.  I propose to fix this, but I wanted to check if anyone is relying on the current odd behaviour.


Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20111223/950ed00d/attachment.htm>


More information about the Glasgow-haskell-users mailing list