You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flexdis defines a number of register types that have more representations than they have valid values. Consider Reg64:
--| One of the 16 64-bit general purpose registers.newtypeReg64=Reg64{unReg64::Word8}
As noted in the Haddock and enforced via assert, the only valid values of this type are Reg64 0, ..., Reg64 15. However, there are 241 additional, invalid values! To make matters worse, the constructor is exported, meaning that Flexdis cannot guarantee that clients don't construct invalid values.
The set of registers is small and fixed. This is the perfect use-case for an enumeration type! It would be nice to promote all of the patterns in that module to be the constructors of an enumeration. We could then exhaustively pattern-match on these types, and implement classes such as Enum and Bounded.
There are two downsides to this proposal:
It's not backwards-compatible. Some client code could break.
Functions like reg32_reg would be slightly more complex. Today they are defined simply like so:
reg32_reg::Reg32->Reg64
reg32_reg (Reg32 r) =Reg64 r
The text was updated successfully, but these errors were encountered:
Flexdis defines a number of register types that have more representations than they have valid values. Consider
Reg64
:As noted in the Haddock and enforced via
assert
, the only valid values of this type areReg64 0
, ...,Reg64 15
. However, there are 241 additional, invalid values! To make matters worse, the constructor is exported, meaning that Flexdis cannot guarantee that clients don't construct invalid values.The set of registers is small and fixed. This is the perfect use-case for an enumeration type! It would be nice to promote all of the
pattern
s in that module to be the constructors of an enumeration. We could then exhaustively pattern-match on these types, and implement classes such asEnum
andBounded
.There are two downsides to this proposal:
reg32_reg
would be slightly more complex. Today they are defined simply like so:The text was updated successfully, but these errors were encountered: