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
, P 5 "Akemi" 2 8
, P 6 "Sadayo" 2 70
, P 7 "Hiroko" 2 15]
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)
, A 5 1 3 (fromGregorian 2011 4 1)]
exists = not . null
main = print $
[p | p <- persons
, exists [a | a <- assignments
, a_p_id a == p_id p]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment