Language.Haskell.Extract
- functionExtractor :: String -> ExpQ
- functionExtractorMap :: String -> ExpQ -> ExpQ
- locationModule :: ExpQ
Documentation
functionExtractor :: String -> ExpQSource
Extract the names and functions from the module where this function is called.
foo = "test" boo = "testing" bar = $(functionExtractor "oo$")
will automagically extract the functions ending with oo such as
bar = [("foo",foo), ("boo",boo)]
functionExtractorMap :: String -> ExpQ -> ExpQSource
Extract the names and functions from the module and apply a function to every pair.
Is very useful if the common denominator of the functions is just a type class.
secondTypeclassTest =
do let expected = ["45", "88.8", "\"hej\""]
actual = $(functionExtractorMap "^tc" [|\n f -> show f|] )
expected @=? actual
tcInt :: Integer
tcInt = 45
tcDouble :: Double
tcDouble = 88.8
tcString :: String
tcString = "hej"
Extract the name of the current module.