Permalink
Browse files

Expose method for IntT type class and fix tests

That what you get for for forgetting to run tests before uploading package
  • Loading branch information...
1 parent d3fa692 commit 16ccd7f0aef26c012dbbb2d454525885fc0ff187 @Shimuuar committed Apr 23, 2012
Showing with 12 additions and 11 deletions.
  1. +1 −1 TypeLevel/Number/Int.hs
  2. +10 −9 test/TestNat.hs
  3. +1 −1 type-level-numbers.cabal
View
@@ -25,7 +25,7 @@ module TypeLevel.Number.Int ( -- * Integer numbers
, Dn
, D0
, D1
- , IntT
+ , IntT(..)
-- * Template haskell utilities
, intT
, module TypeLevel.Number.Classes
View
@@ -4,30 +4,31 @@ module TestNat where
import Language.Haskell.TH
import Text.Printf
-import TypeLevel.Number.Nat
-import TypeLevel.Number.Int
+import TypeLevel.Number.Nat as N
+import TypeLevel.Number.Int as I
text :: Bool -> String
-text flag = if flag then "OK" else "Failed"
+text True = "OK"
+text False = "Failed"
----------------------------------------------------------------
-- Natural numbers
testAdd :: Integer -> Integer -> ExpQ
testAdd n m =
- [| let flag = (n+m) == (toInt $ addN (undefined :: $(natT n)) (undefined :: $(natT m)) :: Integer)
+ [| let flag = (n+m) == (N.toInt $ addN (undefined :: $(natT n)) (undefined :: $(natT m)) :: Integer)
in printf "Add %3i %3i : %s" (n::Integer) (m::Integer) (text flag) :: String
|]
testSub :: Integer -> Integer -> ExpQ
testSub n m =
- [| let flag = (n-m) == (toInt $ subN (undefined :: $(natT n)) (undefined :: $(natT m)) :: Integer)
+ [| let flag = (n-m) == (N.toInt $ subN (undefined :: $(natT n)) (undefined :: $(natT m)) :: Integer)
in printf "Sub %3i %3i : %s" (n::Integer) (m::Integer) (text flag) :: String
|]
testMul :: Integer -> Integer -> ExpQ
testMul n m =
- [| let flag = (n*m) == (toInt $ mulN (undefined :: $(natT n)) (undefined :: $(natT m)) :: Integer)
+ [| let flag = (n*m) == (N.toInt $ mulN (undefined :: $(natT n)) (undefined :: $(natT m)) :: Integer)
in printf "Mul %3i %3i : %s" (n::Integer) (m::Integer) (text flag) :: String
|]
@@ -36,19 +37,19 @@ testMul n m =
testAddZ :: Integer -> Integer -> ExpQ
testAddZ n m =
- [| let flag = (n+m) == (toInt $ addN (undefined :: $(intT n)) (undefined :: $(intT m)) :: Integer)
+ [| let flag = (n+m) == (I.toInt $ addN (undefined :: $(intT n)) (undefined :: $(intT m)) :: Integer)
in printf "Add %3i %3i : %s" (n::Integer) (m::Integer) (text flag) :: String
|]
testSubZ :: Integer -> Integer -> ExpQ
testSubZ n m =
- [| let flag = (n-m) == (toInt $ subN (undefined :: $(intT n)) (undefined :: $(intT m)) :: Integer)
+ [| let flag = (n-m) == (I.toInt $ subN (undefined :: $(intT n)) (undefined :: $(intT m)) :: Integer)
in printf "Sub %3i %3i : %s" (n::Integer) (m::Integer) (text flag) :: String
|]
testMulZ :: Integer -> Integer -> ExpQ
testMulZ n m =
- [| let flag = (n*m) == (toInt $ mulN (undefined :: $(intT n)) (undefined :: $(intT m)) :: Integer)
+ [| let flag = (n*m) == (I.toInt $ mulN (undefined :: $(intT n)) (undefined :: $(intT m)) :: Integer)
in printf "Mul %3i %3i : %s" (n::Integer) (m::Integer) (text flag) :: String
|]
View
@@ -1,5 +1,5 @@
Name: type-level-numbers
-Version: 0.1.0.3
+Version: 0.1.0.4
Synopsis:
Type level numbers implemented using type families.
Description:

0 comments on commit 16ccd7f

Please sign in to comment.