I'm tackling a simple leap year exercise in Haskell, and I'd like to make my solution point-free. Starting from this:
isLeapYear :: Integer -> Bool
isLeapYear year = divisibleBy 400 year || divisibleBy 4 year && not (divisibleBy 100 year)
where
divisibleBy m y = (== 0) $ flip mod m y
I tried using liftA3, with a function doing (x || (y && z)) following this, but the tests do not finish and I don't know why.
So, then, I have 3 questions:
- Do you have any pointers as to how could I achieve this?
- In my first solution, what's preventing
divisibleByto be point-free? (Typechecker complains if I remove the arguments) - As I mentioned before, I tried something like
liftA3 (\x y z -> x || (y && z)) (divisibleBy 400) (divisibleBy 4) (indivisibleBy 100), but the tests hang. Why does that happen? I'm not getting howliftA3works.
Thanks a lot for your help.