aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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
commit226740b45a5a94811404f4fabfb09f0100ddf61f (patch)
treefa27fddc8ea81749c6c4558b5fdc9c2bbc4750a9
parent8d1554b1eb97d4456fa4d042327ac3829c9e27ff (diff)
downloadprogrammingbitcoin-226740b45a5a94811404f4fabfb09f0100ddf61f.tar.gz
programmingbitcoin-226740b45a5a94811404f4fabfb09f0100ddf61f.tar.bz2
programmingbitcoin-226740b45a5a94811404f4fabfb09f0100ddf61f.zip
Overlapping show
-rw-r--r--ecc.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/ecc.hs b/ecc.hs
index e639e3a..83a9fb1 100644
--- a/ecc.hs
+++ b/ecc.hs
@@ -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