Skip to content

Instantly share code, notes, and snippets.

@joelmccracken
Created May 18, 2023 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelmccracken/3bcbcaded3041b7845209bd12e935299 to your computer and use it in GitHub Desktop.
Save joelmccracken/3bcbcaded3041b7845209bd12e935299 to your computer and use it in GitHub Desktop.
import Test.Hspec
-- import Control.Monad
gen1 :: [Bool]
gen1 = [False, True]
gen2 :: [(Bool, Bool)]
gen2 = gen1 >>= \a -> gen1 >>= \b -> pure (a, b)
gen3 :: [(Bool, Bool, Bool)]
gen3 = gen2 >>= \(a,b) -> gen1 >>= \c -> pure (a, b, c)
main :: IO ()
main = do
hspec $ do
it "does this example" $ do
let l (a, b, c) = a && b && c
let r (a, b, c) = c && b && a
l <$> gen3 `shouldMatchList` r <$> gen3
it "problem 14b" $ do
let l z@(a, b, c) =
(((a && b) && not c) || (c && not (a && b))
, z
)
let r z@(a, b, c) =
((((a && not c) || (c && not a)) && not (a && not b)) ||
((a && not b) && not ((a && not c) || c && not a))
, z
)
l <$> gen3 `shouldMatchList` r <$> gen3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment