Idris2/tests/chez/chez015/Numbers.idr
Edwin Brady 498421a236 All functions now need to be covering by default
This has caught a couple of things in the Idris 2 code base itself. Some
tests needed partial annotations too.
2020-05-24 19:58:20 +01:00

37 lines
833 B
Idris
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module Main
import Data.List
%default partial
large : (a: Type) -> a
-- integer larger than 64 bits
large Integer = 3518437212345678901234567890123
-- int close to 2ˆ63
-- we expect some operations will overflow
large Int = 3518437212345678901234567890
small : (a: Type) -> a
small Integer = 437
small Int = 377
numOps : (Num a) => List ( a -> a -> a )
numOps = [ (+), (*) ]
negOps : (Neg a) => List (a -> a -> a)
negOps = [ (-) ]
integralOps : (Integral a) => List (a -> a -> a)
integralOps = [ div, mod ]
binOps : (Num a, Neg a, Integral a) => List (a -> a -> a)
binOps = numOps ++ negOps ++ integralOps
main : IO ()
main = do
putStrLn $ show (results Integer)
putStrLn $ show (results Int)
where
results : (a:Type) -> (Num a, Neg a, Integral a) => List a
results a = map (\ op => large a `op` small a) binOps