[EMAIL PROTECTED] (Ketil Z. Malde) wrote:
> I'd like a general 'nth', but of course that would restrict us to
> monotyped tuples (e.g.,
> 
>         nth :: Int -> (a,a,...,a,a) -> a
> ) 

Under [1] you find an interesting proposal for Template Haskell. 
I don't know, how far it is from beiing implemented, but it would
allow 
  $(sel 1 3) x 
to be replaced  by 
  (\x -> case x of (a, b, c) -> a) x
at compile time. (example from the paper)
Using "program reflection" it should even be possible to detect the size
of the tuple at compile time, giving your nth function with a slightly
different syntax.

Regards
  Nils Decker

[1] http://research.microsoft.com/Users/simonpj/papers/meta-haskell/
-- 
Nils Decker <[EMAIL PROTECTED]>
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to