I have defined two data type.
type LastName = String
type FirstName = String
type CodeP = Int
type CodeS = String
type CodeI = Int
type GroupNb = Int
type Session = Int
Data Inscription = Inscription CodeS GroupNb Session deriving (Show, Eq)
Data Student = Student CodeS LastName FirstName CodeP
I wanna get a list of all the GroupNb that a student followed during the Session 1. My issue is that I don't know how to pass those 2 data types as arguments of the wanted function. Here are the functions I wrote (not working) :
getCodeS :: Student -> CodeS
getCodeS (Student codeS _ _ _) = codeS
check :: Inscription -> Student -> Bool
check (Inscription codeS _ Session) = codeS == (getCodeS Student) && Session == 1
filterGroups :: [Inscription] -> Student -> [Inscription]
filterGroups g = filter check g Student
getGroupNb :: Inscription -> GroupNb
getGroupNb (Inscription _ groupNb _) = groupNb
stuGroupNb :: [Inscription] -> Student -> [groupNb]
stuGroupNb groupX = map getGroupNb (filterGroups groupX Student)
So, I'm trying to pass Student as a parameter to many functions, but it is not working.
How can I pass two data types parameter to a function?