Get all functions / values โ€‹โ€‹in a haskell template scope

With a haskell template, is there a way to list all the functions in a scope? Sort of

allVarsInScope :: Q [Name] 

What I'm trying to do with this is to get a list of all the imported functions starting with test_ and run the tests automatically.

+4
source share
1 answer

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.

+2
source

All Articles