Skip to content

Commit

Permalink
Declare fixity of exponentiation (Clash.Class.Exp) (#2818)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5706eaf)
  • Loading branch information
DigitalBrains1 authored and mergify[bot] committed Oct 9, 2024
1 parent 1487755 commit 46f4fe0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/2024-10-03T17_02_19+02_00_exp_fixity
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 4 additions & 1 deletion clash-prelude/src/Clash/Class/Exp.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{-|
Copyright : (C) 2019, Myrtle Software Ltd
2024, QBayLogic B.V.
License : BSD2 (see the file LICENSE)
Maintainer : Christiaan Baaij <christiaan.baaij@gmail.com>
Maintainer : QBayLogic B.V. <devops@qaylogic.com>
-}

{-# LANGUAGE CPP #-}
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 46f4fe0

Please sign in to comment.