Integer representation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Integer representation

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.
Reply | Threaded
Open this post in threaded view
|

Re: Integer representation

Andrew Martin
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 <[hidden email]> 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.
_______________________________________________
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

_______________________________________________
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.
Reply | Threaded
Open this post in threaded view
|

Re: Integer representation

Claude Heiland-Allen-3
In reply to this post by David Feuer
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.
Reply | Threaded
Open this post in threaded view
|

Re: Integer representation

David Feuer
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
<[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

Re: Integer representation

Claude Heiland-Allen-3
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=flag#configuration-flags

>
> On Thu, Apr 19, 2018 at 3:01 PM, Claude Heiland-Allen
> <[hidden email]> 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
_______________________________________________
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.
Reply | Threaded
Open this post in threaded view
|

Re: Integer representation

Andrew Martin
In reply to this post by Claude Heiland-Allen-3
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 <[hidden email]> 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.



--
-Andrew Thaddeus Martin

_______________________________________________
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.
Reply | Threaded
Open this post in threaded view
|

Re: Integer representation

Oleg Grenrus
In reply to this post by David Feuer
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
> <[hidden email]> 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.


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

signature.asc (836 bytes) Download Attachment