Last active
January 9, 2023 15:46
-
-
Save L7R7/b3be60a1b4138b7aa0f9f2719e299f86 to your computer and use it in GitHub Desktop.
minimal demo of a contramap-like combinator to modify the outer resource of a spec which would make it possible to combine several specs into one large spec
This file contains hidden or 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
| {-# LANGUAGE DataKinds #-} | |
| import Test.Syd | |
| data Outers = Outers | |
| { foo :: Int, | |
| bar :: String | |
| } | |
| fullSpec :: TestDef (Outers : otherOuters) () | |
| fullSpec = do | |
| contramapOuter foo fooSpec | |
| contramapOuter bar barSpec | |
| fooSpec :: TestDef (Int : otherOuters) () | |
| fooSpec = itWithOuter "foo" $ \i -> i `shouldBe` 3 | |
| barSpec :: TestDef (String : otherOuters) () | |
| barSpec = itWithOuter "bar" $ \s -> s `shouldBe` "s" | |
| -- is there something like that? Is it even possible to implement? | |
| contramapOuter :: | |
| (outer -> newOuter) -> | |
| TestDef (newOuter : otherOuters) () -> | |
| TestDef (outer : otherOuters) () | |
| contramapOuter = _ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works with
beforeAllWith:https://twitter.com/kerckhove_ts/status/1612470104113184770