Can Class do this?

Saswat Anand
Tue, 6 Mar 2001 20:14:32 -0800

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable

I have a problem as follows -

type CF =3D Char -> Float
type IF =3D Integer -> Float
type CIF =3D (Char,Integer) -> Float

There be two functions:
fun :: CF
fun =3D fromInt.ord

sun :: IF
sun =3D fromInteger

I want the followings to be valid.

x :: IF
x =3D sun \+ sun

y :: IF
y =3D sun \+ sun \+ sun       -- when only sun is there, type should be =

a :: CF
a =3D fun \+ fun=20

b :: CF
b =3D fun \+ fun \+ fun        -- when only fun is there, type should be =

p :: CIF
p =3D sun \+ fun=20

q :: CIF
q =3D 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.


Content-Type: text/html;
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META content=3D"text/html; charset=3Diso-8859-1" =
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I have a problem as follows =
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>type CF =3D Char -&gt; =
<DIV><FONT face=3DArial size=3D2>type IF =3D Integer -&gt; =
<DIV><FONT face=3DArial size=3D2>type CIF =3D (Char,Integer) -&gt; =
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>There be two =
<DIV><FONT face=3DArial size=3D2>fun :: CF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>fun =3D fromInt.ord</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>sun :: IF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>sun =3D fromInteger</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I want the followings to be =
<DIV><FONT face=3DArial size=3D2>x :: IF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>x =3D sun \+ sun</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>y :: IF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>y =3D sun \+ sun \+=20
sun&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- when only sun is there, type =
be IF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a :: CF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a =3D fun \+ fun </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>b&nbsp;:: CF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>b =3D fun \+ fun \+=20
fun&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- when only fun is there, =
should be IF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>p :: CIF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>p =3D sun \+ fun </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>q :: CIF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>q =3D sun \+ fun \+=20
sun&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- -when sun and =
fun are=20
mixed type should be CIF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I guess&nbsp;this can be done using =
classes, but I=20
have not been successful after trying many variations.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Any help is very much =
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Saswat</FONT></DIV></BODY></HTML>