isto wrote: ] I've been trying to compile the following function ] (rounding to a desired degree): ] ] roundDec :: (Num a, Typeable a) => Int -> a -> a ] roundDec d a = ] let t = show (typeOf a) ] in case t of ] "Double" -> roundDDec d a ] "Complex Double" -> roundCDec d a ] otherwise -> a -- or something ] ] The two other functions are ] ] roundCDec :: (RealFloat a) => Int -> Complex a -> Complex a ] roundCDec d (c :+ b) = (roundDDec d c :+ roundDDec d b) ] and ] roundDDec :: (RealFloat a) => Int -> a -> a ] roundDDec d a = a -- or somegthing
Maybe you want type classes instead? > import Complex > > class Round a where > roundD :: Int -> a -> a > > instance Round Double where > roundD d a = a > > instance (Round a, RealFloat a) => Round (Complex a) where > roundD d (c :+ b) = (roundD d c :+ roundD d b) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe