git.iko.soy/haskell-generate
on master help sign in
6 files changed+25−16
since splitsnapshots
unifiedsplit
.travis.yml+4−3 LICENSE+1−1 README.md−1 haskell-generate.cabal+8−6 src/Language/Haskell/Generate/Monad.hs+11−3 tests/doctests.hsc+1−2
.travis.yml+4−3
@@ -2,7 +2,8 @@ env:
22 - GHCVER=7.4.2 CABALVER=1.16
33 - GHCVER=7.6.3 CABALVER=1.18
44 - GHCVER=7.8.3 CABALVER=1.20
5− - GHCVER=head CABALVER=1.20
5+ - GHCVER=7.10.2 CABALVER=1.22
6+ - GHCVER=head CABALVER=1.22
67
78before_install:
89 - sudo add-apt-repository -y ppa:hvr/ghc
@@ -21,5 +22,5 @@ script:
2122
2223matrix:
2324 allow_failures:
24− - env: GHCVER=head CABALVER=1.20
25− fast_finish: true
25+ - env: GHCVER=head CABALVER=1.22
26+ fast_finish: true
LICENSE+1−1
@@ -1,4 +1,4 @@
1−Copyright 2013-2014 Benno Fünfstück
1+Copyright 2013-2015 Benno Fünfstück
22
33All rights reserved.
44
README.md−1
@@ -102,4 +102,3 @@ declareFunction 'permutations -- This generates the same code as above, but is m
102102## Contributing
103103
104104If you have an idea, a question or a bug report, open an issue on github. You can also find me on freenode in the #haskell channel, my nick is bennofs.
105−
haskell-generate.cabal+8−6
@@ -1,5 +1,5 @@
11name: haskell-generate
2−version: 0.2.2
2+version: 0.2.4
33license: BSD3
44category: Code Generation, Language
55cabal-version: >= 1.10
@@ -9,9 +9,13 @@ maintainer: Benno Fünfstück <benno.fuenfstueck@gmail.com>
99stability: experimental
1010homepage: http://github.com/bennofs/haskell-generate/
1111bug-reports: http://github.com/bennofs/haskell-generate/issues
12−copyright: Copyright (C) 2013 Benno Fünfstück
13−synopsis: haskell-generate
14−description: haskell-generate
12+copyright: Copyright (C) 2013-2015 Benno Fünfstück
13+synopsis: Typesafe generation of haskell source code
14+description:
15+ This library provides an interface to generate haskell source code, verifying at compile time
16+ that the resulting code typechecks.
17+ See <https://github.com/bennofs/haskell-generate haskell-generate> for an
18+ introduction explaining how to use the library.
1519build-type: Custom
1620
1721extra-source-files:
@@ -53,6 +57,4 @@ test-suite doctests
5357 , doctest >= 0.9.1
5458 , filepath
5559 ghc-options: -Wall -threaded
56− if impl(ghc<7.6.1)
57− ghc-options: -Werror
5860 hs-source-dirs: tests
src/Language/Haskell/Generate/Monad.hs+11−3
@@ -36,6 +36,8 @@ import Language.Haskell.Exts.SrcLoc
3636import Language.Haskell.Exts.Syntax
3737import Language.Haskell.Generate.Expression
3838
39+import Prelude
40+
3941--------------------------------------------------------------------------------
4042-- Generate expressions
4143
@@ -62,9 +64,11 @@ generateExp = prettyPrint . runExpression . fst . runGenerate
6264caseE :: ExpG x -> [(Pat, ExpG t)] -> ExpG t
6365caseE v alt = do
6466 v' <- v
65−#if MIN_VERSION_haskell_src_exts(1,16,0)
67+#if MIN_VERSION_haskell_src_exts(1,17,0)
68+ alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedRhs $ runExpression a') Nothing) a) alt
69+#elif MIN_VERSION_haskell_src_exts(1,16,0)
6670 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedRhs $ runExpression a') (BDecls [])) a) alt
67−#else
71+#else
6872 alt' <- mapM (\(p,a) -> fmap (\a' -> Alt noLoc p (UnGuardedAlt $ runExpression a') (BDecls [])) a) alt
6973#endif
7074 return $ Expression $ Case (runExpression v') alt'
@@ -210,7 +214,7 @@ instance GenExp (FunRef t) where
210214
211215-- | Generate a ExportSpec for a given function item.
212216exportFun :: FunRef t -> ExportSpec
213−#if MIN_VERSION_haskell_src_exts(1,16,0)
217+#if MIN_VERSION_haskell_src_exts(1,16,0) && !MIN_VERSION_haskell_src_exts(1,17,0)
214218exportFun (FunRef name) = EVar NoNamespace (UnQual name)
215219#else
216220exportFun (FunRef name) = EVar (UnQual name)
@@ -220,7 +224,11 @@ exportFun (FunRef name) = EVar (UnQual name)
220224addDecl :: Name -> ExpG t -> ModuleM (FunRef t)
221225addDecl name e = ModuleM $ do
222226 let (body, mods) = runGenerate e
227+#if MIN_VERSION_haskell_src_exts(1,17,0)
228+ tell (mods, [FunBind [Match noLoc name [] Nothing (UnGuardedRhs $ runExpression body) Nothing]])
229+#else
223230 tell (mods, [FunBind [Match noLoc name [] Nothing (UnGuardedRhs $ runExpression body) $ BDecls []]])
231+#endif
224232 return $ FunRef name
225233
226234-- | Extract the Module from a module generator.
tests/doctests.hsc+1−2
@@ -20,18 +20,17 @@ import Data.List
2020import System.Directory
2121import System.FilePath
2222import Test.DocTest
23+import Prelude
2324
2425##ifdef mingw32_HOST_ARCH
2526##ifdef i386_HOST_ARCH
2627##define USE_CP
27−import Control.Applicative
2828import Control.Exception
2929import Foreign.C.Types
3030foreign import stdcall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool
3131foreign import stdcall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt
3232##elif defined(x86_64_HOST_ARCH)
3333##define USE_CP
34−import Control.Applicative
3534import Control.Exception
3635import Foreign.C.Types
3736foreign import ccall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool