fixed

Pure Haskell large fixed-width integers.
git clone git://git.ppad.tech/fixed.git
Log | Files | Refs | README | LICENSE

commit 1ee2b4f9c8f96b29071d29ed19e34c786c3c7481
parent 085c244b34572417f3216a775e443cafbc20026d
Author: Jared Tobin <jared@jtobin.io>
Date:   Mon, 24 Nov 2025 20:02:12 +0400

lib: basic Eq instance for Wider

Diffstat:
Mlib/Data/Word/Wider.hs | 11+++++++++--
Mlib/Numeric/Montgomery/Secp256k1/Curve.hs | 2+-
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/Data/Word/Wider.hs b/lib/Data/Word/Wider.hs @@ -32,13 +32,17 @@ wrapping_neg# w = plusWord# (not# w) 1## -- | Little-endian wider words. data Wider = Wider !(# Word#, Word#, Word#, Word# #) +instance Eq Wider where + Wider a == Wider b = C.decide (C.ct_eq_wider# a b) + instance Show Wider where show (Wider (# a, b, c, d #)) = "(" <> show (W# a) <> ", " <> show (W# b) <> ", " <> show (W# c) <> ", " <> show (W# d) <> ")" instance NFData Wider where - rnf (Wider a) = case a of (# _, _, _, _ #) -> () + rnf (Wider a) = case a of + (# _, _, _, _ #) -> () instance Num Wider where (+) = add @@ -47,7 +51,10 @@ instance Num Wider where abs = id fromInteger = to negate = to . negate . from - signum = to . signum . from + signum a + | a == Wider (# 0##, 0##, 0##, 0## #) = 0 + | otherwise = 1 + -- construction / conversion -------------------------------------------------- -- | Construct a 'Wider' word from four 'Words', provided in diff --git a/lib/Numeric/Montgomery/Secp256k1/Curve.hs b/lib/Numeric/Montgomery/Secp256k1/Curve.hs @@ -39,7 +39,7 @@ instance Num Montgomery where a * b = mul a b negate a = neg a abs = id - signum = id + signum = id -- XX fromInteger = to . WW.to -- XX define constants here, current approach is fragile