I have a problem as follows -
 
type CF = Char -> Float
type IF = Integer -> Float
type CIF = (Char,Integer) -> Float
 
There be two functions:
fun :: CF
fun = fromInt.ord
 
sun :: IF
sun = fromInteger
 
I want the followings to be valid.
 
x :: IF
x = sun \+ sun
 
y :: IF
y = sun \+ sun \+ sun       -- when only sun is there, type should be IF
 
a :: CF
a = fun \+ fun
 
b :: CF
b = fun \+ fun \+ fun        -- when only fun is there, type should be IF
 
p :: CIF
p = sun \+ fun
 
q :: CIF
q = sun \+ fun \+ sun         - -when sun and fun are mixed type should be CIF
 
I guess this can be done using classes, but I have not been successful after trying many variations.
 
Any help is very much appreciated.
 
Thanks,
Saswat

Reply via email to