
16 Nov
2006
16 Nov
'06
5:02 p.m.
isto wrote: ] > isto wrote: ] > ] let t = show (typeOf a) ] > ] in case t of ] > ] "Double" -> roundDDec d a ] > ] "Complex Double" -> roundCDec d a ] ] I'll guess the reason it didn't compile was different ] types at case branches (am I wrong?) Correct. ] Anyhow, do you know that is it possible to choose the return type ] somehow in the spirit above? Maybe you want something like...
roundDec d (Left a) = Left (roundDDec d a) roundDec d (Right a) = Right (roundCDec d a)
roundCDec :: (RealFloat a) => Int -> Complex a -> Complex a roundCDec d (c :+ b) = (roundDDec d c :+ roundDDec d b)
roundDDec :: (RealFloat a) => Int -> a -> a roundDDec d a = a -- or somegthing
Greg Buchholz