Can Class do this?
Saswat Anand
iscp9157@nus.edu.sg
Tue, 6 Mar 2001 20:14:32 -0800
This is a multi-part message in MIME format.
------=_NextPart_000_0009_01C0A67A.0E4074A0
Content-Type: text/plain;
charset="iso-8859-1"
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 =
IF
a :: CF
a =3D fun \+ fun=20
b :: CF
b =3D fun \+ fun \+ fun -- when only fun is there, type should be =
IF
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.
Thanks,
Saswat
------=_NextPart_000_0009_01C0A67A.0E4074A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I have a problem as follows =
-</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>type CF =3D Char -> =
Float</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>type IF =3D Integer -> =
Float</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>type CIF =3D (Char,Integer) -> =
Float</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>There be two =
functions:</FONT></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>fun :: CF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>fun =3D fromInt.ord</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>sun :: IF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>sun =3D fromInteger</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I want the followings to be =
valid.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>x :: IF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>x =3D sun \+ sun</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>y :: IF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>y =3D sun \+ sun \+=20
sun -- when only sun is there, type =
should=20
be IF</FONT></DIV>
<DIV> </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> </DIV>
<DIV><FONT face=3DArial size=3D2>b :: CF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>b =3D fun \+ fun \+=20
fun -- when only fun is there, =
type=20
should be IF</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>p :: CIF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>p =3D sun \+ fun </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>q :: CIF</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>q =3D sun \+ fun \+=20
sun - -when sun and =
fun are=20
mixed type should be CIF</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I guess this can be done using =
classes, but I=20
have not been successful after trying many variations.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Any help is very much =
appreciated.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Saswat</FONT></DIV></BODY></HTML>
------=_NextPart_000_0009_01C0A67A.0E4074A0--