diff --git a/Setup.lhs b/Setup.lhs index 1ad23ed..3c0e9b3 100755 --- a/Setup.lhs +++ b/Setup.lhs @@ -1,7 +1,6 @@ #! /usr/bin/env runhaskell \begin{code} -{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS -Wall #-} ----------------------------------------------------------------------------- @@ -23,37 +22,19 @@ import System.FilePath ( () ) -import Data.Version - ( Version(..) - ) - import Distribution.Simple ( defaultMainWithHooks , simpleUserHooks - , UserHooks(runTests, haddockHook, buildHook) + , UserHooks(runTests) , Args ) import Distribution.Simple.LocalBuildInfo - ( LocalBuildInfo(..) - ) - -import Distribution.Simple.Program - ( userSpecifyArgs - ) - -import Distribution.Simple.Setup - ( HaddockFlags - , BuildFlags + ( LocalBuildInfo ) -import Distribution.Package - import Distribution.PackageDescription - ( PackageDescription(..) - , BuildInfo(..) - , Library(..) - , Executable(..) + ( PackageDescription ) main :: IO () @@ -61,8 +42,6 @@ main = defaultMainWithHooks hooks where hooks = simpleUserHooks { runTests = runTests' - , haddockHook = haddockHook' - , buildHook = buildHook' } -- Run a 'test' binary that gets built when configured with '-ftest'. @@ -72,77 +51,5 @@ runTests' _ _ _ _ = system cmd >> return () testcmd = "." "test" cmd = "cd " ++ testdir ++ " && " ++ testcmd --- Define __HADDOCK__ for CPP when running haddock. This is a workaround for --- Haddock not building the documentation due to some issue with Template --- Haskell. -haddockHook' :: PackageDescription -> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO () -haddockHook' pkg lbi = - haddockHook simpleUserHooks pkg (lbi { withPrograms = p }) - where - p = userSpecifyArgs "haddock" ["--optghc=-D__HADDOCK__"] (withPrograms lbi) - --- Insert CPP flag for building with template-haskell versions >= 2.3. This was --- previously done in the .cabal file, but it was not backwards compatible with --- Cabal 1.2. This should work with Cabal from 1.2 to 1.6 at least. -buildHook' :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO () -buildHook' pkg lbi hooks flags = do - buildHook simpleUserHooks pkg (lbi { localPkgDescr = newPkgDescr }) hooks flags - where - - -- Old local package description - oldPkgDescr = localPkgDescr lbi - - -- New local package description - newPkgDescr = - case thVersion of - Nothing -> - oldPkgDescr - Just version -> - if version >= Version [2,3] [] - then - oldPkgDescr - { library = addThCppToLibrary (library oldPkgDescr) - , executables = map addThCppToExec (executables oldPkgDescr) - } - else - oldPkgDescr - - -- Template Haskell package name - thPackageName = mkPackageName "template-haskell" - - mkPackageName :: (Read a) => String -> a - mkPackageName nm = - fst $ head $ reads shownNm ++ reads ("PackageName " ++ shownNm) - where - shownNm = show nm - - -- template-haskell version - thVersion = findThVersion (packageDeps lbi) - - -- CPP options for template-haskell >= 2.3 - thCppOpt = "-DTH_LOC_DERIVEREP" - - -- Find the version of the template-haskell package - findThVersion [] = Nothing - findThVersion (PackageIdentifier name version:ps) - | name == thPackageName = Just version - | otherwise = findThVersion ps - - -- Add the template-haskell CPP flag to a BuildInfo - addThCppToBuildInfo :: BuildInfo -> BuildInfo - addThCppToBuildInfo bi = - bi { cppOptions = thCppOpt : cppOptions bi } - - -- Add the template-haskell CPP flag to a library package description - addThCppToLibrary :: Maybe Library -> Maybe Library - addThCppToLibrary ml = do - lib <- ml - return (lib { libBuildInfo = addThCppToBuildInfo (libBuildInfo lib) }) - - -- Add the template-haskell CPP flag to an executable package description - addThCppToExec :: Executable -> Executable - addThCppToExec exec = - exec { buildInfo = addThCppToBuildInfo (buildInfo exec) } - \end{code} diff --git a/emgm.cabal b/emgm.cabal index b708431..9a7844b 100644 --- a/emgm.cabal +++ b/emgm.cabal @@ -62,7 +62,6 @@ extra-source-files: README, tests/Collect.hs, tests/Compare.hs, tests/Crush.hs, - tests/Derive.hs, tests/Enum.hs, tests/Everywhere.hs, tests/Main.hs, @@ -129,20 +128,8 @@ Library Generics.EMGM.Data.List Generics.EMGM.Data.Maybe Generics.EMGM.Data.Tuple - Generics.EMGM.Data.TH - -- Deriving - Generics.EMGM.Derive - - other-modules: Generics.EMGM.Derive.Common - Generics.EMGM.Derive.ConDescr - Generics.EMGM.Derive.EP - Generics.EMGM.Derive.Functions - Generics.EMGM.Derive.Instance - Generics.EMGM.Derive.Internal - - build-depends: base >= 3.0 && < 4.0, - template-haskell >= 2.2 && < 2.4 + build-depends: base >= 3.0 && < 5.0 extensions: CPP @@ -162,28 +149,3 @@ Library if flag(nolib) buildable: False --------------------------------------------------------------------------------- - -Executable test - hs-source-dirs: src, tests, examples - other-modules: Generics.EMGM - extensions: CPP - main-is: Main.hs - - build-depends: base >= 3.0 && < 4.0, - template-haskell >= 2.2 && < 2.4 - - -- Only enable the build-depends here if configured with "-ftest". This - -- allows users to use EMGM without having to install QuickCheck. - if flag(test) - build-depends: QuickCheck >= 2.1 && < 2.2, - HUnit >= 1.2 && < 1.3 - else - buildable: False - - ghc-options: -Wall -O0 -fno-warn-missing-signatures - - -- Add program coverage if configured with "-fhpc". - if flag(hpc) - ghc-options: -fhpc - diff --git a/src/Generics/EMGM.hs b/src/Generics/EMGM.hs index 052f05c..da565c7 100644 --- a/src/Generics/EMGM.hs +++ b/src/Generics/EMGM.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | @@ -23,8 +22,6 @@ -- defining functions. -- -- * "Generics.EMGM.Functions" - Generic functions included with EMGM. --- --- * "Generics.EMGM.Derive" - Generating the EMGM representation for a datatype. ----------------------------------------------------------------------------- module Generics.EMGM ( @@ -119,16 +116,6 @@ module Generics.EMGM ( Generic2(..), Generic3(..), - -- ** Deriving Representation - -- - -- | The necessary values and instances for using EMGM with a user-defined - -- datatype can be generated automatically using Template Haskell. By - -- necessity, there are a number of exported values for this process that are - -- unrelated to other uses of the EMGM library. In order to not export these - -- signatures more than necessary, you should import "Generics.EMGM.Derive" - -- for deriving the representation. Note that "Generics.EMGM" does not export - -- anything in "Generics.EMGM.Derive". - -- * Generic Functions -- -- | The following collection of functions use the common EMGM infrastructure diff --git a/src/Generics/EMGM/Data/Bool.hs b/src/Generics/EMGM/Data/Bool.hs index 2e1ccfc..f1fe95b 100644 --- a/src/Generics/EMGM/Data/Bool.hs +++ b/src/Generics/EMGM/Data/Bool.hs @@ -1,10 +1,8 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverlappingInstances #-} -{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS -fno-warn-orphans #-} {- OPTIONS -ddump-splices -} @@ -32,15 +30,9 @@ module Generics.EMGM.Data.Bool ( bifrep2Bool, ) where -import Generics.EMGM.Derive.Internal - -#ifndef __HADDOCK__ - -$(derive ''Bool) - -#else --- The following code is used by Haddock to generate documentation. It may be --- useful to keep around for debugging TH, so don't remove it. +import Generics.EMGM.Common +import Generics.EMGM.Functions.Collect +import Generics.EMGM.Functions.Everywhere ----------------------------------------------------------------------------- -- Embedding-projection pair @@ -117,5 +109,3 @@ instance Rep (Everywhere Bool) Bool where instance Rep (Everywhere' Bool) Bool where rep = Everywhere' ($) -#endif - diff --git a/src/Generics/EMGM/Data/Either.hs b/src/Generics/EMGM/Data/Either.hs index 2f910ed..2932827 100644 --- a/src/Generics/EMGM/Data/Either.hs +++ b/src/Generics/EMGM/Data/Either.hs @@ -1,10 +1,8 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverlappingInstances #-} -{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS -fno-warn-orphans #-} {- OPTIONS -ddump-splices -} @@ -32,15 +30,9 @@ module Generics.EMGM.Data.Either ( bifrep2Either, ) where -import Generics.EMGM.Derive.Internal - -#ifndef __HADDOCK__ - -$(derive ''Either) - -#else --- The following code is used by Haddock to generate documentation. It may be --- useful to keep around for debugging TH, so don't remove it. +import Generics.EMGM.Common +import Generics.EMGM.Functions.Collect +import Generics.EMGM.Functions.Everywhere ----------------------------------------------------------------------------- -- Embedding-projection pair @@ -126,5 +118,3 @@ instance (Rep (Everywhere (Either a b)) a, Rep (Everywhere (Either a b)) b) instance Rep (Everywhere' (Either a b)) (Either a b) where rep = Everywhere' ($) -#endif - diff --git a/src/Generics/EMGM/Data/List.hs b/src/Generics/EMGM/Data/List.hs index 185bd03..1d45196 100644 --- a/src/Generics/EMGM/Data/List.hs +++ b/src/Generics/EMGM/Data/List.hs @@ -29,7 +29,9 @@ module Generics.EMGM.Data.List ( bifrep2List, ) where -import Generics.EMGM.Derive.Internal +import Generics.EMGM.Common +import Generics.EMGM.Functions.Collect +import Generics.EMGM.Functions.Everywhere ----------------------------------------------------------------------------- -- Embedding-projection pair diff --git a/src/Generics/EMGM/Data/Maybe.hs b/src/Generics/EMGM/Data/Maybe.hs index 07e2136..c3e9ea2 100644 --- a/src/Generics/EMGM/Data/Maybe.hs +++ b/src/Generics/EMGM/Data/Maybe.hs @@ -1,10 +1,8 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverlappingInstances #-} -{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS -fno-warn-orphans #-} {- OPTIONS -ddump-splices -} @@ -32,15 +30,9 @@ module Generics.EMGM.Data.Maybe ( bifrep2Maybe, ) where -import Generics.EMGM.Derive.Internal - -#ifndef __HADDOCK__ - -$(derive ''Maybe) - -#else --- The following code is used by Haddock to generate documentation. It may be --- useful to keep around for debugging TH, so don't remove it. +import Generics.EMGM.Common +import Generics.EMGM.Functions.Collect +import Generics.EMGM.Functions.Everywhere ----------------------------------------------------------------------------- -- Embedding-projection pair @@ -131,5 +123,3 @@ instance (Rep (Everywhere (Maybe a)) a) => Rep (Everywhere (Maybe a)) (Maybe a) instance Rep (Everywhere' (Maybe a)) (Maybe a) where rep = Everywhere' ($) -#endif - diff --git a/src/Generics/EMGM/Data/Tuple.hs b/src/Generics/EMGM/Data/Tuple.hs index 6c29a55..42a73b9 100644 --- a/src/Generics/EMGM/Data/Tuple.hs +++ b/src/Generics/EMGM/Data/Tuple.hs @@ -86,7 +86,9 @@ module Generics.EMGM.Data.Tuple ( ) where -import Generics.EMGM.Derive.Internal +import Generics.EMGM.Common +import Generics.EMGM.Functions.Collect +import Generics.EMGM.Functions.Everywhere ----------------------------------------------------------------------------- -- 0: () diff --git a/src/Generics/EMGM/Functions/Everywhere.hs b/src/Generics/EMGM/Functions/Everywhere.hs index cef8ea9..9101cb1 100644 --- a/src/Generics/EMGM/Functions/Everywhere.hs +++ b/src/Generics/EMGM/Functions/Everywhere.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -31,7 +30,7 @@ -- -- @ -- -- SYB --- everywhere :: (forall a. 'Data' a => a -> a) -> forall a. 'Data' a => a -> a +-- everywhere :: (forall a. Data a => a -> a) -> forall a. Data a => a -> a -- @ -- -- @ @@ -50,10 +49,6 @@ module Generics.EMGM.Functions.Everywhere ( import Generics.EMGM.Common.Base import Generics.EMGM.Common.Representation -#ifdef __HADDOCK__ -import Data.Generics (Data) -#endif - -------------------------------------------------------------------------------- -- Types --------------------------------------------------------------------------------