Closed viviag closed 6 years ago
Seems that approach with toType
functions is applicable for every restriction e.g. existing wrapper Prime
. See message of https://github.com/cartazio/arithmoi/pull/108/commits/b0d0c1bd94f67321b08d59c233ca3ae9306e1572
Here we expect p
is prime and it's checked earlier.
We do not push errors here back and can expect nontermination later if p
is actually not a prime
let (Just c) = Moduli.sqrtModMaybe (-1) (FieldCharacteristic (PrimeNat . integerToNatural $ p) 1)
sqrtModMaybe
I'll leave direct calls to constructor in tests.Merged! Huge thanks for your contribution.
Covers #87 (Not closes since there is still strange internal design) Possible workaround here:
PrimeNat
.data Residue a = Quadratic a | NonQuadratic a
. It looks like reflecting terminology to type system is a good approach.