shithub: MicroHs

Download patch

ref: d65bc804563c41d1be4a6620ccde395555cb6da9
parent: bdfec110cf9b15a7ff80105fa7d7c3e7a4a15f55
author: Lennart Augustsson <lennart@augustsson.net>
date: Thu Nov 2 15:26:32 EDT 2023

Num class

--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,7 @@
 	$(GHCC) -c lib/Data/Functor.hs
 	$(GHCC) -c lib/Control/Applicative.hs
 	$(GHCC) -c lib/Control/Monad.hs
+	$(GHCC) -c lib/Data/Num.hs
 	$(GHCC) -c lib/Data/Int.hs
 	$(GHCC) -c lib/Data/Double.hs
 	$(GHCC) -c lib/Data/Char.hs
--- a/comb/mhs.comb
+++ b/comb/mhs.comb
@@ -1,3 +1,3 @@
 v4.0
-1195
-((A :0 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :1 (T (BK (BK (BK K))))) ((A :2 (T (K (BK (BK K))))) ((A :3 (T (K (K (BK K))))) ((A :4 (T (K (K (K K))))) ((A :5 (T (K (K (K A))))) ((A :6 (K (noDefault "Alternative.empty"))) ((A :7 (K (noDefault "Alternative.<|>"))) ((A :8 ((S (((S' S') ((B _14) _1)) (((C' _130) ((B _12) _1)) _238))) _5)) ((A :9 ((S (((S' C') _3) _4)) (((C' _13) _1) _237))) ((A :10 (((S' P) _2) (((C' _13) _1) _956))) ((A :11 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :12 (T (BK (BK (BK K))))) ((A :13 (T (K (BK (BK K))))) ((A :14 (T (K (K (BK K))))) ((A :15 (T (K (K (K K))))) ((A :16 (T (K (K (K A))))) ((A :17 (K (noDefault "Applicative.pure"))) ((A :18 (K (noDefault "Applicative.<*>"))) ((A :19 (((S' B) _14) (((C' _127) _12) _119))) ((A :20 (((S' B) _14) (((C' _130) _12) _120))) ((A :21 _1028) ((A :22 ((B _1071) _21)) ((A :23 (((S' _1071) _21) I)) ((A :24 _998) ((A :25 (_24 "undefined")) ((A :26 I) ((A :27 (((C' B) _1027) ((C _118) _26))) ((A :28 (((C' _27) ((_126 _1041) _107)) ((_118 (_34 _1043)) _106))) ((A :29 ((B ((S _1071) (_34 _1043))) _24)) ((A :30 ((B (B (B C))) ((B (B C)) P))) ((A :31 (T (BK (BK K)))) ((A :32 (T (K (BK K)))) ((A :33 (T (K (K K)))) ((A :34 (T (K (K A)))) ((A :35 (K (noDefault "Monad.>>="))) ((A :36 (((C' (C' B)) _32) K)) ((A :37 ((B _13) _31)) ((A :38 (((S' (C' B)) _32) (((S' (C' B)) _32) (B' _34)))) ((A :39 P) ((A :40 (T K)) ((A :41 (T A)) ((A :42 (K _24)) ((A :43 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _237)))) (((S' (C' B)) ((B (B (C' B))) (B' _32))) (((S' (C' (C' B))) (B' _32)) (((C' B) (B' _34)) _238)))))) ((A :44 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _956)))) (((C' (C' B)) ((B (B (C' B))) (B' _32))) BK)))) ((A :45 ((B T) ((C _34) _956))) ((A :46 ((C _43) _119)) ((A :47 ((B _121) _32)) ((A :48 ((B C) ((B C') _32))) ((A :49 ((B _121) _48)) ((A :50 T) ((A :51 ((_125 ((B (B (_116 _50))) ((B ((C' C) _54)) (B P)))) (_129 _51))) ((A :52 (((((_11 _51) ((B (_116 _50)) P)) (_38 _53)) ((B (B (_116 _50))) (((C' B) ((B C) _54)) (BK _54)))) (_20 _52))) ((A :53 ((((_30 _52) ((B (B (_116 _50))) (((C' B) ((B C) _54)) (B _54)))) (_15 _52)) (_13 _52))) ((A :54 (T I)) ((A :55 ((B (_118 _276)) _54)) ((A :56 ((B (_116 _50)) (B (P _956)))) ((A :57 ((B (_116 _50)) (BK (P _956)))) ((A :58 ((_116 _50) ((S P) I))) ((A :59 ((B (_116 _50)) ((C (S' P)) I))) ((A :60 ((_111 ((C ((C S') _64)) I)) (_115 _60))) ((A :61 (((_1169 (K ((P (_1178 "False")) (_1178 "True")))) (_1174 _61)) (_1175 _61))) ((A :62 (R _67)) ((A :63 (T _66)) ((A :64 ((P _67) _66)) ((A :65 _67) ((A :66 K) ((A :67 A) ((A :68 ((_111 _992) _993)) ((A :69 ((((((((_254 _68) (_263 _69)) _994) _995) _996) _997) (_268 _69)) (_269 _69))) ((A :70 ((_111 _1002) (_115 _70))) ((A :71 ((((((((_254 _70) _1001) (((C' (C' (_112 _270))) _1001) _273)) (((C' (C' (_113 _270))) _1001) _275)) (((C' (C' (_112 _270))) _1001) _275)) (((C' (C' (_113 _270))) _1001) _275)) (_268 _71)) (_269 _71))) ((A :72 _1003) ((A :73 _1004) ((A :74 (((S' _63) (_995 #97)) ((C _995) #122))) ((A :75 (((S' _63) (_995 #65)) ((C _995) #90))) ((A :76 (((S' _62) _74) _75)) ((A :77 (((S' _63) (_995 #48)) ((C _995) #57))) ((A :78 (((S' _62) _76) _77)) ((A :79 (((S' _63) (_995 #32)) ((C _995) #126))) ((A :80 (((S' _62) ((C (_112 _68)) #32)) (((S' _62) ((C (_112 _68)) #9)) ((C (_112 _68)) #10)))) ((A :81 ((S ((S (((S' _63) (_995 #65)) ((C _995) #90))) (_67 (((noMatch "lib/Data/Char.hs") #79) #1)))) ((B _72) (((C' _131) (((C' _132) _73) (_73 #65))) (_73 #97))))) ((A :82 ((S ((S (((S' _63) (_995 #97)) ((C _995) #97))) (_67 (((noMatch "lib/Data/Char.hs") #83) #1)))) ((B _72) (((C' _131) (((C' _132) _73) (_73 #97))) (_73 #65))))) ((A :83 (((_1169 (K ((C ((S ((C ==) #39)) ((B (_118 (_1177 #39))) (((C' _118) ((B _1178) _84)) (_1177 #39))))) (_1178 "'\92&''")))) (_1174 _83)) ((B (_118 (_1177 #34))) (Y ((B (P (_1177 #34))) (((S' C) ((B ((S' S') ((C (_112 _68)) #34))) ((C' B) ((B _118) ((B _1178) _84))))) (B (_118 (_1178 "\92&\34&"))))))))) ((A :84 (((C' Y) (((S' B) ((B P) ((S ((S _79) ((B (_239 "'\92&")) (((C' _239) ((B (_1171 _140)) _73)) ((O #39) K))))) ((C O) K)))) ((B 
\ No newline at end of file
+1191
+((A :0 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :1 (T (BK (BK (BK K))))) ((A :2 (T (K (BK (BK K))))) ((A :3 (T (K (K (BK K))))) ((A :4 (T (K (K (K K))))) ((A :5 (T (K (K (K A))))) ((A :6 (K (noDefault "Alternative.empty"))) ((A :7 (K (noDefault "Alternative.<|>"))) ((A :8 ((S (((S' S') ((B _14) _1)) (((C' _114) ((B _12) _1)) _218))) _5)) ((A :9 ((S (((S' C') _3) _4)) (((C' _13) _1) _217))) ((A :10 (((S' P) _2) (((C' _13) _1) _952))) ((A :11 ((B (B (B (B C)))) ((B (B (B C))) ((B (B C)) P)))) ((A :12 (T (BK (BK (BK K))))) ((A :13 (T (K (BK (BK K))))) ((A :14 (T (K (K (BK K))))) ((A :15 (T (K (K (K K))))) ((A :16 (T (K (K (K A))))) ((A :17 (K (noDefault "Applicative.pure"))) ((A :18 (K (noDefault "Applicative.<*>"))) ((A :19 (((S' B) _14) (((C' _111) _12) _103))) ((A :20 (((S' B) _14) (((C' _114) _12) _104))) ((A :21 _1024) ((A :22 ((B _1067) _21)) ((A :23 (((S' _1067) _21) I)) ((A :24 _994) ((A :25 (_24 "undefined")) ((A :26 I) ((A :27 (((C' B) _1023) ((C _102) _26))) ((A :28 (((C' _27) ((_110 _1037) _91)) ((_102 (_34 _1039)) _90))) ((A :29 ((B ((S _1067) (_34 _1039))) _24)) ((A :30 ((B (B (B C))) ((B (B C)) P))) ((A :31 (T (BK (BK K)))) ((A :32 (T (K (BK K)))) ((A :33 (T (K (K K)))) ((A :34 (T (K (K A)))) ((A :35 (K (noDefault "Monad.>>="))) ((A :36 (((C' (C' B)) _32) K)) ((A :37 ((B _13) _31)) ((A :38 (((S' (C' B)) _32) (((S' (C' B)) _32) (B' _34)))) ((A :39 P) ((A :40 (T K)) ((A :41 (T A)) ((A :42 (K _24)) ((A :43 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _217)))) (((S' (C' B)) ((B (B (C' B))) (B' _32))) (((S' (C' (C' B))) (B' _32)) (((C' B) (B' _34)) _218)))))) ((A :44 ((B (B Y)) (((S' B) (B' ((B P) ((C _34) _952)))) (((C' (C' B)) ((B (B (C' B))) (B' _32))) BK)))) ((A :45 ((B T) ((C _34) _952))) ((A :46 ((C _43) _103)) ((A :47 ((B _105) _32)) ((A :48 ((B C) ((B C') _32))) ((A :49 ((B _105) _48)) ((A :50 T) ((A :51 ((_109 ((B (B (_100 _50))) ((B ((C' C) _54)) (B P)))) (_113 _51))) ((A :52 (((((_11 _51) ((B (_100 _50)) P)) (_38 _53)) ((B (B (_100 _50))) (((C' B) ((B C) _54)) (BK _54)))) (_20 _52))) ((A :53 ((((_30 _52) ((B (B (_100 _50))) (((C' B) ((B C) _54)) (B _54)))) (_15 _52)) (_13 _52))) ((A :54 (T I)) ((A :55 ((B (_102 _272)) _54)) ((A :56 ((B (_100 _50)) (B (P _952)))) ((A :57 ((B (_100 _50)) (BK (P _952)))) ((A :58 ((_100 _50) ((S P) I))) ((A :59 ((B (_100 _50)) ((C (S' P)) I))) ((A :60 ((_95 ((C ((C S') _64)) I)) (_99 _60))) ((A :61 (((_1165 (K ((P (_1174 "False")) (_1174 "True")))) (_1170 _61)) (_1171 _61))) ((A :62 (R _67)) ((A :63 (T _66)) ((A :64 ((P _67) _66)) ((A :65 _67) ((A :66 K) ((A :67 A) ((A :68 ((_95 _988) _989)) ((A :69 ((((((((_250 _68) (_259 _69)) _990) _991) _992) _993) (_264 _69)) (_265 _69))) ((A :70 ((_95 _998) (_99 _70))) ((A :71 ((((((((_250 _70) _997) (((C' (C' (_96 _266))) _997) _269)) (((C' (C' (_97 _266))) _997) _271)) (((C' (C' (_96 _266))) _997) _271)) (((C' (C' (_97 _266))) _997) _271)) (_264 _71)) (_265 _71))) ((A :72 _999) ((A :73 _1000) ((A :74 (((S' _63) (_991 #97)) ((C _991) #122))) ((A :75 (((S' _63) (_991 #65)) ((C _991) #90))) ((A :76 (((S' _62) _74) _75)) ((A :77 (((S' _63) (_991 #48)) ((C _991) #57))) ((A :78 (((S' _62) _76) _77)) ((A :79 (((S' _63) (_991 #32)) ((C _991) #126))) ((A :80 (((S' _62) ((C (_96 _68)) #32)) (((S' _62) ((C (_96 _68)) #9)) ((C (_96 _68)) #10)))) ((A :81 ((S ((S (((S' _63) (_991 #65)) ((C _991) #90))) (_67 (((noMatch "lib/Data/Char.hs") #80) #9)))) ((B _72) (((C' (_235 _115)) (((C' (_236 _115)) _73) (_73 #65))) (_73 #97))))) ((A :82 ((S ((S (((S' _63) (_991 #97)) ((C _991) #97))) (_67 (((noMatch "lib/Data/Char.hs") #84) #9)))) ((B _72) (((C' (_235 _115)) (((C' (_236 _115)) _73) (_73 #97))) (_73 #65))))) ((A :83 (((_1165 (K ((C ((S ((C ==) #39)) ((B (_102 (_1173 #39))) (((C' _102) ((B _1174) _84)) (_1173 #39))))) (_1174 "'\92&''")))) (_1170 _83)) ((B (_102 (_1173 #34))) (Y ((B (P (_1173 #34))) (((S' C) ((B ((S' S') ((C (_96 _68)) #34))) ((C' B) ((B _102) ((B _1174) _84))))) (B (_102 (_1174 "\92&\34&"))))))))) ((A :84 (((C' Y) (((S' B) ((B P) ((S ((S _79) ((B (_219 "'\92&")) (((C' _219) ((B (_1167 _120)) _73)) ((O #39) K))))) ((C O) K)))
\ No newline at end of file
--- a/lib/Data/Char.hs
+++ b/lib/Data/Char.hs
@@ -11,6 +11,7 @@
 import Data.Function
 import Data.Int
 import Data.List_Type
+import Data.Num
 import Data.Ord
 import Text.Show
 
--- a/lib/Data/Double.hs
+++ b/lib/Data/Double.hs
@@ -2,13 +2,26 @@
 -- See LICENSE file for full license.
 module Data.Double(module Data.Double, Double) where
 import Primitives
+import Control.Error
 import Data.Bool_Type
 import Data.Eq
+import Data.Ord
+import Data.Num
 import Text.Show
 
-infixl 6 +,-
-infixl 7 *
+instance Num Double where
+  (+)  = primDoubleAdd
+  (-)  = primDoubleSub
+  (*)  = primDoubleMul
+  abs x = if x < 0.0 then negate x else x
+  signum x =
+    case compare x 0.0 of
+      LT -> -1.0
+      EQ ->  0.0
+      GT ->  1.0
+  fromInt x = error "Double.fromInt unimplemented"
 
+{-
 -- Arithmetic
 (+) :: Double -> Double -> Double
 (+)  = primDoubleAdd
@@ -16,9 +29,12 @@
 (-)  = primDoubleSub
 (*) :: Double -> Double -> Double
 (*)  = primDoubleMul
+-}
+
 (/) :: Double -> Double -> Double
 (/) = primDoubleDiv
 
+{-
 negate :: Double -> Double
 negate x = 0.0 - x
 
@@ -30,11 +46,12 @@
 mulDouble = (*)
 divDouble :: Double -> Double -> Double
 divDouble = (/)
+-}
 
 --------------------------------
 
 --infix 4 ==,/=
-infix 4 <,<=,>,>=
+--infix 4 <,<=,>,>=
 
 {-
 -- Comparison
@@ -48,11 +65,20 @@
   (==) = primDoubleEQ
   (/=) = primDoubleNE
 
+{-
 eqDouble :: Double -> Double -> Bool
 eqDouble = (==)
 neqDouble :: Double -> Double -> Bool
 neqDouble = (/=)
+-}
 
+instance Ord Double where
+  (<)  = primDoubleLT
+  (<=) = primDoubleLE
+  (>)  = primDoubleGT
+  (>=) = primDoubleGE
+  
+{-
 (<)  :: Double -> Double -> Bool
 (<)  = primDoubleLT
 (<=) :: Double -> Double -> Bool
@@ -73,6 +99,7 @@
 
 geDouble :: Double -> Double -> Bool
 geDouble = (>=)
+-}
 
 -- | this primitive will print doubles with up to 6 decimal points
 -- it turns out that doubles are extremely tricky, and just printing them is a
--- a/lib/Data/Int.hs
+++ b/lib/Data/Int.hs
@@ -6,12 +6,26 @@
 import Data.Char_Type
 import Data.Eq
 import Data.List_Type
+import Data.Num
 import Data.Ord
 import Text.Show
 
-infixl 6 +,-
-infixl 7 *,`quot`,`rem`
+infixl 7 `quot`,`rem`
 
+instance Num Int where
+  (+)  = primIntAdd
+  (-)  = primIntSub
+  (*)  = primIntMul
+  negate x = primIntSub 0 x
+  abs x = if x < 0 then negate x else x
+  signum x =
+    case compare x 0 of
+      LT -> -1
+      EQ ->  0
+      GT ->  1
+  fromInt x = x
+
+{-
 -- Arithmetic
 (+) :: Int -> Int -> Int
 (+)  = primIntAdd
@@ -19,16 +33,12 @@
 (-)  = primIntSub
 (*) :: Int -> Int -> Int
 (*)  = primIntMul
+-}
+
 quot :: Int -> Int -> Int
 quot = primIntQuot
 rem :: Int -> Int -> Int
 rem  = primIntRem
-
-subtract :: Int -> Int -> Int
-subtract = primIntSubR
-
-negate :: Int -> Int
-negate x = 0 - x
 
 --------------------------------
 
--- a/lib/Data/Integer.hs
+++ b/lib/Data/Integer.hs
@@ -37,11 +37,31 @@
   --deriving Show
 
 instance Eq Integer where
-  x == y  =  isZero (subI x y)
+  (==) = eqI
+  (/=) = neI
 
+instance Ord Integer where
+  (<)  = ltI
+  (<=) = leI
+  (>)  = gtI
+  (>+) = geI
+
 instance Show Integer where
   show i = showInteger i
 
+instance Num Integer where
+  (+) = addI
+  (-) = subI
+  (*) = mulI
+  negate = negateI
+  abs = absI
+  signum x =
+    case compare x zeroI of
+      LT -> negOneI
+      EQ -> zeroI
+      GT -> oneI
+  fromInt = intToInteger
+
 isZero :: Integer -> Bool
 isZero (I _ ds) = null ds
 
@@ -235,6 +255,9 @@
 
 twoI :: Integer
 twoI = I Plus [2]
+
+negOneI :: Integer
+negOneI = I Minus [1]
 
 --------------
 
--- a/lib/Data/List.hs
+++ b/lib/Data/List.hs
@@ -14,6 +14,7 @@
 import Data.Functor
 import Data.Int
 import Data.List_Type
+import Data.Num
 import Data.Ord
 import Data.Maybe_Type
 import Data.Tuple
--- /dev/null
+++ b/lib/Data/Num.hs
@@ -1,0 +1,22 @@
+module Data.Num(module Data.Num) where
+import Primitives
+
+infixl 6 +,-
+infixl 7 *
+
+class Num a where
+  (+) :: a -> a -> a
+  (-) :: a -> a -> a
+  (*) :: a -> a -> a
+  negate :: a -> a
+  abs :: a -> a
+  signum :: a -> a
+--  fromInteger :: Integer -> a
+  fromInt :: Int -> a
+
+  negate x = fromInt 0 - x
+
+subtract :: forall a . Num a => a -> a -> a
+subtract x y = y - x
+
+
--- a/lib/Data/Word.hs
+++ b/lib/Data/Word.hs
@@ -5,13 +5,22 @@
 import Data.Bool_Type
 import qualified Data.Char as C
 import Data.Eq
-import qualified Data.Int as I
+import Data.Int()  -- insances only
 import Data.List
+import Data.Num
 import Text.Show
 
-infixl 6 +,-
-infixl 7 *,`quot`,`rem`
+infixl 7 `quot`,`rem`
 
+instance Num Word where
+  (+)  = primWordAdd
+  (-)  = primWordSub
+  (*)  = primWordMul
+  abs x = x
+  signum x = if x == fromInt 0 then fromInt 0 else fromInt 1
+  fromInt = primUnsafeCoerce
+
+{-
 -- Arithmetic
 (+) :: Word -> Word -> Word
 (+)  = primWordAdd
@@ -19,6 +28,8 @@
 (-)  = primWordSub
 (*) :: Word -> Word -> Word
 (*)  = primWordMul
+-}
+
 quot :: Word -> Word -> Word
 quot = primWordQuot
 rem :: Word -> Word -> Word
@@ -67,7 +78,7 @@
       showWord :: Word -> C.String
       showWord n =
         let
-          c = C.chr ((I.+) (C.ord '0') (wordToInt (rem n (intToWord 10))))
+          c = C.chr ((+) (C.ord '0') (wordToInt (rem n (intToWord 10))))
         in  case n < intToWord 10 of
               False -> showWord (quot n (intToWord 10)) ++ [c]
               True  -> [c]
--- a/lib/Prelude.hs
+++ b/lib/Prelude.hs
@@ -13,6 +13,7 @@
   module Data.Int,
   module Data.List,
   module Data.Maybe,
+  module Data.Num,
   module Data.Ord,
   module Data.Tuple,
   module System.IO,
@@ -33,6 +34,7 @@
 import Data.Int
 import Data.List
 import Data.Maybe
+import Data.Num
 import Data.Ord
 import Data.Tuple
 import System.IO
--- a/lib/System/IO.hs
+++ b/lib/System/IO.hs
@@ -13,10 +13,11 @@
 import Data.Bool
 import Data.Char
 import Data.Eq
+import Data.Functor
 import Data.Int
 import Data.List
-import Data.Functor
 import Data.Maybe
+import Data.Num
 import Data.Tuple
 import Text.Show
 
--- a/lib/Text/String.hs
+++ b/lib/Text/String.hs
@@ -10,6 +10,7 @@
 import Data.Int
 import Data.List
 import Data.Maybe
+import Data.Num
 import Data.Ord
 import Data.Tuple
 import Text.Show
--- a/tests/FArith.hs
+++ b/tests/FArith.hs
@@ -1,25 +1,25 @@
 module FArith(module FArith) where
 
 import Prelude
-import qualified Data.Double as D
+import Data.Double as D
 import Text.String
 
-list1 :: [D.Double]
+list1 :: [Double]
 list1 = [-100.343241, -53.3248973, -0.0, 0.0, 1.0, 1.23453523, 3243534.34534, 999.999]
 
-list2 :: [D.Double]
+list2 :: [Double]
 list2 = [-100.343241, -53.3248973, -0.0, 0.0, 1.0, 1.23453523, 3243534.34534, 999.999]
 
-divide :: D.Double -> D.Double -> D.Double
-divide x y = if D.eqDouble y 0.0 then 0.0 else D.divDouble x y
+divide :: Double -> Double -> Double
+divide x y = if y == 0.0 then 0.0 else x D./ y
 
 main :: IO ()
 main = do
-  putStrLn $ show [ op x y | x <- list1, y <- list2, op <- [D.addDouble, D.subDouble, D.mulDouble, divide] ]
-  putStrLn $ show [ op x y | x <- list1, y <- list2, op <- [D.eqDouble, D.neqDouble, D.ltDouble, D.leDouble, D.gtDouble, D.geDouble] ]
-  putStrLn $ show [ D.divDouble x y | x <- [2.234983, 1.232, 23.0], y <- [1.0, 5.0, 10.0, 100.0]]
-  putStrLn $ show [ D.divDouble x y | x <- [-2.234983, -1.232, -23.0], y <- [1.0, -5.0, 10.0, -100.0]]
+  putStrLn $ show [ op x y | x <- list1, y <- list2, op <- [(+), (-), (*), divide] ]
+  putStrLn $ show [ op x y | x <- list1, y <- list2, op <- [(==), (/=), (<), (<=), (>), (>=)] ]
+  putStrLn $ show [ x D./ y | x <- [2.234983, 1.232, 23.0], y <- [1.0, 5.0, 10.0, 100.0]]
+  putStrLn $ show [ x D./ y | x <- [-2.234983, -1.232, -23.0], y <- [1.0, -5.0, 10.0, -100.0]]
   let str = readDouble "1.576"
   putStrLn $ show str
-  putStrLn $ show $ D.addDouble 1.0 $ readDouble "2.5"
+  putStrLn $ show $ 1.0 + readDouble "2.5"
   putStrLn $ show $ map readDouble ["1.5e42", "1.2e-90"]
--- a/tests/IOTest.hs
+++ b/tests/IOTest.hs
@@ -23,7 +23,7 @@
   p
   p
   p
-  cprint (+)
+  cprint ((+) :: Int->Int->Int)
   hout <- openFile "test.tmp" WriteMode
   hPutChar hout 'a'
   hPutChar hout 'z'
--- a/tests/Word.hs
+++ b/tests/Word.hs
@@ -7,7 +7,7 @@
   putStrLn $ show 4294967295
   putStrLn $ show (W.intToWord 1000)
   putStrLn $ show twoTo32M1
-  putStrLn $ show $ (W.*) twoTo32M1 twoTo32M1
+  putStrLn $ show $ (*) twoTo32M1 twoTo32M1
 
 twoTo32M1 :: W.Word
 twoTo32M1 = W.intToWord 4294967295
--