Skip to content

Commit

Permalink
Added integer-simple flag.
Browse files Browse the repository at this point in the history
This allows the library to build with GHC versions using the
integer-simple library instead of integer-gmp.

I think this should resolve issues swamp-agr#1 and swamp-agr#8.
  • Loading branch information
Philipp Kant committed Jun 28, 2015
1 parent c1a95ae commit f9329c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
10 changes: 8 additions & 2 deletions Blaze/Text/Int.hs
Expand Up @@ -30,11 +30,15 @@ import GHC.Types (Int(..))
# if __GLASGOW_HASKELL__ < 611
import GHC.Integer.Internals
# else
import GHC.Integer.GMP.Internals
#ifdef INTEGER_GMP
import GHC.Integer.GMP.Internals
#elseif defined (INTEGER_SIMPLE)
import GHC.Integer.Simple.Internals
#endif
# endif
#endif

#ifdef INTEGER_GMP
#if defined (INTEGER_GMP) || defined (INTEGER_SIMPLE)
# define PAIR(a,b) (# a,b #)
#else
# define PAIR(a,b) (a,b)
Expand Down Expand Up @@ -106,7 +110,9 @@ int = integral
{-# INLINE int #-}

integer :: Integer -> Builder
#ifdef INTEGER_GMP
integer (S# i#) = int (I# i#)
#endif
integer i
| i < 0 = minus `mappend` go (-i)
| otherwise = go i
Expand Down
22 changes: 16 additions & 6 deletions blaze-textual.cabal
Expand Up @@ -35,6 +35,11 @@ flag native
default: True
manual: True

flag integer-simple
description: use integer-simple instead of integer-gmp
default: False
manual: True

library
exposed-modules:
Blaze.Text
Expand Down Expand Up @@ -67,13 +72,18 @@ library

ghc-options: -Wall

if impl(ghc >= 6.11)
cpp-options: -DINTEGER_GMP
build-depends: integer-gmp >= 0.2
if flag(integer-simple) && impl(ghc >= 6.12.1)
cpp-options: -DINTEGER_SIMPLE
build-depends: integer-simple

else
if impl(ghc >= 6.11)
cpp-options: -DINTEGER_GMP
build-depends: integer-gmp >= 0.2

if impl(ghc >= 6.9) && impl(ghc < 6.11)
cpp-options: -DINTEGER_GMP
build-depends: integer >= 0.1 && < 0.2
if impl(ghc >= 6.9) && impl(ghc < 6.11)
cpp-options: -DINTEGER_GMP
build-depends: integer >= 0.1 && < 0.2

test-suite tests
type: exitcode-stdio-1.0
Expand Down

0 comments on commit f9329c1

Please sign in to comment.