diff options
author | Óscar Nájera <hi@oscarnajera.com> | 2021-07-04 23:52:01 +0200 |
---|---|---|
committer | Óscar Nájera <hi@oscarnajera.com> | 2021-07-04 23:52:01 +0200 |
commit | 226740b45a5a94811404f4fabfb09f0100ddf61f (patch) | |
tree | fa27fddc8ea81749c6c4558b5fdc9c2bbc4750a9 | |
parent | 8d1554b1eb97d4456fa4d042327ac3829c9e27ff (diff) | |
download | programmingbitcoin-226740b45a5a94811404f4fabfb09f0100ddf61f.tar.gz programmingbitcoin-226740b45a5a94811404f4fabfb09f0100ddf61f.tar.bz2 programmingbitcoin-226740b45a5a94811404f4fabfb09f0100ddf61f.zip |
Overlapping show
-rw-r--r-- | ecc.hs | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -57,7 +57,12 @@ data ECPoint a } deriving (Eq) -instance KnownNat n => Show (ECPoint (FieldElement n)) where + +instance {-# OVERLAPPABLE #-} (PrintfArg a, Num a) => Show (ECPoint a) where + show Infinity = "ECPoint(Infinity)" + show p = printf "ECPoint(%f, %f)_%f_%f" (x p) (y p) (a p) (b p) + +instance {-# OVERLAPPING #-} KnownNat n => Show (ECPoint (FieldElement n)) where show Infinity = "ECPoint(Infinity)" show p | n == (2 ^ 256 - 2 ^ 32 - 977) = "S256Point" ++ points |