Skip to content

Non-determinism in Ord TyLit

The Ord TyLit instance uses uniqCompareFS, which is non-deterministic:

instance Ord TyLit where
  compare (NumTyLit x) (NumTyLit y)   = compare x y
  compare (StrTyLit x) (StrTyLit y)   = uniqCompareFS x y
  compare (CharTyLit x) (CharTyLit y) = compare x y
  compare a b = compare (tag a) (tag b)
    where
      tag :: TyLit -> Int
      tag NumTyLit{}  = 0
      tag StrTyLit{}  = 1
      tag CharTyLit{} = 2

That is very easy to misuse. This comparison should be called nonDetCmpTyLit.

Edited by Vladislav Zavialov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information