This code:
import Data.Foldable
import Debug.Trace
factors :: [Bool]
factors = [True, True, False, True, True, True, True, True]
andy :: Bool -> Bool -> Bool
andy False _ = False
andy True False = False
andy True True = True
tandy :: Bool -> Bool -> Bool
tandy a b = let c = a `andy` b in trace (show a ++ " & " ++ show b ++ " = " ++ show c) c
wonder :: Bool
wonder = foldl tandy True factors
says this when I evaluate wonder:
True & True = True
True & True = True
True & False = False
False & True = False
False & True = False
False & True = False
False & True = False
False & True = False
but I would have preferred it to have stopped sooner. I've tried this with everything imaginable in place of the foldl and with && in place of andy but it never seems to get the hint.
It seems to me that the line andy False _ = False doesn't invite the compiler to evaluate the second parameter. I haven't forced any strictness. What's going on? Even C can do better.