From 5706eafca799ae04fda0ee7d666a40b6c0e7f22b Mon Sep 17 00:00:00 2001 From: Peter Lebbing Date: Wed, 9 Oct 2024 19:29:50 +0200 Subject: [PATCH] Declare fixity of exponentiation (Clash.Class.Exp) (#2818) --- changelog/2024-10-03T17_02_19+02_00_exp_fixity | 1 + clash-prelude/src/Clash/Class/Exp.hs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog/2024-10-03T17_02_19+02_00_exp_fixity diff --git a/changelog/2024-10-03T17_02_19+02_00_exp_fixity b/changelog/2024-10-03T17_02_19+02_00_exp_fixity new file mode 100644 index 0000000000..63bb9e4c02 --- /dev/null +++ b/changelog/2024-10-03T17_02_19+02_00_exp_fixity @@ -0,0 +1 @@ +FIXED: Exponentiation (`Clash.Class.Exp`) is now right-associative with a precedence level of 8 (`infixr 8`). By accident, it used to lack a fixity declaration, meaning it was implicitly left-associative at level 9. diff --git a/clash-prelude/src/Clash/Class/Exp.hs b/clash-prelude/src/Clash/Class/Exp.hs index 9d25f0e294..aff559b4d7 100644 --- a/clash-prelude/src/Clash/Class/Exp.hs +++ b/clash-prelude/src/Clash/Class/Exp.hs @@ -1,7 +1,8 @@ {-| Copyright : (C) 2019, Myrtle Software Ltd + 2024, QBayLogic B.V. License : BSD2 (see the file LICENSE) -Maintainer : Christiaan Baaij +Maintainer : QBayLogic B.V. -} {-# LANGUAGE CPP #-} @@ -38,6 +39,8 @@ class Exp a where -> ExpResult a n -- ^ Resized result, guaranteed to not have overflown +infixr 8 ^ + instance KnownNat m => Exp (Index m) where type ExpResult (Index m) n = Index (Max 2 (m ^ n))