packages feed

modulespection-0.1.0.6: modulespection.cabal

-- Initial modulespection.cabal generated by cabal init.  For further 
-- documentation, see http://haskell.org/cabal/users-guide/

name:                modulespection
version:             0.1.0.6
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). 
 . 
 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 
 > -- 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. 
 .
 > import Data.Aeson.TH (deriveJSON, defaultOptions)
 > import MonadUtils (concatMapM)
 > import Language.Haskell.TH.Module.Magic (names)
 > 
 > data Test = Test Int
 > newtype OtherTest = OtherTest Test
 >
 > concatMapM (deriveJSON defaultOptions) =<< declarations
 .
 Which will make JSON instances for Test, OtherTest and any other types
 added to the file.
 .
 You can also do the same thing for an existing module.
 .
 > import Data.Aeson.TH (deriveJSON, defaultOptions)
 > import MonadUtils (concatMapM)
 > import Language.Haskell.TH.Module.Magic (names)
 > import Data.Monoid
 > 
 > concatMapM (deriveJSON defaultOptions) =<< moduleDeclarations "Data.Monoid"
 .
 Which will build instances for all the types in "Data.Monoid".

license:             BSD3
license-file:        LICENSE
author:              Jonathan Fischoff
maintainer:          jonathangfischoff@gmail.com
homepage: https://github.com/jfischoff/modulespection
-- copyright:           
category:            Language
build-type:          Simple
-- extra-source-files:  
cabal-version:       >=1.10

library
  exposed-modules:     Language.Haskell.TH.Module.Magic
  -- other-modules:       
  other-extensions: LambdaCase
                  , FlexibleInstances
  build-depends: base >=4.6 && <4.7
               , template-haskell >=2.7 && <2.9
               , ghc-paths >=0.1 && <0.2
               , ghc
               , temporary == 1.2.*
               , exceptions == 0.3.*
               , transformers == 0.3.*
               , filepath == 1.3.*
  hs-source-dirs:      src
  default-language:    Haskell2010