Skip to content

A combination of type-level comparison and subtraction does not work for 0

The following function on type level naturals

  Diff x y = If (x <=? y) (y-x) (x-y)

does not work when either x or y is 0.

https://github.com/nushio3/practice/blob/ea8a1716b1d6221ce32d77432b6de3f38e653a27/type-nats/int-bug.hs

I've tested this code on ghc 7.7.20130926 since I couldn't build the really latest ghc. I'm sorry if it is already fixed on the ghc head.

Trac metadata
Trac field Value
Version 7.6.3
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information