Finally I got what I meant:
class ExpandTuple t where
type Result t
expand :: t->Result t
instance (Integral a)=>ExpandTuple (a,a) where
type Result (a,a) = (a,a,a)
expand (x,y) = (x,y,1)
instance (Integral a)=>ExpandTuple (a,a,a) where
type Result (a,a,a) = (a,a,a)
expand = id
But it's so verbose (even more so than similar C++ template code I
guess), introduces an additional name (the typeclass) into the current
scope, and requires 2 extensions: TypeFamilies and
FlexibleInstances.Is there a cleaner way to do this?
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe