Reputation: 3
just a quick question as I'm not sure how to symatically go about this:
I've made a test to show you what I mean; I have
type Teacher = String
type Assitant = String
data Student = String Int
The data they will contain will be:
Teacher's name
Assistant's name
Student's name, age
--
I want to make another data called 'Classroom' but I'm not sure how I can contain all these types within the 'Classroom' data? So far I have:
data Classroom = Classroom Teacher Assistant [Student]
i.e. "Mrs. Cloud" "Terrence" [("Amy, 19), ("Paul", 20), ("Scott", 20)]
Cany anyone help me to change my Classroom data to allow the entry above? Many thanks, Mike
Upvotes: 0
Views: 230
Reputation: 1918
Your Classroom
datatype is correct. But you need Student
datatype either to have a constructor (as Classroom
): data Student = Student String Int
or to be a tuple synonym: type Student = (String, Int)
. The latter one matches to your example (just don't forget constructor of Classroom
).
Upvotes: 1