Last generator in do {...}

George Kosmidis gkosmidis@epsilon7.gr
Tue, 29 Oct 2002 11:20:47 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_015D_01C27F3D.3AEFC580
Content-Type: text/plain;
	charset="iso-8859-7"
Content-Transfer-Encoding: quoted-printable

I am sure there are a billion errors in this.
This is the first one:=20
    Line:17 - Last generator in do {...} must be an expression=20
Can Anyone point the errors and maybe tell me if there is a possibility =
for this to work?

import IO
import System
import List
import Maybe
import Char
import Numeric

type Name=3DString
type Room=3DInt
type Dr=3DString
type PatientTup=3D(Name,(Room,Dr))
type PatientList=3D[PatientTup]

main=3Ddo userText<-getText
-------------------------------------------------------------------------=
----------
________getText::IO String
________getText=3Ddo nc<-getText
___________________return (:nc)
-------------------------------------------------------------------------=
----------=20
________PatientList::[(String,(Int,String))]
________PatientList=3D[("Robson, Brian",(2,"MJH")),
_____________________("Hitchin, Linda",(1,"ILR")),
_____________________("Reeve, Paul", (2,"ILR"))]
-------------------------------------------------------------------------=
----------
________getWards::Int->Int
________getWards PatientList=3D[Room | (Name,(Room,Dr)) <- PatientList, =
Room=3D=3DgetText]
_________________do putSpc (length Room)
_________________return(RoomLength)
-------------------------------------------------------------------------=
----------
________getPatient::String->String
________getPatient PatientList=3D[Name,Room,Dr | (Name,(Room,Dr)) <- =
PatientList, Name=3D=3DgetText]
___________________do putChar (Name)
______________________putChar 'is in ward'
______________________putChar (Room)
______________________putChar 'and is treated by'
______________________putChar (Dr)
______________________return (wl)
-------------------------------------------------------------------------=
----------=20
________printFreq::WordList->IO()
________printFreq wl
-------------------------------------------------------------------------=
----------
________NumberInWard::printFreq(getWards(getText))
-------------------------------------------------------------------------=
----------=20
________PatientInfo::printFreq(getPatient(getText))
-------------------------------------------------------------------------=
----------=20
________setABC::ReceptionReport -> ReceptionReport
________setABC [ ]___=3D[ ]
________setABC(wn:ws)=3DsetABC[(w,wc) | (w,wc)<-ws, =
not(isBigger(w,wc)wn)]
_________++[wn]++setABC[(w,wc) | (w,wc) <- ws, isBigger (w,wc) wn]
__________________where=20
___________________isBigger (w1,wc1) (w2,wc2)
____________________| ord(head(w1))-ord(head(w2))>0=3DTrue
____________________| ord(head(w1))-ord(head(w2))<0=3DFalse
____________________|length w1>1&&length w2>1
_____________________=3DisBigger(tail(w1),wc1) (tail(w2),wc2)
____________________|length w1>1&&length w2=3D=3D1=3DTrue
____________________|otherwise=3Dfalse=20
-------------------------------------------------------------------------=
----------
________ReseptionList::String->String
________ReseptionList PatientList=3D[Name,Room | (Name,(Room,Dr)) <- =
PatientList]
______________________do sequence (map ReceptionReport wl)
__________________________________where=20
______________________________________ReceptionReport::setABC((Name,Room)=
)->IO()
______________________________________ReceptionReport(w,wc)=3Ddo putStr =
w
_______________________________________________________________putStr =
(show w)
_______________________________________________________________putChar =
'in'
_______________________________________________________________putStr =
(show wc)
_______________________________________________________________putChar =
'\n'
_______________________________________________________________return wl
-------------------------------------------------------------------------=
----------
________setNum::DoctorsReport -> DoctorsReport
________setNum [ ] =3D [ ]
________setNum((wn,wcn):DoctorsReport[(w,wc)|(w,wc)<-ws,
_________________________ws<=3Dwcn++[(wn,wcn)]DoctorsReport[(w,wc)|(w,wc)=
<-ws,wc>wcn]
-------------------------------------------------------------------------=
----------
________DoctorsList::String->String
________DoctorsList PatientList=3D[Name,Room | (Name,(Room,Dr)) <- =
PatientList, Dr=3D=3DgetText]
____________________do sequence (map DoctorsReport wl)  =20
________________________________where=20
____________________________________DoctorsReport::setNum((Name,Room))->I=
O()
____________________________________DoctorsReport(w,wc)=3Ddo putStr w
___________________________________________________________putStr (show =
w)
___________________________________________________________putChar 'in'
___________________________________________________________putStr (show =
wc)
___________________________________________________________putChar '\n'
_______________________________________________________________return wl
-------------------------------------------------------------------------=
----------
------=_NextPart_000_015D_01C27F3D.3AEFC580
Content-Type: text/html;
	charset="iso-8859-7"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-7">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3D"Comic Sans MS" color=3D#0000ff size=3D2>I am sure =
there are a=20
billion errors in this.</FONT></DIV>
<DIV><FONT face=3D"Comic Sans MS" color=3D#0000ff size=3D2>This is the =
first one:=20
</FONT></DIV>
<DIV><FONT face=3D"Comic Sans MS" color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp; Line:17=20
- Last generator in do {...} must be an expression </FONT></DIV>
<DIV><FONT face=3D"Comic Sans MS" color=3D#0000ff size=3D2>Can Anyone =
point the errors=20
and maybe tell me if there is a possibility for this to =
work?</FONT></DIV>
<DIV><FONT face=3D"Comic Sans MS" color=3D#0000ff =
size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Comic Sans MS" color=3D#0000ff size=3D2>import =
IO<BR>import=20
System<BR>import List<BR>import Maybe<BR>import Char<BR>import=20
Numeric</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3D"Comic Sans MS" color=3D#0000ff size=3D2>type =
Name=3DString<BR>type=20
Room=3DInt<BR>type Dr=3DString<BR>type =
PatientTup=3D(Name,(Room,Dr))<BR>type=20
PatientList=3D[PatientTup]</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3D"Comic Sans MS" color=3D#0000ff size=3D2>main=3Ddo=20
userText&lt;-getText<BR>-------------------------------------------------=
----------------------------------<BR>________getText::IO=20
String<BR>________getText=3Ddo =
nc&lt;-getText<BR>___________________return=20
(:nc)<BR>----------------------------------------------------------------=
-------------------&nbsp;<BR>________PatientList::[(String,(Int,String))]=
<BR>________PatientList=3D[("Robson,=20
Brian",(2,"MJH")),<BR>_____________________("Hitchin,=20
Linda",(1,"ILR")),<BR>_____________________("Reeve, Paul",=20
(2,"ILR"))]<BR>----------------------------------------------------------=
-------------------------<BR>________getWards::Int-&gt;Int<BR>________get=
Wards=20
PatientList=3D[Room | (Name,(Room,Dr)) &lt;- PatientList,=20
Room=3D=3DgetText]<BR>_________________do putSpc (length=20
Room)<BR>_________________return(RoomLength)<BR>-------------------------=
----------------------------------------------------------<BR>________get=
Patient::String-&gt;String<BR>________getPatient=20
PatientList=3D[Name,Room,Dr | (Name,(Room,Dr)) &lt;- PatientList,=20
Name=3D=3DgetText]<BR>___________________do putChar=20
(Name)<BR>______________________putChar 'is in=20
ward'<BR>______________________putChar =
(Room)<BR>______________________putChar=20
'and is treated by'<BR>______________________putChar=20
(Dr)<BR>______________________return=20
(wl)<BR>-----------------------------------------------------------------=
------------------&nbsp;<BR>________printFreq::WordList-&gt;IO()<BR>_____=
___printFreq=20
wl<BR>-------------------------------------------------------------------=
----------------<BR>________NumberInWard::printFreq(getWards(getText))<BR=
>------------------------------------------------------------------------=
-----------&nbsp;<BR>________PatientInfo::printFreq(getPatient(getText))<=
BR>----------------------------------------------------------------------=
-------------&nbsp;<BR>________setABC::ReceptionReport=20
-&gt; ReceptionReport<BR>________setABC [ ]___=3D[=20
]<BR>________setABC(wn:ws)=3DsetABC[(w,wc) | (w,wc)&lt;-ws,=20
not(isBigger(w,wc)wn)]<BR>_________++[wn]++setABC[(w,wc) | (w,wc) &lt;- =
ws,=20
isBigger (w,wc) wn]<BR>__________________where =
<BR>___________________isBigger=20
(w1,wc1) (w2,wc2)<BR>____________________|=20
ord(head(w1))-ord(head(w2))&gt;0=3DTrue<BR>____________________|=20
ord(head(w1))-ord(head(w2))&lt;0=3DFalse<BR>____________________|length=20
w1&gt;1&amp;&amp;length =
w2&gt;1<BR>_____________________=3DisBigger(tail(w1),wc1)=20
(tail(w2),wc2)<BR>____________________|length w1&gt;1&amp;&amp;length=20
w2=3D=3D1=3DTrue<BR>____________________|otherwise=3Dfalse=20
<BR>---------------------------------------------------------------------=
--------------<BR>________ReseptionList::String-&gt;String<BR>________Res=
eptionList=20
PatientList=3D[Name,Room | (Name,(Room,Dr)) &lt;-=20
PatientList]<BR>______________________do sequence (map ReceptionReport=20
wl)<BR>__________________________________where=20
<BR>______________________________________ReceptionReport::setABC((Name,R=
oom))-&gt;IO()<BR>______________________________________ReceptionReport(w=
,wc)=3Ddo=20
putStr=20
w<BR>_______________________________________________________________putSt=
r (show=20
w)<BR>_______________________________________________________________putC=
har=20
'in'<BR>_______________________________________________________________pu=
tStr=20
(show=20
wc)<BR>_______________________________________________________________put=
Char=20
'\n'<BR>_______________________________________________________________re=
turn=20
wl<BR>-------------------------------------------------------------------=
----------------<BR>________setNum::DoctorsReport=20
-&gt; DoctorsReport<BR>________setNum [ ] =3D [=20
]<BR>________setNum((wn,wcn):DoctorsReport[(w,wc)|(w,wc)&lt;-ws,<BR>_____=
____________________ws&lt;=3Dwcn++[(wn,wcn)]DoctorsReport[(w,wc)|(w,wc)&l=
t;-ws,wc&gt;wcn]<BR>-----------------------------------------------------=
------------------------------<BR>________DoctorsList::String-&gt;String<=
BR>________DoctorsList=20
PatientList=3D[Name,Room | (Name,(Room,Dr)) &lt;- PatientList,=20
Dr=3D=3DgetText]<BR>____________________do sequence (map DoctorsReport=20
wl)&nbsp;&nbsp;&nbsp;<BR>________________________________where=20
<BR>____________________________________DoctorsReport::setNum((Name,Room)=
)-&gt;IO()<BR>____________________________________DoctorsReport(w,wc)=3Dd=
o=20
putStr =
w<BR>___________________________________________________________putStr=20
(show =
w)<BR>___________________________________________________________putChar =

'in'<BR>___________________________________________________________putStr=
 (show=20
wc)<BR>___________________________________________________________putChar=
=20
'\n'<BR>_______________________________________________________________re=
turn=20
wl<BR>-------------------------------------------------------------------=
----------------</FONT></DIV></BODY></HTML>

------=_NextPart_000_015D_01C27F3D.3AEFC580--