From 226740b45a5a94811404f4fabfb09f0100ddf61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20N=C3=A1jera?= Date: Sun, 4 Jul 2021 23:52:01 +0200 Subject: Overlapping show --- ecc.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3