Advertisement
Coriic

Untitled

Jun 13th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data Student = Student {studentName::String, studentSurname::String, age::Int, index::String}
  2.  
  3. data Teacher = Teacher {teacherName::String, teacherSurname::String, phone::String}
  4.  
  5. getName::Student->String
  6. getName student = studentName student
  7.  
  8. setName::Student->String->Student
  9. setName student name = Student firstName surname (age student) (index student)
  10.     where
  11.     firstName = splitted !! 0
  12.     surname = splitted !! 1
  13.     splitted = words name
  14.  
  15. instance Show Student where
  16.     show student = studentName student ++ " " ++ studentSurname student ++ " " ++ show (age student) ++ " " ++ index student
  17.  
  18. instance Eq Student where
  19.     (==) student1 student2 = (studentName student1 == studentName student2) && (studentSurname student1 == studentSurname student2) && (age student1 == age student2) && (index student1 == index student2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement