language-haskell-extract-0.2.4: Module to automatically extract functions from the local code.

Safe HaskellNone

Language.Haskell.Extract

Synopsis

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"

locationModule :: ExpQSource

Extract the name of the current module.