Instantly share code, notes, and snippets.

Embed
What would you like to do?
import Data.Time.Calendar
data Person = P { p_id :: Int
, name :: String
, gender :: Int
, age :: Int
} deriving (Show, Eq)
data Group = G { g_id :: Int
, gname :: String
} deriving Show
data Assginment = A { a_id :: Int
, a_p_id :: Int
, a_g_id :: Int
, date :: Day
} deriving Show
persons = [ P 1 "Tarou" 1 10
, P 2 "Hanako" 2 20
, P 3 "Jirou" 1 30
, P 4 "Saburou" 1 40]
groups = [ G 1 "Matu", G 2 "Take", G 3 "Ume"]
assignments = [ A 1 1 1 (fromGregorian 2010 4 1)
, A 2 2 1 (fromGregorian 2009 9 1)
, A 3 3 2 (fromGregorian 2010 4 1)
, A 4 1 2 (fromGregorian 2010 5 1)]
main = print [p | p <- persons
, 2010 `elem` [case toGregorian (date a) of
(y,_,_) -> y | a <- assignments
, p_id p == a_p_id a]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment