diff --git a/src/Hanafuda.hs b/src/Hanafuda.hs index e1fe004..a19357e 100644 --- a/src/Hanafuda.hs +++ b/src/Hanafuda.hs @@ -13,6 +13,7 @@ module Hanafuda ( , match , packOfCards , remove + , sameMonth , shuffle , size ) where @@ -111,8 +112,8 @@ intersection = portBinary (.&.) difference :: Pack -> Pack -> Pack difference = portBinary (\a b -> a `xor` (a .&. b)) -sameMonth :: Card -> Pack -sameMonth card = Pack $ 0xf `shift` (fromEnum card .&. 0xfc) +sameMonth :: Card -> Pack -> Pack +sameMonth card (Pack p) = Pack $ (0xf `shift` (fromEnum card .&. 0xfc)) .&. p cards :: [Card] cards = [Pine0 .. Phoenix] @@ -130,7 +131,7 @@ shuffle l = match :: Card -> Pack -> Either String (Pack, [Card]) match card pack = - let sameMonthCards = sameMonth card `intersection` pack in + let sameMonthCards = sameMonth card pack in case size sameMonthCards of 0 -> Right (add pack card, []) 1 -> Right (difference pack sameMonthCards, card : cardsOfPack sameMonthCards)