[Haskell-cafe] Integer representation
Oleg Grenrus
oleg.grenrus at iki.fi
Thu Apr 19 20:44:19 UTC 2018
Hi David,
you could check http://hackage.haskell.org/package/integer-logarithms
I don't use different source-dirs (I could), the implementation isn't
that different so CPP didn't felt too intrusive.
The
http://cabal.readthedocs.io/en/latest/developing-packages.html#resolution-of-conditions-and-flags
section speaks about automatic flags.
TL;DR cabal solver will toggle _automatic_ flags (manual flags are set
to defaults). It's recommended to make flag assignment disjoint, e.g.
note how bytestring version ranges are disjoint.
if flag(bytestring-builder)
build-depends: bytestring >= 0.9.2 && < 0.10.4,
bytestring-builder >= 0.10.4 && < 1
else
build-depends: bytestring >= 0.10.4 && < 0.11
Similarly, in `integer-logarithms` we have
flag integer-gmp
description: integer-gmp or integer-simple
default: True
manual: False
library
...
if flag(integer-gmp)
build-depends:
integer-gmp < 1.1
else
build-depends:
integer-simple
-- here we could have hs-source-dirs
relying that there aren't install plan with both integer-gmp and
integer-simple
For very complicated example see: functor-classes-compat
http://hackage.haskell.org/package/functor-classes-compat-1/functor-classes-compat.cabal
Hopefully these help
Cheers, Oleg.
On 19.04.2018 23:05, David Feuer wrote:
> I'm not familiar with automatic cabal flags. Could you point me to
> documentation?
>
> On Thu, Apr 19, 2018 at 3:01 PM, Claude Heiland-Allen
> <claude at mathr.co.uk> wrote:
>> Hi David,
>>
>> On 19/04/18 18:13, David Feuer wrote:
>>> Is there any way to determine whether Integer comes from integer-gmp
>>> or integer-simple? I'm playing with the idea of using the underlying
>>> representation to get more compact/efficient tries, but I need to be
>>> able to find out what that representation is.
>> One way could be to use an automatic cabal flag. With it enabled,
>> depend on integer-gmp and add hs-source-dirs to a directory containing
>> your integer-gmp implementation, with it disabled, depend on
>> integer-simple and add hs-source dirs to a directory containing your
>> integer-simple implementation. This gives module-level control. With
>> automatic flag I think cabal will try both and choose the setting that
>> gives the best build plan (likely corresponding to the Integer
>> implementation of your ghc).
>>
>>
>> Claude
>> --
>> https://mathr.co.uk
>> _______________________________________________
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>> Only members subscribed via the mailman list are allowed to post.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180419/d77c0f9a/attachment.sig>
More information about the Haskell-Cafe
mailing list