shithub: MicroHs

Download patch

ref: b62ae9934dbc2e9324e1c2b85265f9f0a36eeb73
parent: b29c281fb78c5fec611a49f8e0b791d3e9c48264
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Fri Sep 22 07:31:16 EDT 2023

Make it work with cabal

--- a/MicroHs.cabal
+++ b/MicroHs.cabal
@@ -63,6 +63,7 @@
                        Primitives
   build-depends:       base         >= 4.10 && < 4.20,
                        containers   >= 0.5 && < 0.8,
+                       deepseq      >= 1.1 && < 1.6,
                        ghc-prim     >= 0.5 && < 0.11,
                        mtl          >= 2.0 && < 2.4,
                        time         >= 1.1 && < 1.15
--- a/README.md
+++ b/README.md
@@ -9,11 +9,15 @@
 * Using GHC with standard `Prelude` and libraries. `Makefile` target `bin/mhs`
 * Using GHC, but with `Prelude` and libraries from MicroHs. `Makefile` target `bin/bootmhs`
 * Using mhs, with the supplied `comb/mhs.comb`. `Makefile` target `comb/mhs-new.comb`
-These differenty ways need slightly different imports etc.  To accomodate this
-each source file is preprocessed for the first two targets.
+
+These different ways of compiling need slightly different imports etc.
+To accomodate this each source file is preprocessed for the first two targets.
 When compiling with GHC and standard libraries the strings `--X` and `--W` are removed from the source file.
 When compiling with GHC and MicroHs libraries the strings `--Y` and `--W` are removed from the source file.
 This way anything special needed with GHC is just treated as comments by mhs.
+
+Compiling MicroHs is really best done using `make`, but there is also a `MicroHs.cabal` file
+for use with `cabal`.
 
 ## Language
 The language is a subset of Haskell.  There is only simple Hindley-Milner polymorphism,
--- a/ghc/Primitives.hs
+++ b/ghc/Primitives.hs
@@ -12,7 +12,7 @@
 import Control.Exception(try)
 import Data.Time
 import Data.Time.Clock.POSIX
-import Data.Word
+--import Data.Word
 import System.IO
 import System.IO.Unsafe
 import System.Environment
@@ -141,7 +141,7 @@
 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)) :: IO (Either IOError Handle)
+  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)
@@ -148,13 +148,21 @@
     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
--