3 Jan
2003
3 Jan
'03
2:33 p.m.
ketil@ii.uib.no (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 <ndecker@gmx.de>
8636
Age (days ago)
8636
Last active (days ago)
0 comments
1 participants
participants (1)
-
Nils Decker