[Haskell-cafe] tuples and Show in GHC
John Meacham
john at repetae.net
Mon Mar 7 18:29:15 EST 2005
On Mon, Mar 07, 2005 at 03:54:07PM +0000, Keean Schupke wrote:
> >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
> >
> >
> Whilst thats certainly one way to do it, HLists are composed of binary
> products (,)... So this
> works as long as you can imagine: (a,(b,(c,HNil))) == (a,b,c)
If we make the list constructor :*: strict in its second argument
data a :*: b = a :*: !b
then they are isomorphic, no?
John
--
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-Cafe
mailing list