polysemy-test: Polysemy effects for testing

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Please see the README on Github at https://github.com/tek/polysemy-test

[Skip to Readme]


Change log Changelog.md
Dependencies base (>=4 && <5), containers, either, hedgehog (>=1.0.2 && <1.1), path (>=0.7 && <0.9), path-io (>=0.2 && <1.7), polysemy (>=1.3 && <1.6), polysemy-plugin (>=0.2.5), relude (>=0.7), string-interpolate (>=0.1 && <0.4), tasty (>=1.1 && <1.5), tasty-hedgehog (>= && <1.2), template-haskell, text, transformers [details]
License BSD-2-Clause-Patent
Copyright 2020 Torsten Schmits
Author Torsten Schmits
Maintainer tek@tryp.io
Category Test
Uploaded by tek at 2021-04-04T19:30:27Z




Maintainer's Corner

For package maintainers and hackage trustees

Readme for polysemy-test-

[back to package description]


This package provides utilities for testing Polysemy programs:


import Path (relfile)
import Polysemy.Test
import Test.Tasty (defaultMain)

test_fixture :: UnitTest
test_fixture =
  runTestAuto do
    fixContent1 <- fixtureLines fixRel
    fixPath <- Test.fixturePath fixRel
    fixContent2 <- Text.lines <$> embed (Text.readFile (toFilePath fixPath))
    fixContent1 === fixContent2
    fixContent1 === ["file", "content"]
    fixRel =

main :: IO ()
main =
  defaultMain (unitTest test_fixture)


Any file that is located below the subdirectory fixtures inside the test directory can be accessed using the constructors Test.fixturePath, Test.fixture and Text.fixtureLines.

You can override the path used to look for the fixtures directory by using runTest instead of runTestAuto. The latter analyzes the call stack to determine the test directory.

Temp Files

The constructors Test.tempDir, Test.tempFile, Test.tempFileContent and Test.tempFileLines allow you to create and read files in the temp directory within the test directory.


All paths are of type Path from the package path.

You can construct them using the quasiquoters reldir, absdir etc. or the functions parseRelDir, parseAbsDir etc.