Skip to content

Unit unboxed tuple behaving oddly

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

Trac metadata
Trac field Value
Version 7.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information