shithub: MicroHs

Download patch

ref: 30bf0fefd83707e86533acee179d47e3bbbc2195
parent: fa5fad4b37eb6242d09a07e39ad3a200d45be95d
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Tue Feb 20 11:46:56 EST 2024

Include enough stuff that cpphs can be bootstrapped.

--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,13 @@
 	@echo "*** stage2 equal to stage1"
 	$(CCEVAL) generated/mhs-stage2.c -o bin/mhs-stage2
 
+cpphssrc/malcolm-wallace-universe:
+	mkdir -p cpphssrc
+	cd cpphssrc; git clone --branch dot-spaces git@github.com:augustss/malcolm-wallace-universe.git
+
+bootstrapcpphs: cpphssrc/malcolm-wallace-universe bin/cpphs
+	MHSCPPHS=bin/cpphs bin/mhs -XCPP -icpphssrc/malcolm-wallace-universe/polyparse-1.12/src -icpphssrc/malcolm-wallace-universe/cpphs-1.20.9 cpphssrc/malcolm-wallace-universe/cpphs-1.20.9/cpphs.hs -ogenerated/cpphs.c
+
 # Run test examples with ghc-compiled compiler
 runtest:	bin/mhseval bin/gmhs tests/*.hs
 	cd tests; make alltest
--- a/README.md
+++ b/README.md
@@ -294,6 +294,15 @@
 do `make bootstrap`.  This will recompile the compiler twice and compare
 the outputs to make sure the new compiler still works.
 
+# Preprocessor
+Sadly, compiling a lot of Haskell packages needs the C preprocessor.
+To this end, the distribution contains the combinator code for `cpphs`.
+Doing `make bin/cpphs` will create the binary for the preprocessor.
+
+To bootstrap `cpphs` you can do `make bootstrapcpphs`.
+This assumes that you have `git` to download the needed packages.
+At the moment, the downloaded packages are forks of the original to
+make it compile with `mhs`.
 
 # FAQ
 * 
--- /dev/null
+++ b/lib/Data/Time/Clock.hs
@@ -1,0 +1,17 @@
+-- A hack to be able to compile cpphs.
+-- We need a proper package for this.
+module Data.Time.Clock(
+  UTCTime(..),
+  getCurrentTime,
+  ) where
+import Prelude
+import System.IO
+
+-- Second since 1970, probably
+newtype UTCTime = UTCTime Int
+  deriving (Show)
+
+getCurrentTime :: IO UTCTime
+getCurrentTime = do
+  t <- getTimeMilli
+  return $ UTCTime $ t `quot` 1000
--- /dev/null
+++ b/lib/Data/Time/Format.hs
@@ -1,0 +1,7 @@
+module Data.Time.Format(module Data.Time.Format) where
+import Data.Time.Clock
+
+data TimeLocale
+
+formatTime :: TimeLocale -> String -> UTCTime -> String
+formatTime _ _ (UTCTime t) = show t ++ "s"
--- /dev/null
+++ b/lib/TimeCompat.hs
@@ -1,0 +1,6 @@
+module TimeCompat(module TimeCompat) where
+import Prelude
+import Data.Time.Format
+
+defaultTimeLocale :: TimeLocale
+defaultTimeLocale = error "defaultTimeLocale"
--