--The Kalotans are a tribe with a peculiar quirk. Their males always
--tell the truth. Their females never make two consecutive true
--statements, or two consecutive untrue statements. An anthropologist
--(let's call him Worf) has begun to study them. Worf does not yet know
--the Kalotan language. One day, he meets a Kalotan (heterosexual)
--couple and their child Kibi. Worf asks Kibi: ``Are you a boy?'' Kibi
--answers in Kalotan, which of course Worf doesn't understand.  Worf
--turns to the parents (who know English) for explanation. One of them
--says: ``Kibi said: `I am a boy.' '' The other adds: ``Kibi is a
--girl. Kibi lied.'' Solve for the sex of the parents and Kibi.

data Gender = M | F deriving (Show, Eq)

x `xor` y = if x then not y else y

-- One of them says "Kibi said: `I am a boy.'"
M `says` said = (said == M)
F `says` _ = True

-- The other adds "Kibi is a girl. Kibi lied."
M `adds` (is,lied) = (is == F) && lied
F `adds` (is,lied) = (is == F) && (not lied) `xor` (is == M) && lied

ans = [(one,other,is) | one <- [M,F], other <- [M,F], is <- [M,F], said <- [M,F], lied <- [True,False], one /= other, if lied then said /= is else said == is, one `says` said, other `adds` (is,lied)]