ccef06da41
Was able to reuse many of the android patches, but several had to be re-done. On Android, ghc is a stage2 build, so can compile, but not run TH code. But debian's ghc on armel cannot even compile TH code, so it has to be patched out. Some haskell packages have been updated to new versions, including yesod and DAV, and their patches had to be redone. The Makefile now has 2 new targets. The first is run on a companion x86 system to do the build and get TH splices. Then the second target is run the same source tree on the arm system to build without needing TH. This commit was sponsored by Svenne Krap.
150 lines
4.2 KiB
Diff
150 lines
4.2 KiB
Diff
From 08aa9d495cb486c45998dfad95518c646b5fa8cc Mon Sep 17 00:00:00 2001
|
|
From: Joey Hess <joey@kitenet.net>
|
|
Date: Tue, 17 Dec 2013 16:24:31 +0000
|
|
Subject: [PATCH] remove TH
|
|
|
|
---
|
|
Control/Monad/Logger.hs | 109 ++++++++++--------------------------------------
|
|
1 file changed, 21 insertions(+), 88 deletions(-)
|
|
|
|
diff --git a/Control/Monad/Logger.hs b/Control/Monad/Logger.hs
|
|
index be756d7..d4979f8 100644
|
|
--- a/Control/Monad/Logger.hs
|
|
+++ b/Control/Monad/Logger.hs
|
|
@@ -31,31 +31,31 @@ module Control.Monad.Logger
|
|
, withChannelLogger
|
|
, NoLoggingT (..)
|
|
-- * TH logging
|
|
- , logDebug
|
|
- , logInfo
|
|
- , logWarn
|
|
- , logError
|
|
- , logOther
|
|
+ --, logDebug
|
|
+ --, logInfo
|
|
+ --, logWarn
|
|
+ --, logError
|
|
+ --, logOther
|
|
-- * TH logging with source
|
|
- , logDebugS
|
|
- , logInfoS
|
|
- , logWarnS
|
|
- , logErrorS
|
|
- , logOtherS
|
|
+ --, logDebugS
|
|
+ --, logInfoS
|
|
+ --, logWarnS
|
|
+ --, logErrorS
|
|
+ --, logOtherS
|
|
-- * TH util
|
|
- , liftLoc
|
|
+ -- , liftLoc
|
|
-- * Non-TH logging
|
|
- , logDebugN
|
|
- , logInfoN
|
|
- , logWarnN
|
|
- , logErrorN
|
|
- , logOtherN
|
|
+ --, logDebugN
|
|
+ --, logInfoN
|
|
+ --, logWarnN
|
|
+ --, logErrorN
|
|
+ --, logOtherN
|
|
-- * Non-TH logging with source
|
|
- , logDebugNS
|
|
- , logInfoNS
|
|
- , logWarnNS
|
|
- , logErrorNS
|
|
- , logOtherNS
|
|
+ --, logDebugNS
|
|
+ --, logInfoNS
|
|
+ --, logWarnNS
|
|
+ --, logErrorNS
|
|
+ --, logOtherNS
|
|
) where
|
|
|
|
import Language.Haskell.TH.Syntax (Lift (lift), Q, Exp, Loc (..), qLocation)
|
|
@@ -115,13 +115,6 @@ import Control.Monad.Writer.Class ( MonadWriter (..) )
|
|
data LogLevel = LevelDebug | LevelInfo | LevelWarn | LevelError | LevelOther Text
|
|
deriving (Eq, Prelude.Show, Prelude.Read, Ord)
|
|
|
|
-instance Lift LogLevel where
|
|
- lift LevelDebug = [|LevelDebug|]
|
|
- lift LevelInfo = [|LevelInfo|]
|
|
- lift LevelWarn = [|LevelWarn|]
|
|
- lift LevelError = [|LevelError|]
|
|
- lift (LevelOther x) = [|LevelOther $ pack $(lift $ unpack x)|]
|
|
-
|
|
type LogSource = Text
|
|
|
|
class Monad m => MonadLogger m where
|
|
@@ -152,66 +145,6 @@ instance (MonadLogger m, Monoid w) => MonadLogger (Strict.WriterT w m) where DEF
|
|
instance (MonadLogger m, Monoid w) => MonadLogger (Strict.RWST r w s m) where DEF
|
|
#undef DEF
|
|
|
|
-logTH :: LogLevel -> Q Exp
|
|
-logTH level =
|
|
- [|monadLoggerLog $(qLocation >>= liftLoc) (pack "") $(lift level) . (id :: Text -> Text)|]
|
|
-
|
|
--- | Generates a function that takes a 'Text' and logs a 'LevelDebug' message. Usage:
|
|
---
|
|
--- > $(logDebug) "This is a debug log message"
|
|
-logDebug :: Q Exp
|
|
-logDebug = logTH LevelDebug
|
|
-
|
|
--- | See 'logDebug'
|
|
-logInfo :: Q Exp
|
|
-logInfo = logTH LevelInfo
|
|
--- | See 'logDebug'
|
|
-logWarn :: Q Exp
|
|
-logWarn = logTH LevelWarn
|
|
--- | See 'logDebug'
|
|
-logError :: Q Exp
|
|
-logError = logTH LevelError
|
|
-
|
|
--- | Generates a function that takes a 'Text' and logs a 'LevelOther' message. Usage:
|
|
---
|
|
--- > $(logOther "My new level") "This is a log message"
|
|
-logOther :: Text -> Q Exp
|
|
-logOther = logTH . LevelOther
|
|
-
|
|
--- | Lift a location into an Exp.
|
|
---
|
|
--- Since 0.3.1
|
|
-liftLoc :: Loc -> Q Exp
|
|
-liftLoc (Loc a b c (d1, d2) (e1, e2)) = [|Loc
|
|
- $(lift a)
|
|
- $(lift b)
|
|
- $(lift c)
|
|
- ($(lift d1), $(lift d2))
|
|
- ($(lift e1), $(lift e2))
|
|
- |]
|
|
-
|
|
--- | Generates a function that takes a 'LogSource' and 'Text' and logs a 'LevelDebug' message. Usage:
|
|
---
|
|
--- > $logDebugS "SomeSource" "This is a debug log message"
|
|
-logDebugS :: Q Exp
|
|
-logDebugS = [|\a b -> monadLoggerLog $(qLocation >>= liftLoc) a LevelDebug (b :: Text)|]
|
|
-
|
|
--- | See 'logDebugS'
|
|
-logInfoS :: Q Exp
|
|
-logInfoS = [|\a b -> monadLoggerLog $(qLocation >>= liftLoc) a LevelInfo (b :: Text)|]
|
|
--- | See 'logDebugS'
|
|
-logWarnS :: Q Exp
|
|
-logWarnS = [|\a b -> monadLoggerLog $(qLocation >>= liftLoc) a LevelWarn (b :: Text)|]
|
|
--- | See 'logDebugS'
|
|
-logErrorS :: Q Exp
|
|
-logErrorS = [|\a b -> monadLoggerLog $(qLocation >>= liftLoc) a LevelError (b :: Text)|]
|
|
-
|
|
--- | Generates a function that takes a 'LogSource', a level name and a 'Text' and logs a 'LevelOther' message. Usage:
|
|
---
|
|
--- > $logOtherS "SomeSource" "My new level" "This is a log message"
|
|
-logOtherS :: Q Exp
|
|
-logOtherS = [|\src level msg -> monadLoggerLog $(qLocation >>= liftLoc) src (LevelOther level) (msg :: Text)|]
|
|
-
|
|
-- | Monad transformer that disables logging.
|
|
--
|
|
-- Since 0.2.4
|
|
--
|
|
1.8.5.1
|
|
|