Unfortunately, in the Haskell template there is no such possibility of reflection, but there are workarounds. However, before writing something like this, I recommend trying the test-framework-th package, which already does this for HUnit tests starting with case_ , as well as for QuickCheck properties starting with prop_ .
Under the hood, this package uses the language-haskell-extract package, which essentially performs its own parsing modulo to define definitions. This is a somewhat hacky solution, but in practice it works quite well. However, this leads to many dependencies, and additional parsing can slow down your builds.
source share