th-desugar 1.5.2 → 1.5.3
raw patch · 7 files changed
+44/−52 lines, 7 filesdep +th-desugarPVP ok
version bump matches the API change (PVP)
Dependencies added: th-desugar
API changes (from Hackage documentation)
Files
- CHANGES.md +4/−0
- Language/Haskell/TH/Desugar/Reify.hs +17/−31
- Test/Dec.hs +3/−3
- Test/DsDec.hs +3/−3
- Test/Run.hs +5/−5
- Test/Splices.hs +5/−5
- th-desugar.cabal +7/−5
CHANGES.md view
@@ -1,3 +1,7 @@+Version 1.5.3+-------------+* More `DsMonad` instances, thanks to David Fox.+ Version 1.5.2 ------------- * Sweeten kinds more, too.
Language/Haskell/TH/Desugar/Reify.hs view
@@ -21,6 +21,9 @@ ) where import Control.Monad.Reader+import Control.Monad.State+import Control.Monad.Writer+import Control.Monad.RWS import Data.List import Data.Maybe #if __GLASGOW_HASKELL__ < 709@@ -28,6 +31,7 @@ #endif import qualified Data.Set as S +import Language.Haskell.TH.Instances () import Language.Haskell.TH.Syntax hiding ( lift ) import Language.Haskell.TH.Desugar.Util@@ -134,47 +138,29 @@ -- | A convenient implementation of the 'DsMonad' class. Use by calling -- 'withLocalDeclarations'. newtype DsM q a = DsM (ReaderT [Dec] q a)- deriving (Functor, Applicative, Monad, MonadTrans)--instance Quasi q => Quasi (DsM q) where- qNewName = lift `comp1` qNewName- qReport = lift `comp2` qReport- qLookupName = lift `comp2` qLookupName- qReify = lift `comp1` qReify- qReifyInstances = lift `comp2` qReifyInstances- qLocation = lift qLocation- qRunIO = lift `comp1` qRunIO- qAddDependentFile = lift `comp1` qAddDependentFile-#if __GLASGOW_HASKELL__ >= 707- qReifyRoles = lift `comp1` qReifyRoles- qReifyAnnotations = lift `comp1` qReifyAnnotations- qReifyModule = lift `comp1` qReifyModule- qAddTopDecls = lift `comp1` qAddTopDecls- qAddModFinalizer = lift `comp1` qAddModFinalizer- qGetQ = lift qGetQ- qPutQ = lift `comp1` qPutQ-#endif- - qRecover (DsM handler) (DsM body) = DsM $ do- env <- ask- lift $ qRecover (runReaderT handler env) (runReaderT body env)+ deriving (Functor, Applicative, Monad, MonadTrans, Quasi) instance Quasi q => DsMonad (DsM q) where localDeclarations = DsM ask +instance DsMonad m => DsMonad (ReaderT r m) where+ localDeclarations = lift localDeclarations++instance DsMonad m => DsMonad (StateT s m) where+ localDeclarations = lift localDeclarations++instance (DsMonad m, Monoid w) => DsMonad (WriterT w m) where+ localDeclarations = lift localDeclarations++instance (DsMonad m, Monoid w) => DsMonad (RWST r w s m) where+ localDeclarations = lift localDeclarations + -- | Add a list of declarations to be considered when reifying local -- declarations. withLocalDeclarations :: DsMonad q => [Dec] -> DsM q a -> q a withLocalDeclarations new_decs (DsM x) = do orig_decs <- localDeclarations runReaderT x (orig_decs ++ new_decs)---- helper functions for composition-comp1 :: (b -> c) -> (a -> b) -> a -> c-comp1 = (.)--comp2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d-comp2 f g a b = f (g a b) --------------------------- -- Reifying local declarations
Test/Dec.hs view
@@ -14,10 +14,10 @@ {-# OPTIONS_GHC -fno-warn-orphans -fno-warn-name-shadowing #-} -module Test.Dec where+module Dec where -import qualified Test.Splices as S-import Test.Splices ( unqualify )+import qualified Splices as S+import Splices ( unqualify ) $(S.dectest1) $(S.dectest2)
Test/DsDec.hs view
@@ -15,10 +15,10 @@ {-# OPTIONS_GHC -fno-warn-orphans -fno-warn-incomplete-patterns -fno-warn-name-shadowing #-} -module Test.DsDec where+module DsDec where -import qualified Test.Splices as S-import Test.Splices ( dsDecSplice, unqualify )+import qualified Splices as S+import Splices ( dsDecSplice, unqualify ) import Language.Haskell.TH ( reportError ) import Language.Haskell.TH.Desugar
Test/Run.hs view
@@ -12,7 +12,7 @@ -fno-warn-unused-matches -fno-warn-type-defaults -fno-warn-missing-signatures -fno-warn-unused-do-bind #-} -module Test.Run where+module Run where import Prelude hiding ( exp ) @@ -20,10 +20,10 @@ import Test.Hspec hiding ( runIO ) -- import Test.Hspec.HUnit -import Test.Splices-import qualified Test.DsDec-import qualified Test.Dec-import Test.Dec ( RecordSel )+import Splices+import qualified DsDec+import qualified Dec+import Dec ( RecordSel ) import Language.Haskell.TH.Desugar import Language.Haskell.TH import qualified Language.Haskell.TH.Syntax as Syn ( lift )
Test/Splices.hs view
@@ -13,7 +13,7 @@ {-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-name-shadowing #-} -module Test.Splices where+module Splices where import Data.List import Data.Char@@ -36,8 +36,8 @@ testDecSplice :: Int -> Q Exp testDecSplice n = do- let dsName = mkName $ "Test.DsDec.Dec" ++ show n- regName = mkName $ "Test.Dec.Dec" ++ show n+ let dsName = mkName $ "DsDec.Dec" ++ show n+ regName = mkName $ "Dec.Dec" ++ show n infoDs <- reify dsName infoReg <- reify regName #if __GLASGOW_HASKELL__ < 707@@ -295,8 +295,8 @@ testRecSelTypes :: Int -> Q Exp testRecSelTypes n = do- VarI _ ty1 _ _ <- reify (mkName ("Test.DsDec.recsel" ++ show n))- VarI _ ty2 _ _ <- reify (mkName ("Test.Dec.recsel" ++ show n))+ VarI _ ty1 _ _ <- reify (mkName ("DsDec.recsel" ++ show n))+ VarI _ ty2 _ _ <- reify (mkName ("Dec.recsel" ++ show n)) let ty1' = return $ unqualify ty1 ty2' = return $ unqualify ty2 [| let x :: $ty1'
th-desugar.cabal view
@@ -1,5 +1,5 @@ name: th-desugar-version: 1.5.2+version: 1.5.3 cabal-version: >= 1.10 synopsis: Functions to desugar Template Haskell homepage: http://www.cis.upenn.edu/~eir/packages/th-desugar@@ -26,7 +26,7 @@ source-repository this type: git location: https://github.com/goldfirere/th-desugar.git- tag: v1.5.2+ tag: v1.5.3 library build-depends: @@ -52,11 +52,12 @@ test-suite spec type: exitcode-stdio-1.0- ghc-options: -Wall -main-is Test.Run+ ghc-options: -Wall -main-is Run default-language: Haskell2010 default-extensions: TemplateHaskell- main-is: Test/Run.hs- other-modules: Test.Splices, Test.Dec, Test.DsDec+ hs-source-dirs: Test+ main-is: Run.hs+ other-modules: Splices, Dec, DsDec build-depends: base >= 4 && < 5,@@ -66,5 +67,6 @@ syb >= 0.4, HUnit >= 1.2, hspec >= 1.3,+ th-desugar, th-lift >= 0.6.1, th-orphans >= 0.9.1