packages feed

modulespection 0.1.2.1 → 0.1.2.2

raw patch · 2 files changed

+29/−22 lines, 2 filesdep ~exceptionsdep ~transformersPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: exceptions, transformers

API changes (from Hackage documentation)

- Language.Haskell.TH.Module.Magic: instance MonadIO Ghc
+ Language.Haskell.TH.Module.Magic: instance MonadMask Ghc

Files

modulespection.cabal view
@@ -1,40 +1,40 @@--- Initial modulespection.cabal generated by cabal init.  For further +-- Initial modulespection.cabal generated by cabal init.  For further -- documentation, see http://haskell.org/cabal/users-guide/  name:                modulespection-version:             0.1.2.1+version:             0.1.2.2 synopsis:            Template Haskell for introspecting a module's declarations-description: - Collect all of the declarations in a module using Template Haskell (via the GHC API). - . +description:+ Collect all of the declarations in a module using Template Haskell (via the GHC API).+ .  One can either get all the names, or just the declarations (only type declarations  are supported right now).  .  Here is a quick example:- . + .  > import Language.Haskell.TH.Module.Magic (names)- > + >  > data Test = Test Int  > newtype OtherTest = OtherTest Test- > + >  > someFunction :: String -> String  > someFunction = id- > - > -- 'names' is Template Haskell function that will collect all of the + >+ > -- 'names' is Template Haskell function that will collect all of the  > -- toplevel declaration names of the current file.  > names >>= runIO . print >> return []  .  Which will spew the following when compiling:  .  > [Test,OtherTest,someFunction]- . + .  There is also 'declarations' which can be used, for example, to make sure that all- types have @ToJSON@/@FromJSON@ instances. + types have @ToJSON@/@FromJSON@ instances.  .  > import Data.Aeson.TH (deriveJSON, defaultOptions)  > import MonadUtils (concatMapM)  > import Language.Haskell.TH.Module.Magic (declarations)- > + >  > data Test = Test Int  > newtype OtherTest = OtherTest Test  >@@ -49,7 +49,7 @@  > import MonadUtils (concatMapM)  > import Language.Haskell.TH.Module.Magic (moduleDeclarations)  > import Data.Monoid- > + >  > concatMapM (deriveJSON defaultOptions) =<< moduleDeclarations "Data.Monoid"  .  Which will build instances for all the types in "Data.Monoid".@@ -59,24 +59,28 @@ author:              Jonathan Fischoff maintainer:          jonathangfischoff@gmail.com homepage: https://github.com/jfischoff/modulespection--- copyright:           +-- copyright: category:            Language build-type:          Simple--- extra-source-files:  +-- extra-source-files: cabal-version:       >=1.10 +source-repository head+    type: git+    location: git://github.com/jfischoff/modulespection+ library   exposed-modules:     Language.Haskell.TH.Module.Magic-  -- other-modules:       +  -- other-modules:   other-extensions: LambdaCase                   , FlexibleInstances   build-depends: base >=4.6 && < 666-               , template-haskell >=2.7 +               , template-haskell >=2.7                , ghc-paths >=0.1 && <0.2                , ghc                , temporary == 1.2.*-               , transformers == 0.3.*-               , exceptions >= 0.5 && < 0.6+               , transformers == 0.3.* || == 0.4.*+               , exceptions >= 0.5 && < 0.7                , filepath == 1.3.*   hs-source-dirs:      src   default-language:    Haskell2010
src/Language/Haskell/TH/Module/Magic.hs view
@@ -10,7 +10,6 @@    , declarations    , moduleDeclarations    ) where- #include "ghcplatform.h"     import Language.Haskell.TH as TH@@ -92,6 +91,8 @@  instance MonadCatch Ghc where     catch   = gcatch++instance MonadMask Ghc where     mask f =        Ghc $ \s -> mask $ \io_restore ->                               let@@ -101,7 +102,7 @@     uninterruptibleMask = error "uninterruptibleMask" -- | Either try to parse a source file or if the module is --   part of library, look it up and browse the contents-lookupModuleNames :: (MTL.MonadIO m, MonadCatch m, GhcMonad m) +lookupModuleNames :: (MTL.MonadIO m, MonadCatch m, MonadMask m, GhcMonad m)                   => String -> m [TH.Name] lookupModuleNames mName = do       target <- targetId <$> guessTarget mName Nothing@@ -170,7 +171,9 @@  instance GetNameMaybe (TyClDecl RdrName) where    getNameMaybe = \case+#if __GLASGOW_HASKELL__ < 710       ForeignType x _   -> getNameMaybe x+#endif #if __GLASGOW_HASKELL__ >= 707       FamDecl x -> getNameMaybe $ fdLName x        SynDecl  { tcdLName } -> getNameMaybe tcdLName