system-uuid 0.0.0 → 0.0.1
raw patch · 3 files changed
+48/−6 lines, 3 files
Files
- MacroMacros.hs +38/−0
- Macros.hs +6/−4
- system-uuid.cabal +4/−2
+ MacroMacros.hs view
@@ -0,0 +1,38 @@++{-| Macros for macros. + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}++{-# LANGUAGE TemplateHaskell+ #-}++module MacroMacros where+++import Control.Applicative+import Language.Haskell.TH+import Language.Haskell.TH.Syntax++++presentFile = recover newTH oldTH+ where+ oldTH = do+ reify name + return $ InfixE+ (Just $ VarE $ mkName "fileName")+ (VarE $ mkName "<$>")+ (Just $ VarE name)+ where+ name = mkName "currentModule"+ newTH = do + return $ InfixE+ (Just $ VarE $ mkName "loc_filename")+ (VarE $ mkName "<$>")+ (Just $ VarE $ mkName "location")+++fileName mod = map replace mod ++ ".hs"+ where+ replace '.' = '/'+ replace c = c+
Macros.hs view
@@ -9,9 +9,12 @@ module Macros where +import MacroMacros+ import Language.Haskell.TH import Language.Haskell.TH.Syntax import Data.List+import Control.Applicative import Text.Regex @@ -23,9 +26,9 @@ {-| Extract the usage from the module we're in and put it here. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} usage = lift =<< do- mod <- currentModule+ p <- $(presentFile) runIO $ do- s <- readFile $ fileName mod+ s <- readFile p return $ extractUsage s where fileName mod = map replace mod ++ ".hs"@@ -45,10 +48,9 @@ r <//> s = matchRegex (mkRegexWithOpts r False True) s regex = ".*\\{-([\t -]*\n)+([ \t]+(SYNOPSIS|USAGE))(.+)\n[-\t ]*-\\}" + -- normalizeLeadingEmptyLines normalizeLeadingEmpties = ('\n':) . dropWhile (`elem` "\n \t") normalizeEmptyLines'' = reverse . normalizeLeadingEmpties . reverse--
system-uuid.cabal view
@@ -1,5 +1,5 @@ name : system-uuid-version : 0.0.0+version : 0.0.1 category : System license : BSD3 license-file : LICENSE@@ -8,7 +8,8 @@ homepage : http://github.com/jsnx/system-uuid/ synopsis : Bindings to system UUID functions. description :- Bindings to the native UUID generator for a number of platforms.+ Bindings to the native UUID generator for a number of platforms. Please+ contact the author if your platform is not supported. cabal-version : >= 1.2@@ -17,6 +18,7 @@ CONTRIBUTORS Options.hs Macros.hs+ MacroMacros.hs Messages.hs