I am sure there are a
billion errors in this.
This is the first one:
Line:17
- Last generator in do {...} must be an expression
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=String
type
Room=Int
type Dr=String
type PatientTup=(Name,(Room,Dr))
type
PatientList=[PatientTup]
main=do
userText<-getText
-----------------------------------------------------------------------------------
________getText::IO
String
________getText=do nc<-getText
___________________return
(:nc)
-----------------------------------------------------------------------------------
________PatientList::[(String,(Int,String))]
________PatientList=[("Robson,
Brian",(2,"MJH")),
_____________________("Hitchin,
Linda",(1,"ILR")),
_____________________("Reeve, Paul",
(2,"ILR"))]
-----------------------------------------------------------------------------------
________getWards::Int->Int
________getWards
PatientList=[Room | (Name,(Room,Dr)) <- PatientList,
Room==getText]
_________________do putSpc (length
Room)
_________________return(RoomLength)
-----------------------------------------------------------------------------------
________getPatient::String->String
________getPatient
PatientList=[Name,Room,Dr | (Name,(Room,Dr)) <- PatientList,
Name==getText]
___________________do putChar
(Name)
______________________putChar 'is in
ward'
______________________putChar (Room)
______________________putChar
'and is treated by'
______________________putChar
(Dr)
______________________return
(wl)
-----------------------------------------------------------------------------------
________printFreq::WordList->IO()
________printFreq
wl
-----------------------------------------------------------------------------------
________NumberInWard::printFreq(getWards(getText))
-----------------------------------------------------------------------------------
________PatientInfo::printFreq(getPatient(getText))
-----------------------------------------------------------------------------------
________setABC::ReceptionReport
-> ReceptionReport
________setABC [ ]___=[
]
________setABC(wn:ws)=setABC[(w,wc) | (w,wc)<-ws,
not(isBigger(w,wc)wn)]
_________++[wn]++setABC[(w,wc) | (w,wc) <- ws,
isBigger (w,wc) wn]
__________________where
___________________isBigger
(w1,wc1) (w2,wc2)
____________________|
ord(head(w1))-ord(head(w2))>0=True
____________________|
ord(head(w1))-ord(head(w2))<0=False
____________________|length
w1>1&&length w2>1
_____________________=isBigger(tail(w1),wc1)
(tail(w2),wc2)
____________________|length w1>1&&length
w2==1=True
____________________|otherwise=false
-----------------------------------------------------------------------------------
________ReseptionList::String->String
________ReseptionList
PatientList=[Name,Room | (Name,(Room,Dr)) <-
PatientList]
______________________do sequence (map ReceptionReport
wl)
__________________________________where
______________________________________ReceptionReport::setABC((Name,Room))->IO()
______________________________________ReceptionReport(w,wc)=do
putStr
w
_______________________________________________________________putStr (show
w)
_______________________________________________________________putChar
'in'
_______________________________________________________________putStr
(show
wc)
_______________________________________________________________putChar
'\n'
_______________________________________________________________return
wl
-----------------------------------------------------------------------------------
________setNum::DoctorsReport
-> DoctorsReport
________setNum [ ] = [
]
________setNum((wn,wcn):DoctorsReport[(w,wc)|(w,wc)<-ws,
_________________________ws<=wcn++[(wn,wcn)]DoctorsReport[(w,wc)|(w,wc)<-ws,wc>wcn]
-----------------------------------------------------------------------------------
________DoctorsList::String->String
________DoctorsList
PatientList=[Name,Room | (Name,(Room,Dr)) <- PatientList,
Dr==getText]
____________________do sequence (map DoctorsReport
wl)
________________________________where
____________________________________DoctorsReport::setNum((Name,Room))->IO()
____________________________________DoctorsReport(w,wc)=do
putStr w
___________________________________________________________putStr
(show w)
___________________________________________________________putChar
'in'
___________________________________________________________putStr (show
wc)
___________________________________________________________putChar
'\n'
_______________________________________________________________return
wl
-----------------------------------------------------------------------------------