shithub: MicroHs

Download patch

ref: 3c4dcd0457a4908b9e5e5969d875ada0412aa34d
parent: 8813aa5bda117f7c01db53c48328ef9fe1ed6c41
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Tue Aug 29 07:05:29 EDT 2023

Minor fixes

--- a/README.md
+++ b/README.md
@@ -138,12 +138,12 @@
 so there are undoubtedly problems on Windows.
 
 The code has only been tested on 64 bit platforms, so again, there are lurking problems
-with other word sizees.
+with other word sizes.
 
 ## Bootstrapping
 It is possible to recompile the compiler without access to a Haskell compiler.
 The combinator file for the compiler itself is available in `comb/mhs.comb`.
-The bootstrapping process takes about 15s.
+The bootstrapping process takes about 15s (on a modern machine).
 To bootstrap:
  * build the evaluator, `make bin/eval`, this requires a C compiler
  * compile the compiler
--- a/lib/Data/Integer.hs
+++ b/lib/Data/Integer.hs
@@ -21,12 +21,12 @@
 maxW = W.intToWord 4294967296
 
 (+) :: Integer -> Integer -> Integer
-(+) (I Plus  xs) (I Plus  ys)             = I Plus    (add xs ys)
+(+) (I Plus  xs) (I Plus  ys)             = I Plus  (add xs ys)
 (+) (I Plus  xs) (I Minus ys) | ltW xs ys = I Minus (sub ys xs)
                               | True      = I Plus  (sub xs ys)
 (+) (I Minus xs) (I Plus  ys) | ltW ys xs = I Minus (sub xs ys)
                               | True      = I Plus  (sub ys xs)
-(+) (I Minus xs) (I Minus ys)             = I Minus   (add xs ys)
+(+) (I Minus xs) (I Minus ys)             = I Minus (add xs ys)
 
 negate :: Integer -> Integer
 negate (I Plus  x) = I Minus x
@@ -49,8 +49,8 @@
 addW x y z = (W.quot s maxW, W.rem s maxW)  where s = (W.+) ((W.+) x y) z
 
 -- We always have xs <= ys
-sub :: [Word] -> [Word] -> (Sign, [Word])
-sub xs ys = if ltW xs ys then (Minus, sub' zeroW ys xs) else (Plus, sub' zeroW xs ys)
+sub :: [Word] -> [Word] -> [Word]
+sub = sub' zeroW
 
 sub' :: Word -> [Word] -> [Word] -> [Word]
 sub' bi (x : xs) (y : ys) = d : sub' bo xs ys  where (d, bo) = subW bi x y
--