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))