Idris2/tests/idris2/basic/basic042/LiteralsInteger.idr
2023-09-07 14:57:22 +01:00

32 lines
441 B
Idris

import Data.Fin
%default total
data ZeroOneOmega = Zero | One | Omega
Num ZeroOneOmega where
Zero + a = a
a + Zero = a
One + a = Omega
a + One = Omega
Omega + Omega = Omega
Zero * _ = Zero
_ * Zero = Zero
One * a = a
a * One = a
Omega * Omega = Omega
fromInteger 0 = Zero
fromInteger 1 = One
fromInteger _ = Omega
test1 : ZeroOneOmega
test1 = 0
test2 : ZeroOneOmega
test2 = 1
test3 : ZeroOneOmega
test3 = 8