arithmoi icon indicating copy to clipboard operation
arithmoi copied to clipboard

Wrap known prime numbers

Open hacatu opened this issue 4 years ago • 1 comments

Currently, as far as I can tell there is no way to use externally sourced prime numbers. If I use primesieve or some other method to make a bunch of prime numbers, but then I want to call sqrtsModPrime or one of its related functions, I cannot do this unless I wrap the number in fromJust $ isPrime p or something like that.

Why?

Just exposing the type constructor would allow users to circumvent the guarantees arithmoi itself has, but this is necessary for neat integration with other libraries. Plus, wrapping primes could be exposed as a function with a name like unsafeWrapPrime so people totally wouldn't use it unless they needed it.

hacatu avatar Jan 07 '21 06:01 hacatu

Yes, makes sense.

Because of GHC 9.0 changes, primes in arithmoi require a huge overhaul anyways. I'm painfully slowly fleshing out Math.NumberTheory.Primes as a separate library.

Bodigrim avatar Jan 07 '21 19:01 Bodigrim