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

Safe HaskellNone
LanguageHaskell98

Language.Haskell.Extract

Synopsis

Documentation

functionExtractor :: String -> ExpQ Source #

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 -> ExpQ Source #

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 :: ExpQ Source #

Extract the name of the current module.