overload lift function
Wang Meng
wangmeng@comp.nus.edu.sg
Fri, 7 Mar 2003 01:35:44 +0800 (GMT-8)
Hi All,
I have a data type defined as
> data D a = D1 Int | D2 a
Follow this definition, I have D2 Int,D2 Bool and D2 [D2 Int] as instances
of type D.
I want to write an overloaded function lift which lifts an atom type to D.
It is easily done for D2 Int and D2 Bool using type classes.I can have
> class Liftable a where
> lift :: a -> L a
>
> instance Liftable Int where
> lift x = D2 x
However, I have problem with D2 [D2 Int].I want to lift [Int] to D2 [D2
Int].
Is there any solution to it?
Thank you very much.
-W-M-
@ @
|
\_/