Unboxed Tuples

Simon Peyton-Jones simonpj at microsoft.com
Mon Feb 7 04:28:35 EST 2005

Good point.  Yes you can rely on it; but the binding is lazy.  So for

	h :: Int -> (# String, String #)
	h = ...

	f x = let (# p,q #) = h x in ...

you'll get

	f x = let (p,q) = case h x of (# p,q #) -> (p,q)
	        in ...

So the call to h only happens when either p or q is used.

On the other hand, if any of the binders in a let-pattern has an
unlifted type (e.g. Int#) then the whole pattern match becomes strict.
So if p or q had an unlifted type, the match would be strict.

I'll add a note to the usre manual.


| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org
| bounces at haskell.org] On Behalf Of Adrian Hey
| Sent: 13 January 2005 11:55
| To: glasgow-haskell-users at haskell.org
| Subject: Unboxed Tuples
| Hello,
| Does the user guide documentation for these reflect current ghc
| Para. 7.2.2 says they can only be deconstructed using case expressions
| but by accident I've found they seem to work fine in let bindings too
| (with ghc version 6.2.2).
| Not that I'm complaining (I always thought using case expressions was
| just too painful :-). I just wanted to check that this is a feature
| I can rely on in future (and if so suggest the user guide should be
| ammended to reflect this).
| Regards
| --
| Adrian Hey
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

More information about the Glasgow-haskell-users mailing list