Hi thanks!
to, 2006-11-16 kello 14:02 -0800, Greg Buchholz kirjoitti:
] 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?
On Thu, Nov 16, 2006 at 10:44:59PM +0200, isto wrote:
I'll guess the reason it didn't compile was different
types at case branches (am I wrong?) Anyhow, do you know that
is it possible to choose the return type somehow in the spirit
above?
GADTs let you do this. And they even omit the
ke, 2006-11-15 kello 13:31 -0800, Greg Buchholz kirjoitti:
isto wrote:
] let t = show (typeOf a)
] in case t of
] Double - roundDDec d a
] Complex Double - roundCDec d a
Maybe you want type classes instead?
yes, I was blind... Thanks!
I'll guess
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
Hi,
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
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 -