shithub: MicroHs

Download patch

ref: 55986eeb29b0872b17be0b20218e003da09a5b9b
parent: 287a43bdd5d192e9f5764090ca3851f6453b9ede
author: Lennart Augustsson <lennart@augustsson.net>
date: Sun Nov 12 17:07:51 EST 2023

Remove junk file.

--- a/Makefile
+++ b/Makefile
@@ -18,11 +18,10 @@
 MHS=mhs
 COMB=comb/
 EVAL=$(BIN)/mhseval
-.PHONY: all alltest everytest runtest bootboottest bootcombtest $(MHS)test test alltest time example bootstraptest
+.PHONY: all alltest everytest runtest bootcombtest $(MHS)test test alltest time example bootstraptest
 
 all:	$(EVAL) $(BIN)/$(MHS)
 
-#everytest:	runtest example examplecomb bootboottest bootcombtest
 everytest:	runtest example examplecomb bootcombtest
 
 ###
@@ -36,18 +35,12 @@
 ###
 ### Build the compiler with ghc, using standard libraries (Prelude, Data.List, etc)
 ###
-$(BIN)/$(MHS):	src/*.hs src/*/*.hs $(TOOLS)/convertX.sh
+$(BIN)/$(MHS):	src/*/*.hs $(TOOLS)/convertX.sh
 	$(GHCE) -ighc -isrc -Wall -Wno-unrecognised-warning-flags -Wno-x-partial -O src/MicroHs/Main.hs -main-is MicroHs.Main -o $(BIN)/$(MHS)
 
 # Self compile using comb/mhs.comb
 $(COMB)$(MHS)-new.comb: $(EVAL)
 	$(EVAL) +RTS -r$(COMB)$(MHS).comb -RTS -ilib -isrc -o$(COMB)$(MHS)-new.comb MicroHs.Main
-
-# Compare version compiled with normal GHC libraries and $(MHS) libraries
-bootboottest:	$(BIN)/$(MHS) $(BIN)/boot$(MHS)
-	$(BIN)/$(MHS)     -ilib -isrc -omain-$(MHS).comb  MicroHs.Main
-	$(BIN)/boot$(MHS) -ilib -isrc -omain-boot.comb MicroHs.Main
-	cmp main-$(MHS).comb main-boot.comb
 
 # Compare version compiled with GHC, and bootstrapped combinator version
 bootcombtest:	$(BIN)/$(MHS) $(EVAL) $(COMB)$(MHS).comb
--- /dev/null
+++ b/ghc/Compat.hs
@@ -1,0 +1,211 @@
+-- Copyright 2023 Lennart Augustsson
+-- See LICENSE file for full license.
+-- Functions for GHC that are defined in the UHS libs.
+module Compat(module Compat) where
+--import Control.Exception
+import qualified Data.Function as F
+import Data.Char
+import Data.Time
+import Data.Time.Clock.POSIX
+--import qualified Control.Monad as M
+import Control.Exception
+import Data.List
+import System.Environment
+import System.IO
+import GHC.Types(Any)
+
+-- Functions needed for ghc
+eqChar :: Char -> Char -> Bool
+eqChar = (==)
+
+neChar :: Char -> Char -> Bool
+neChar = (/=)
+
+ltChar :: Char -> Char -> Bool
+ltChar = (<)
+
+eqString :: String -> String -> Bool
+eqString = (==)
+
+leString :: String -> String -> Bool
+leString = (<=)
+
+readInt :: String -> Int
+readInt = read
+
+readInteger :: String -> Integer
+readInteger = read
+
+readDouble :: String -> Double
+readDouble = read
+
+_integerToInt :: Integer -> Int
+_integerToInt = fromInteger
+
+_intToInteger :: Int -> Integer
+_intToInteger = fromIntegral
+
+_integerToDouble :: Integer -> Double
+_integerToDouble = fromIntegral
+
+-- Same as in Data.Integer
+_integerToIntList :: Integer -> [Int]
+_integerToIntList i | i < 0 = -1 : to (-i)
+                    | otherwise =  to i
+  where to 0 = []
+        to n = fromInteger r : to q  where (q, r) = quotRem n 2147483648
+
+xshowChar :: Char -> String
+xshowChar = show
+
+showListS :: (a -> String) -> [a] -> String
+showListS sa arg =
+  let
+    showRest as =
+      case as of
+        [] -> "]"
+        x : xs -> "," ++ sa x ++ showRest xs
+  in
+    case arg of
+      [] -> "[]"
+      a : as -> "[" ++ sa a ++ showRest as
+
+showPairS :: (a -> String) -> (b -> String) -> (a, b) -> String
+showPairS f g (a, b) = "(" ++ f a ++ "," ++ g b ++ ")"
+
+elemBy :: (a -> a -> Bool) -> a -> [a] -> Bool
+elemBy eq a = any (eq a)
+
+stripPrefixBy :: (a -> a -> Bool) -> [a] -> [a] -> Maybe [a]
+stripPrefixBy eq p s =
+  case p of
+    [] -> Just s
+    c : cs ->
+      case s of
+        [] -> Nothing
+        d : ds ->
+          if eq c d then
+            stripPrefixBy eq cs ds
+          else
+            Nothing
+
+lookupBy :: (a -> a -> Bool) -> a -> [(a, b)] -> Maybe b
+lookupBy eq x xys = fmap snd (find (eq x . fst) xys)
+
+openFileM :: FilePath -> IOMode -> IO (Maybe Handle)
+openFileM path m = do
+  r <- (try $ openFile path m) :: IO (Either IOError Handle)
+  case r of
+    Left _ -> return Nothing
+    Right h -> return (Just h)
+
+--when :: Bool -> IO () -> IO ()
+--when = M.when
+
+on :: (a -> a -> b) -> (c -> a) -> (c -> c -> b)
+on = F.on
+
+getTimeMilli :: IO Int
+getTimeMilli  = floor . (1000 *) . nominalDiffTimeToSeconds . utcTimeToPOSIXSeconds <$> getCurrentTime
+
+padLeft :: Int -> String -> String
+padLeft n s = replicate (n - length s) ' ' ++ s
+
+spanUntil :: forall a . (a -> Bool) -> [a] -> ([a], [a])
+spanUntil p =
+  let
+    rec r [] = (reverse r, [])
+    rec r (x:xs) = if p x then rec (x:r) xs else (reverse (x:r), xs)
+  in rec []
+
+-- A hack until we have a real withArgs
+withDropArgs :: Int -> IO a -> IO a
+withDropArgs i ioa = do
+  as <- getArgs
+  withArgs (drop i as) ioa
+
+-- A simple "quicksort" for now.
+sortLE :: forall a . (a -> a -> Bool) -> [a] -> [a]
+sortLE _  [] = []
+sortLE le (x:xs) = sortLE le lt ++ (x : sortLE le ge)
+  where (ge, lt) = partition (le x) xs
+
+deleteAllBy :: forall a . (a -> a -> Bool) -> a -> [a] -> [a]
+deleteAllBy _ _ [] = []
+deleteAllBy eq x (y:ys) = if eq x y then deleteAllBy eq x ys else y : deleteAllBy eq x ys
+
+deleteAllsBy :: forall a . (a -> a -> Bool) -> [a] -> [a] -> [a]
+deleteAllsBy eq = foldl (flip (deleteAllBy eq))
+
+forceString :: String -> ()
+forceString [] = ()
+forceString (c:cs) = c `seq` forceString cs
+
+forceList :: forall a . (a -> ()) -> [a] -> ()
+forceList _ [] = ()
+forceList f (a:as) = case f a of { () -> forceList f as }
+
+writeSerialized :: FilePath -> a -> IO ()
+writeSerialized _ _ = error "writeSerialized"
+
+eqBool :: Bool -> Bool -> Bool
+eqBool True  x = x
+eqBool False x = not x
+
+neBool :: Bool -> Bool -> Bool
+neBool True  x = not x
+neBool False x = x
+
+-- Temporary until overloading
+primIsInt        :: Any -> Bool
+primIsInt         = error "isInt"
+primIsIO         :: Any -> Bool
+primIsIO          = error "isIO"
+
+newtype Exn = Exn String
+  deriving (Show)
+instance Exception Exn
+
+isPrefixOfBy :: forall a . (a -> a -> Bool) -> [a] -> [a] -> Bool
+isPrefixOfBy _ [] _ = True
+isPrefixOfBy _ _ [] = False
+isPrefixOfBy eq (c:cs) (d:ds) = eq c d && isPrefixOfBy eq cs ds
+
+isEQ :: Ordering -> Bool
+isEQ EQ = True
+isEQ _  = False
+
+compareString :: String -> String -> Ordering
+compareString = compare
+
+anySame :: (Eq a) => [a] -> Bool
+anySame = anySameBy (==)
+
+anySameBy :: (a -> a -> Bool) -> [a] -> Bool
+anySameBy _ [] = False
+anySameBy eq (x:xs) = elemBy eq x xs || anySameBy eq xs
+
+-- Convert string in scientific notation to a rational number.
+readRational :: String -> Rational
+readRational "" = undefined
+readRational acs@(sgn:as) | sgn == '-' = negate $ rat1 as
+                          | otherwise  =          rat1 acs
+  where
+    rat1 s1 =
+      case span isDigit s1 of
+        (ds1, cr1) | ('.':r1) <- cr1                   -> rat2 f1 r1
+                   | (c:r1)   <- cr1, toLower c == 'e' -> rat3 f1 r1
+                   | otherwise                         -> f1
+          where f1 = toRational (readInteger ds1)
+
+    rat2 f1 s2 =
+      case span isDigit s2 of
+        (ds2, cr2) | (c:r2) <- cr2, toLower c == 'e' -> rat3 f2 r2
+                   | otherwise                       -> f2
+          where f2 = f1 + toRational (readInteger ds2) * 10 ^^ (negate $ length ds2)
+
+    rat3 f2 ('+':s) = f2 * expo s
+    rat3 f2 ('-':s) = f2 / expo s
+    rat3 f2      s  = f2 * expo s
+
+    expo s = 10 ^ readInteger s
--- a/ghc/Data/Bool_Type.hs
+++ /dev/null
@@ -1,1 +1,0 @@
-module Data.Bool_Type(Bool(..)) where
--- a/ghc/Data/Char_Type.hs
+++ /dev/null
@@ -1,1 +1,0 @@
-module Data.Char_Type(Char, String) where
--- a/ghc/Data/Double.hs
+++ /dev/null
@@ -1,4 +1,0 @@
-module Data.Double(Double, showDouble, negate) where
-
-showDouble :: Double -> [Char]
-showDouble = show
--- a/ghc/Data/List_Type.hs
+++ /dev/null
@@ -1,2 +1,0 @@
-module Data.List_Type((++)) where
--- There is no need to export anything, ghc always provides the list syntax.
--- a/ghc/Data/Ordering_Type.hs
+++ /dev/null
@@ -1,1 +1,0 @@
-module Data.Ordering_Type(Ordering(..)) where
--- a/ghc/PrimFromInteger.hs
+++ /dev/null
@@ -1,5 +1,0 @@
-module PrimFromInteger where
-import qualified Prelude as P
-
-fromInteger :: P.Integer -> P.Int
-fromInteger = P.fromInteger
--- a/ghc/Primitives.hs
+++ /dev/null
@@ -1,254 +1,0 @@
-module Primitives(
-  module Primitives,
-  Any,
-  Char,
-  Handle,
-  Int,
-  Double,
-  IO,
-  Word,
-  NFData(..),
-  Type,
-  ) where
-import Prelude hiding(fromInteger, fromRational)
-import qualified Prelude as P
-import Control.DeepSeq
-import Control.Exception(try)
-import Data.Time
-import Data.Time.Clock.POSIX
---import Data.Word
-import System.IO
-import System.IO.Unsafe
-import System.Environment
-import Unsafe.Coerce
-import GHC.Types(Any, Type)
-
-primIntAdd :: Int -> Int -> Int
-primIntAdd = (+)
-
-primIntSub :: Int -> Int -> Int
-primIntSub = (-)
-
-primIntMul :: Int -> Int -> Int
-primIntMul = (*)
-
-primIntQuot :: Int -> Int -> Int
-primIntQuot = quot
-
-primIntRem :: Int -> Int -> Int
-primIntRem = rem
-
-primIntSubR :: Int -> Int -> Int
-primIntSubR = subtract
-
-primIntEQ :: Int -> Int -> Bool
-primIntEQ = (==)
-
-primIntNE :: Int -> Int -> Bool
-primIntNE = (/=)
-
-primIntLT :: Int -> Int -> Bool
-primIntLT = (<)
-
-primIntLE :: Int -> Int -> Bool
-primIntLE = (<=)
-
-primIntGT :: Int -> Int -> Bool
-primIntGT = (>)
-
-primIntGE :: Int -> Int -> Bool
-primIntGE = (>=)
-
-primCharEQ :: Char -> Char -> Bool
-primCharEQ = (==)
-
-primCharNE :: Char -> Char -> Bool
-primCharNE = (/=)
-
-primCharLT :: Char -> Char -> Bool
-primCharLT = (<)
-
-primCharLE :: Char -> Char -> Bool
-primCharLE = (<=)
-
-primCharGT :: Char -> Char -> Bool
-primCharGT = (>)
-
-primCharGE :: Char -> Char -> Bool
-primCharGE = (>=)
-
-primOrd :: Char -> Int
-primOrd = fromEnum
-
-primChr :: Int -> Char
-primChr = toEnum
-
-primFix :: (a -> a) -> a
-primFix f = let a = f a in a
-
-primError :: String -> a
-primError = error
-
-primStringEQ :: String -> String -> Bool
-primStringEQ = (==)
-
-primUnsafeCoerce :: a -> b
-primUnsafeCoerce = unsafeCoerce
-
-primSeq :: a -> b -> b
-primSeq = seq
-
-primWordEQ :: Word -> Word -> Bool
-primWordEQ = (==)
-
-primWordNE :: Word -> Word -> Bool
-primWordNE = (/=)
-
-primWordAdd :: Word -> Word -> Word
-primWordAdd = (+)
-
-primWordSub :: Word -> Word -> Word
-primWordSub = (-)
-
-primWordMul :: Word -> Word -> Word
-primWordMul = (*)
-
-primWordQuot :: Word -> Word -> Word
-primWordQuot = quot
-
-primWordRem :: Word -> Word -> Word
-primWordRem = rem
-
-primWordLT :: Word -> Word -> Bool
-primWordLT = (<)
-
-primWordLE :: Word -> Word -> Bool
-primWordLE = (<=)
-
-primWordGT :: Word -> Word -> Bool
-primWordGT = (>)
-
-primWordGE :: Word -> Word -> Bool
-primWordGE = (>=)
-
-primDoubleAdd :: Double -> Double -> Double
-primDoubleAdd  = (+)
-
-primDoubleSub :: Double -> Double -> Double
-primDoubleSub  = (-)
-
-primDoubleMul :: Double -> Double -> Double
-primDoubleMul  = (*)
-
-primDoubleDiv :: Double -> Double -> Double
-primDoubleDiv = (/)
-
-primDoubleEQ :: Double -> Double -> Bool
-primDoubleEQ = (==)
-
-primDoubleNE :: Double -> Double -> Bool
-primDoubleNE = (/=)
-
-primDoubleLT :: Double -> Double -> Bool
-primDoubleLT = (<)
-
-primDoubleLE :: Double -> Double -> Bool
-primDoubleLE = (<=)
-
-primDoubleGT :: Double -> Double -> Bool
-primDoubleGT = (>)
-
-primDoubleGE :: Double -> Double -> Bool
-primDoubleGE = (>=)
-
-primDoubleShow :: Double -> [Char]
-primDoubleShow = show
-
-primDoubleRead :: [Char] -> Double
-primDoubleRead = read
-
-primDoubleFromInt :: Int -> Double
-primDoubleFromInt = fromIntegral
-
-------
-
-primBind         :: IO a -> (a -> IO b) -> IO b
-primBind          = (>>=)
-primThen         :: IO a -> IO b -> IO b
-primThen          = (>>)
-primReturn       :: a -> IO a
-primReturn        = return
-primHPutChar     :: Handle -> Int -> IO ()
-primHPutChar h c  = hPutChar h (toEnum c)
-primHGetChar     :: Handle -> IO Int
-primHGetChar h    = do eof <- hIsEOF h; if eof then pure (-1) else fromEnum <$> hGetChar h
-primOpenFile     :: String -> Int -> IO Handle
-primOpenFile s m  = do
-  r <- (try $ openFile s (case m of 0->ReadMode; 1->WriteMode; 2->AppendMode; 3->ReadWriteMode; _->undefined)) :: IO (Either IOError Handle)
-  -- A gruesome hack to signal a failed as a Handle
-  case r of
-    Left _ -> return $ unsafeCoerce (0 :: Int)
-    Right h -> return h
-primIsNullHandle :: Handle -> Bool
-primIsNullHandle h = unsafeCoerce h == (0 :: Int)
-primHSerialize   :: Handle -> a -> IO ()
-primHSerialize    = undefined
-primHDeserialize :: Handle -> IO a
-primHDeserialize  = undefined
-primHPrint       :: Handle -> a -> IO ()
-primHPrint        = undefined
-primHClose       :: Handle -> IO ()
-primHClose        = hClose
-primHFlush       :: Handle -> IO ()
-primHFlush        = hFlush
-primStdin        :: Handle
-primStdin         = stdin
-primStdout       :: Handle
-primStdout        = stdout
-primStderr       :: Handle
-primStderr        = stderr
-primGetArgs      :: IO [[Char]]
-primGetArgs       = getArgs
-primWithDropArgs :: Int -> IO a -> IO a
-primWithDropArgs i ioa = do
-  as <- getArgs
-  withArgs (drop i as) ioa
-primPerformIO    :: IO a -> a
-primPerformIO     = unsafePerformIO
--- Current time (since 1970-01-01T00:00:00UTC) in ms
-primGetTimeMilli :: IO Int
-primGetTimeMilli  = floor . (1000 *) . nominalDiffTimeToSeconds . utcTimeToPOSIXSeconds <$> getCurrentTime
-primGetRaw       :: IO Int
-primGetRaw        = return (-1) -- not implemented
-
-primCatch        :: forall a . IO a -> (String -> IO a) -> IO a
-primCatch         = error "primCatch"
-
--- Temporary until overloading
-primIsInt        :: Any -> Bool
-primIsInt         = error "primIsInt"
-primIsIO         :: Any -> Bool
-primIsIO          = error "primIsIO"
-
-{-
-primCompare      :: String -> String -> Int
-primCompare s t =
-  case compare s t of
-    LT -> -1
-    EQ -> 0
-    GT -> 1
--}
-primCompare      :: String -> String -> Ordering
-primCompare = compare
-
-primRnf :: (NFData a) => a -> ()
-primRnf = rnf
-
---fromInteger :: Integer -> Int
---fromInteger = P.fromInteger
-
-fromRational :: Rational -> Double
-fromRational = P.fromRational
-
-ifThenElse :: Bool -> a -> a -> a
-ifThenElse c t e = if c then t else e
--- a/ghc/System/Console/SimpleReadline.hs
+++ /dev/null
@@ -1,4 +1,0 @@
-module System.Console.SimpleReadline where
-
-getInputLineHist :: FilePath -> String -> IO (Maybe String)
-getInputLineHist _ _ = error "getInputLineHist not available with ghc"
--- a/lib/PreludeNoIO.hs
+++ /dev/null
@@ -1,24 +1,0 @@
--- Copyright 2023 Lennart Augustsson
--- See LICENSE file for full license.
-module PreludeNoIO(
-  module Control.Error,
-  module Data.Bool,
-  module Data.Char,
-  module Data.Either,
-  module Data.Function,
-  module Data.Int,
-  module Data.List,
-  module Data.Maybe,
-  module Data.Tuple,
-  module Text.String
-  ) where
-import Control.Error
-import Data.Bool
-import Data.Char
-import Data.Either
-import Data.Function
-import Data.Int
-import Data.List
-import Data.Maybe
-import Data.Tuple
-import Text.String
--- a/src/Compat.hs
+++ /dev/null
@@ -1,211 +1,0 @@
--- Copyright 2023 Lennart Augustsson
--- See LICENSE file for full license.
--- Functions for GHC that are defined in the UHS libs.
-module Compat(module Compat) where
---import Control.Exception
-import qualified Data.Function as F
-import Data.Char
-import Data.Time
-import Data.Time.Clock.POSIX
---import qualified Control.Monad as M
-import Control.Exception
-import Data.List
-import System.Environment
-import System.IO
-import GHC.Types(Any)
-
--- Functions needed for ghc
-eqChar :: Char -> Char -> Bool
-eqChar = (==)
-
-neChar :: Char -> Char -> Bool
-neChar = (/=)
-
-ltChar :: Char -> Char -> Bool
-ltChar = (<)
-
-eqString :: String -> String -> Bool
-eqString = (==)
-
-leString :: String -> String -> Bool
-leString = (<=)
-
-readInt :: String -> Int
-readInt = read
-
-readInteger :: String -> Integer
-readInteger = read
-
-readDouble :: String -> Double
-readDouble = read
-
-_integerToInt :: Integer -> Int
-_integerToInt = fromInteger
-
-_intToInteger :: Int -> Integer
-_intToInteger = fromIntegral
-
-_integerToDouble :: Integer -> Double
-_integerToDouble = fromIntegral
-
--- Same as in Data.Integer
-_integerToIntList :: Integer -> [Int]
-_integerToIntList i | i < 0 = -1 : to (-i)
-                    | otherwise =  to i
-  where to 0 = []
-        to n = fromInteger r : to q  where (q, r) = quotRem n 2147483648
-
-xshowChar :: Char -> String
-xshowChar = show
-
-showListS :: (a -> String) -> [a] -> String
-showListS sa arg =
-  let
-    showRest as =
-      case as of
-        [] -> "]"
-        x : xs -> "," ++ sa x ++ showRest xs
-  in
-    case arg of
-      [] -> "[]"
-      a : as -> "[" ++ sa a ++ showRest as
-
-showPairS :: (a -> String) -> (b -> String) -> (a, b) -> String
-showPairS f g (a, b) = "(" ++ f a ++ "," ++ g b ++ ")"
-
-elemBy :: (a -> a -> Bool) -> a -> [a] -> Bool
-elemBy eq a = any (eq a)
-
-stripPrefixBy :: (a -> a -> Bool) -> [a] -> [a] -> Maybe [a]
-stripPrefixBy eq p s =
-  case p of
-    [] -> Just s
-    c : cs ->
-      case s of
-        [] -> Nothing
-        d : ds ->
-          if eq c d then
-            stripPrefixBy eq cs ds
-          else
-            Nothing
-
-lookupBy :: (a -> a -> Bool) -> a -> [(a, b)] -> Maybe b
-lookupBy eq x xys = fmap snd (find (eq x . fst) xys)
-
-openFileM :: FilePath -> IOMode -> IO (Maybe Handle)
-openFileM path m = do
-  r <- (try $ openFile path m) :: IO (Either IOError Handle)
-  case r of
-    Left _ -> return Nothing
-    Right h -> return (Just h)
-
---when :: Bool -> IO () -> IO ()
---when = M.when
-
-on :: (a -> a -> b) -> (c -> a) -> (c -> c -> b)
-on = F.on
-
-getTimeMilli :: IO Int
-getTimeMilli  = floor . (1000 *) . nominalDiffTimeToSeconds . utcTimeToPOSIXSeconds <$> getCurrentTime
-
-padLeft :: Int -> String -> String
-padLeft n s = replicate (n - length s) ' ' ++ s
-
-spanUntil :: forall a . (a -> Bool) -> [a] -> ([a], [a])
-spanUntil p =
-  let
-    rec r [] = (reverse r, [])
-    rec r (x:xs) = if p x then rec (x:r) xs else (reverse (x:r), xs)
-  in rec []
-
--- A hack until we have a real withArgs
-withDropArgs :: Int -> IO a -> IO a
-withDropArgs i ioa = do
-  as <- getArgs
-  withArgs (drop i as) ioa
-
--- A simple "quicksort" for now.
-sortLE :: forall a . (a -> a -> Bool) -> [a] -> [a]
-sortLE _  [] = []
-sortLE le (x:xs) = sortLE le lt ++ (x : sortLE le ge)
-  where (ge, lt) = partition (le x) xs
-
-deleteAllBy :: forall a . (a -> a -> Bool) -> a -> [a] -> [a]
-deleteAllBy _ _ [] = []
-deleteAllBy eq x (y:ys) = if eq x y then deleteAllBy eq x ys else y : deleteAllBy eq x ys
-
-deleteAllsBy :: forall a . (a -> a -> Bool) -> [a] -> [a] -> [a]
-deleteAllsBy eq = foldl (flip (deleteAllBy eq))
-
-forceString :: String -> ()
-forceString [] = ()
-forceString (c:cs) = c `seq` forceString cs
-
-forceList :: forall a . (a -> ()) -> [a] -> ()
-forceList _ [] = ()
-forceList f (a:as) = case f a of { () -> forceList f as }
-
-writeSerialized :: FilePath -> a -> IO ()
-writeSerialized _ _ = error "writeSerialized"
-
-eqBool :: Bool -> Bool -> Bool
-eqBool True  x = x
-eqBool False x = not x
-
-neBool :: Bool -> Bool -> Bool
-neBool True  x = not x
-neBool False x = x
-
--- Temporary until overloading
-primIsInt        :: Any -> Bool
-primIsInt         = error "isInt"
-primIsIO         :: Any -> Bool
-primIsIO          = error "isIO"
-
-newtype Exn = Exn String
-  deriving (Show)
-instance Exception Exn
-
-isPrefixOfBy :: forall a . (a -> a -> Bool) -> [a] -> [a] -> Bool
-isPrefixOfBy _ [] _ = True
-isPrefixOfBy _ _ [] = False
-isPrefixOfBy eq (c:cs) (d:ds) = eq c d && isPrefixOfBy eq cs ds
-
-isEQ :: Ordering -> Bool
-isEQ EQ = True
-isEQ _  = False
-
-compareString :: String -> String -> Ordering
-compareString = compare
-
-anySame :: (Eq a) => [a] -> Bool
-anySame = anySameBy (==)
-
-anySameBy :: (a -> a -> Bool) -> [a] -> Bool
-anySameBy _ [] = False
-anySameBy eq (x:xs) = elemBy eq x xs || anySameBy eq xs
-
--- Convert string in scientific notation to a rational number.
-readRational :: String -> Rational
-readRational "" = undefined
-readRational acs@(sgn:as) | sgn == '-' = negate $ rat1 as
-                          | otherwise  =          rat1 acs
-  where
-    rat1 s1 =
-      case span isDigit s1 of
-        (ds1, cr1) | ('.':r1) <- cr1                   -> rat2 f1 r1
-                   | (c:r1)   <- cr1, toLower c == 'e' -> rat3 f1 r1
-                   | otherwise                         -> f1
-          where f1 = toRational (readInteger ds1)
-
-    rat2 f1 s2 =
-      case span isDigit s2 of
-        (ds2, cr2) | (c:r2) <- cr2, toLower c == 'e' -> rat3 f2 r2
-                   | otherwise                       -> f2
-          where f2 = f1 + toRational (readInteger ds2) * 10 ^^ (negate $ length ds2)
-
-    rat3 f2 ('+':s) = f2 * expo s
-    rat3 f2 ('-':s) = f2 / expo s
-    rat3 f2      s  = f2 * expo s
-
-    expo s = 10 ^ readInteger s
--- a/src/CompatIO.hs
+++ /dev/null
@@ -1,22 +1,0 @@
-module CompatIO where
-import Prelude hiding (Monad(..))
-import qualified Prelude as P
-import qualified Control.Monad as M
-
-(>>=) :: IO a -> (a -> IO b) -> IO b
-(>>=) = (P.>>=)
-
-(>>) :: IO a -> IO b -> IO b
-(>>) = (P.>>)
-
-return :: a -> IO a
-return = P.return
-
-when :: Bool -> IO () -> IO ()
-when = M.when
-
-fail        :: forall a . String -> IO a
-fail s       = error s
-
-fmap :: (a -> b) -> IO a -> IO b
-fmap = P.fmap
--- a/src/MicroHs/StateIO.hs
+++ b/src/MicroHs/StateIO.hs
@@ -12,8 +12,6 @@
 import Control.Applicative
 import Control.Monad
 import Data.Functor --Xhiding(unzip)
---import qualified System.IO as IO
---Ximport qualified CompatIO as IO
 
 data StateIO s a = S (s -> IO (a,s))
 
--- a/src/PreludeNoIO.hs
+++ /dev/null
@@ -1,4 +1,0 @@
--- Copyright 2023 Lennart Augustsson
--- See LICENSE file for full license.
-module PreludeNoIO(module Prelude) where
-import Prelude hiding (Monad(..), MonadFail(..), Applicative(..), Functor(..), (<$>), showString)
--