[Haskell-cafe] tuples and Show in GHC
Remi Turk
rturk at science.uva.nl
Mon Mar 7 10:04:48 EST 2005
On Mon, Mar 07, 2005 at 12:05:41AM +0000, Keean Schupke wrote:
> Daniel Fischer wrote:
>
> >The Show instances for tuples aren't automatically derived, they are
> >defined in GHC.Show. So somewhere there must be an end, probably the
> >author(s) thought that larger tuples than quintuples aren't used often
> >enough to bother. That's not a principled reason but a practical one, but
> >it's good enough for me.
> >If you need them frequently and don't want to define your own instances,
> >complain.
> >BTW, tuples are defined in Data.Tuple up to 62-tuples and Eq and Ord
> >instances are derived up to 15-tuples.
> >In Hugs, apparently they are only provided up to quintuples.
> >
> Has there been any work done on declaring instances over all tuples? It
> seems the pattern occurs fairly often, and is quite simple to abstract.
>
> Keean.
Which almost sounds like a hint to replace the current tuples by
HLists in Haskell 2? ;)
Something like:
infixr 5 :*:
data HNil = HNil
data HList b => a :*: b = a :*: !b deriving (Eq, Ord)
-- type () = HNil
type (a,b) = a :*: b :*: HNil
type (a,b,c) = a :*: b :*: c :*: HNil
fst :: HList b => (a :*: b) -> a
fst (a:*:b) = a
Where (x,y,z) is syntactic sugar for x :*: y :*: z :*: HNil in
much the same way [x,y,z] is syntactic sugar for x:y:z:[]...
It might even be (almost?) backward compatible AFAICS.
Groeten,
Remi
--
Nobody can be exactly like me. Even I have trouble doing it.
More information about the Haskell-Cafe
mailing list