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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to