Created
February 13, 2019 17:07
-
-
Save ttuegel/dea18fb17fc6f1bff1f6309f50d22aed to your computer and use it in GitHub Desktop.
Bool.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_binaryTrees :: TestTree | |
test_binaryTrees = | |
testGroup "Combinations with operators that produce top or bottom" | |
[ mkEquals_ internalTrue internalFalse `becomes` bottom | |
, mkEquals_ internalFalse internalTrue `becomes` bottom | |
, mkEquals_ internalTrue internalTrue `becomes` (pure internalTrue) | |
, mkEquals_ internalFalse internalFalse `becomes` (pure internalFalse) | |
, mkAnd internalTrue internalFalse `becomes` bottom | |
, mkAnd internalFalse internalTrue `becomes` bottom | |
, mkAnd internalFalse internalFalse `becomes` bottom | |
, mkAnd internalTrue internalTrue `becomes` (pure internalTrue) | |
] | |
where | |
internalTrue = mkDomainValue bootSort $ Domain.BuiltinBool True | |
internalFalse = mkDomainValue bootSort $ Domain.BuiltinBool False | |
becomes patt expected = | |
withSolver $ \getSolver -> | |
testCase "" $ do | |
solver <- getSolver | |
actual <- evaluateWith solver patt | |
assertEqual "" expected actual |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is often discouraged to use
flip
fully-applied because it usually obscures meaning. For example, I think this is clearer:(I think the idiomatic use-case of
flip
is to pass as an argument to a higher-order function, e.g.uncurry flip
.)pure
(orreturn
) is the unit of(>>=)
, so we might as well write:Having a chain of
>>=
is idiomatic Haskell. As a matter of personal preference, I usually write such a pipeline when we are applying a sequence of operations to the same or related data, and "break" the chain when an unrelated piece of data appears. For example, I would writebecause, if I did not know what
getResource
is doing, I might think thatmaker
does something to the resource and passes it along toassertEqual
; of course, that isn't what happens at all:maker
consumesresource
to produce a new datum passed toassertEqual
. That's probably what I would have written, but nobody is going to hold you to that style in code review.