Prefix form of unboxed tuple
simonpj at microsoft.com
Fri Jul 6 10:57:26 EDT 2007
| You might expect there to be a prefix form of the unboxed tuple:
| Prelude> case (#,#) 1 2 of (# a , b #) -> error $ show (a,b)
| <interactive>:1:7: parse error on input `,'
| But there isn't.
No real reason why not. If you write
foo :: a -> b -> (# a,b #)
foo x y = (# x, y #)
then foo should work just fine. So what you want needs two things:
* We would have to define a collection of such functions in the Prelude (see Data.Tuple, for the (,,,,) functions).
* We'd have to do is to make the parser understand '(#,,,#)'.
Do add a feature request if you like. (And/or implement it!) It'd be a good "rounding out" thing.
Another feature I'd like is for unboxed tuples to be more first class. For example, we don't currently allow
f :: (# a, b #) -> ...
But there's no real reason why not; we could transform them away just before code generation. That would eliminate all special cases for unboxed tuples, except the constraints that apply to all unboxed types (notably: you can't instantiate a type variable with an unboxed type; unboxed types are strict).
If you add a feature request, add that too!
More information about the Glasgow-haskell-users