Integer representation

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.

Here a guess:
#if !(MIN_VERSION_integer-gmp(0,0,0))
Not sure if this works, but it might.
On Thu, Apr 19, 2018 at 1:13 PM, David Feuer
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. _______________________________________________ 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.
-- -Andrew Thaddeus Martin

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

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
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.

On 19/04/18 21:05, David Feuer wrote:
I'm not familiar with automatic cabal flags. Could you point me to documentation?
https://www.haskell.org/cabal/users-guide/developing-packages.html?highlight...
On Thu, Apr 19, 2018 at 3:01 PM, Claude Heiland-Allen
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.
Claude -- https://mathr.co.uk

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... 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-... 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
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.

I've never realized how it worked before your explanation of automatic
flags, but this is what the bytestring library does to depend on
integer-gmp/integer-simple.
On Thu, Apr 19, 2018 at 3:01 PM, Claude Heiland-Allen
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.
-- -Andrew Thaddeus Martin
participants (4)
-
Andrew Martin
-
Claude Heiland-Allen
-
David Feuer
-
Oleg Grenrus