From e805baacb77baa58d7e11a65907544b2d800143b Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Wed, 12 Nov 2025 01:14:09 +0000 Subject: [PATCH 1/5] haskell.{compiler,packages}.microhs: init The package set is built entirely from source using the stdenv and Hugs. This also replaces the recently added microhs package, which was built from pre-generated compiler output. Co-authored-by: sternenseemann --- doc/release-notes/rl-2605.section.md | 2 + maintainers/maintainer-list.nix | 14 + pkgs/by-name/mi/microhs/package.nix | 46 -- .../compilers/microhs/0.15.4.0.nix | 4 + pkgs/development/compilers/microhs/boot.nix | 40 ++ pkgs/development/compilers/microhs/common.nix | 94 ++++ pkgs/development/compilers/microhs/cpphs.nix | 50 +++ .../microhs/patches/hugs-viewpatterns.patch | 406 +++++++++++++++++ .../compilers/microhs/patches/hugs.patch | 365 +++++++++++++++ .../compilers/microhs/patches/link-math.patch | 21 + .../microhs/patches/simple-unicode.patch | 35 ++ pkgs/development/compilers/microhs/stage1.nix | 36 ++ pkgs/development/compilers/microhs/stage2.nix | 61 +++ .../compilers}/microhs/test-hello-world.nix | 0 .../development/compilers/microhs/wrapper.nix | 52 +++ .../haskell-modules/configuration-microhs.nix | 78 ++++ .../haskell-modules/make-package-set.nix | 104 +++-- .../haskell-modules/microhs-builder.nix | 420 ++++++++++++++++++ ...f1b5dec81561a1b1d36b8e3065ce091dce2ec6.nix | 7 + .../tools/haskell/microcabal/common.nix | 69 +++ pkgs/top-level/haskell-packages.nix | 25 +- 21 files changed, 1836 insertions(+), 93 deletions(-) delete mode 100644 pkgs/by-name/mi/microhs/package.nix create mode 100644 pkgs/development/compilers/microhs/0.15.4.0.nix create mode 100644 pkgs/development/compilers/microhs/boot.nix create mode 100644 pkgs/development/compilers/microhs/common.nix create mode 100644 pkgs/development/compilers/microhs/cpphs.nix create mode 100644 pkgs/development/compilers/microhs/patches/hugs-viewpatterns.patch create mode 100644 pkgs/development/compilers/microhs/patches/hugs.patch create mode 100644 pkgs/development/compilers/microhs/patches/link-math.patch create mode 100644 pkgs/development/compilers/microhs/patches/simple-unicode.patch create mode 100644 pkgs/development/compilers/microhs/stage1.nix create mode 100644 pkgs/development/compilers/microhs/stage2.nix rename pkgs/{by-name/mi => development/compilers}/microhs/test-hello-world.nix (100%) create mode 100644 pkgs/development/compilers/microhs/wrapper.nix create mode 100644 pkgs/development/haskell-modules/configuration-microhs.nix create mode 100644 pkgs/development/haskell-modules/microhs-builder.nix create mode 100644 pkgs/development/tools/haskell/microcabal/0.5.3.0-31f1b5dec81561a1b1d36b8e3065ce091dce2ec6.nix create mode 100644 pkgs/development/tools/haskell/microcabal/common.nix diff --git a/doc/release-notes/rl-2605.section.md b/doc/release-notes/rl-2605.section.md index 2e5d9f73d444..f19364281c28 100644 --- a/doc/release-notes/rl-2605.section.md +++ b/doc/release-notes/rl-2605.section.md @@ -284,6 +284,8 @@ - the `autossh-ng` NixOS module was introduced as a simpler alternative to the existing `autossh` module. +- Added `haskell.packages.microhs`, a set of Haskell packages built with MicroHs. + - `gnuradio`: Overriding the `.pkgs` package set is now possible with a `packageOverrides` function, like with `python.pkgs` and other language-specific package sets. Example: diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 115c78f08cf3..44c2aabf8e95 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -1192,6 +1192,20 @@ githubId = 49609151; name = "Popa Ioan Alexandru"; }; + AlexandreTunstall = { + name = "Alex Tunstall"; + email = "alex@tunstall.xyz"; + matrix = "@alex:tunstall.xyz"; + github = "AlexandreTunstall"; + githubId = 32900877; + keys = [ + { + # Fetch with WKD (e.g. gpg --locate-external-keys alex@tunstall.xyz) + # The fetched key should have this fingerprint (please let me know if not) + fingerprint = "51A5 8478 068E B19D FD35 D542 F6CA 1AD5 54DC A5E4"; + } + ]; + }; alexandru0-dev = { email = "alexandru.italia32+nixpkgs@gmail.com"; github = "alexandru0-dev"; diff --git a/pkgs/by-name/mi/microhs/package.nix b/pkgs/by-name/mi/microhs/package.nix deleted file mode 100644 index 847f3c766f66..000000000000 --- a/pkgs/by-name/mi/microhs/package.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ - callPackage, - stdenv, - fetchFromGitHub, - lib, - writableTmpDirAsHomeHook, - nix-update-script, -}: - -stdenv.mkDerivation (finalAttrs: { - pname = "microhs"; - version = "0.15.4.0"; - - src = fetchFromGitHub { - owner = "augustss"; - repo = "MicroHs"; - tag = "v${finalAttrs.version}"; - hash = "sha256-V3Of72rpXvImV90sSoYz02H06o1J3FqHDQNbB+M6/8A="; - }; - - # mcabal doesn't seem to respect the make flag and fails with /homeless-shelter - # This works around the issue - nativeBuildInputs = [ writableTmpDirAsHomeHook ]; - - makeFlags = [ "MCABAL=$(out)" ]; - buildFlags = [ "bootstrap" ]; - - # MicroCabal is a separate repository, which should be packaged separately - # The MicroCabal that is installed by `make install` is pregenerated, does not respect MCABAL above, and so is not useable - postInstall = "rm $out/bin/mcabal"; - - passthru = { - updateScript = nix-update-script { }; - tests = { - hello-world = callPackage ./test-hello-world.nix { microhs = finalAttrs.finalPackage; }; - }; - }; - - meta = { - description = "Haskell implemented with combinators"; - homepage = "https://github.com/augustss/MicroHs"; - license = lib.licenses.asl20; - maintainers = [ lib.maintainers.steeleduncan ]; - platforms = lib.platforms.all; - }; -}) diff --git a/pkgs/development/compilers/microhs/0.15.4.0.nix b/pkgs/development/compilers/microhs/0.15.4.0.nix new file mode 100644 index 000000000000..b0f454e723a0 --- /dev/null +++ b/pkgs/development/compilers/microhs/0.15.4.0.nix @@ -0,0 +1,4 @@ +import ./common.nix { + version = "0.15.4.0"; + hash = "sha256-FUr2EA3zbmt2Tr2F8zT1wHnB8GDlUVb2W1fP4IqNd80="; +} diff --git a/pkgs/development/compilers/microhs/boot.nix b/pkgs/development/compilers/microhs/boot.nix new file mode 100644 index 000000000000..b55587a8438f --- /dev/null +++ b/pkgs/development/compilers/microhs/boot.nix @@ -0,0 +1,40 @@ +{ + stdenvNoCC, + hugs, + makeWrapper, + microhs-src, +}: + +stdenvNoCC.mkDerivation { + pname = "microhs"; + version = "${microhs-src.version}-hugs"; + + inherit (microhs-src) + src + patches + postPatch + meta + ; + + nativeBuildInputs = [ makeWrapper ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/bin" "$out/share/microhs-hugs" + s="$out/share/microhs-hugs/src" + cp -r . "$s" + + makeWrapper ${hugs}/bin/runhugs "$out/bin/mhs" \ + --add-flags "'+P$s/hugs:$s/src:$s/paths:{Hugs}/packages/*:hugs/obj' -98 +o +w -h100m '$s/hugs/Main.hs'" + + runHook postInstall + ''; + + passthru = { + isMhs = true; + usesHugs = true; + }; +} diff --git a/pkgs/development/compilers/microhs/common.nix b/pkgs/development/compilers/microhs/common.nix new file mode 100644 index 000000000000..36d65abb2b69 --- /dev/null +++ b/pkgs/development/compilers/microhs/common.nix @@ -0,0 +1,94 @@ +{ + version, + mcabalVersion ? "0.5.3.0-31f1b5dec81561a1b1d36b8e3065ce091dce2ec6", + rev ? "refs/tags/v${version}", + hash, +}: + +{ + lib, + buildPackages, + pkgsBuildBuild, + callPackage, + fetchFromGitHub, + fetchpatch, + microhs-boot, + stdenv, + versionCheckHook, + writeShellScript, +}: + +let + args = finalAttrs: { + inherit version; + + src = fetchFromGitHub { + owner = "augustss"; + repo = "MicroHs"; + fetchSubmodules = true; + inherit rev hash; + }; + + patches = [ + patches/hugs.patch + patches/hugs-viewpatterns.patch + ] + ++ lib.optional stdenv.hostPlatform.isGnu patches/link-math.patch; + + # The source contains pre-compiled files + # We delete them to be certain we are building from source + postPatch = '' + rm -r generated + ''; + + doInstallCheck = true; + + nativeInstallCheckInputs = [ + versionCheckHook + ]; + + meta = { + description = "Small compiler for Haskell"; + longDescription = '' + A compiler for an extended subset of Haskell 2010. + The compiler translates to combinators and can compile itself. + ''; + homepage = "https://github.com/augustss/MicroHs"; + license = lib.licensesSpdx."Apache-2.0"; + mainProgram = "mhs"; + maintainers = with lib.maintainers; [ + AlexandreTunstall + steeleduncan + ]; + platforms = lib.platforms.all; + }; + }; + + microhs-stage1-build = pkgsBuildBuild.callPackage ./stage1.nix { + inherit args microhs-boot; + }; + + microhs-stage1 = buildPackages.callPackage ./stage1.nix { + inherit args microhs-boot; + }; + + microhs-stage2 = callPackage ./stage2.nix { + inherit + args + microcabal-stage1 + microhs-stage1 + cpphs + ; + }; + + microcabal-stage1 = buildPackages.callPackage ../../tools/haskell/microcabal/${mcabalVersion}.nix { + microhs = microhs-stage1-build; + }; + + cpphs = buildPackages.callPackage ./cpphs.nix { + inherit args; + microhs = microhs-stage2; + }; + +in +microhs-stage2 diff --git a/pkgs/development/compilers/microhs/cpphs.nix b/pkgs/development/compilers/microhs/cpphs.nix new file mode 100644 index 000000000000..7b288ebe4120 --- /dev/null +++ b/pkgs/development/compilers/microhs/cpphs.nix @@ -0,0 +1,50 @@ +{ + args, + hugs, + microhs, + stdenv, +}: + +stdenv.mkDerivation ( + finalAttrs: + let + args' = args finalAttrs; + in + args' + // { + pname = "microhs-cpphs"; + + nativeBuildInputs = [ hugs ]; + + makeFlags = [ "USECPPHS=$(TMP)/cpphs-boot" ]; + buildFlags = [ + "bootstrapcpphs" + "bin/cpphs" + ]; + + # Generate cpphs-boot and populate paths that the target uses + # We can't use cpphs-hugs directly because it's too primitive + preBuild = '' + mkdir -p $TMP/cpphs-hugs/src + cp -r hugs/* cpphscompat/* cpphssrc/malcolm-wallace-universe/{polyparse-*/src,cpphs-*}/* $TMP/cpphs-hugs/src/ + find $TMP/cpphs-hugs/src -type f -name '*.hs' -exec ${hugs}/bin/cpphs-hugs --noline '{}' '-O{}.tmp' \; + find $TMP/cpphs-hugs/src -type f -name '*.hs' -exec mv '{}.tmp' '{}' \; + sed -i -e '/fail *= *Fail\.fail/d' $TMP/cpphs-hugs/src/Text/ParserCombinators/Poly/Parser.hs + + ${microhs}/bin/mhs -l -i$TMP/cpphs-hugs/src $TMP/cpphs-hugs/src/cpphs.hs -o$TMP/cpphs-boot + + mkdir -p bin generated + touch cpphssrc/malcolm-wallace-universe/.git targets.conf + cp ${microhs}/bin/mhs bin/mhs + ''; + + installPhase = '' + runHook preInstall + install -m755 -d $out/bin + install -m755 bin/cpphs $out/bin/cpphs + runHook postInstall + ''; + + doInstallCheck = false; + } +) diff --git a/pkgs/development/compilers/microhs/patches/hugs-viewpatterns.patch b/pkgs/development/compilers/microhs/patches/hugs-viewpatterns.patch new file mode 100644 index 000000000000..5fc8c08d2b72 --- /dev/null +++ b/pkgs/development/compilers/microhs/patches/hugs-viewpatterns.patch @@ -0,0 +1,406 @@ +If you need to update this patch, apply it to the old version, then use Git to +rebase it onto the new version. + +diff --git a/src/MicroHs/ExpPrint.hs b/src/MicroHs/ExpPrint.hs +index 59afc0d0..bada27d2 100644 +--- a/src/MicroHs/ExpPrint.hs ++++ b/src/MicroHs/ExpPrint.hs +@@ -30,7 +30,7 @@ removeUnused (ds, emain) = dfs roots M.empty + dMap = M.fromList ds + dfs :: [Ident] -> M.Map Exp -> [LDef] + dfs [] done = M.toList done +- dfs (i:is) done | Just _ <- M.lookup i done = dfs is done ++ dfs (i:is) done | isJust (M.lookup i done) = dfs is done + | otherwise = dfs (freeVars e ++ is) (M.insert i e done) + where e = fromMaybe (error $ "removeUnused: undef " ++ show i) $ M.lookup i dMap + +@@ -81,7 +81,7 @@ toStringCMdl :: CMdl -> String + toStringCMdl (ds, emain) = + let + def :: (Ident, Exp) -> (String -> String) -> (String -> String) +- def (i, e) r | Just (e', _) <- getForExp e = def (i, e') r ++ def (i, e) r | isJust (getForExp e) = let Just (e', _) = getForExp e in def (i, e') r + def (i, e) r = + ("A " ++) . toStringP e . ((":" ++ showIdent i ++ " @\n") ++) . r . ("@" ++) + +diff --git a/src/MicroHs/Expr.hs b/src/MicroHs/Expr.hs +index bd05f1bc..14225927 100644 +--- a/src/MicroHs/Expr.hs ++++ b/src/MicroHs/Expr.hs +@@ -514,7 +514,7 @@ getTupleConstr i = + getExprTuple :: EType -> Maybe [EType] + getExprTuple = loop [] + where loop ts (EApp f a) = loop (a:ts) f +- loop ts (EVar i) | Just n <- getTupleConstr i, length ts == n = Just ts ++ loop ts (EVar i) | isJust (getTupleConstr i) && length ts == fromJust (getTupleConstr i) = Just ts + loop _ _ = Nothing + + -- Create a tuple selector, component i (0 based) of n +@@ -1015,13 +1015,13 @@ ppExprR raw = ppE + ppApp :: [Expr] -> Expr -> Doc + ppApp as (EApp f a) = ppApp (a:as) f + ppApp as f | raw = ppApply f as +- ppApp as (EVar i) | isOperChar cop, [a, b] <- as = parens $ ppE a <+> text op <+> ppExpr b +- | isOperChar cop, [a] <- as = parens $ ppE a <+> text op +- | cop == ',' && length op + 1 == length as +- = ppE (ETuple as) +- | op == "[]", length as == 1 = ppE (EListish (LList as)) +- where op = unIdent (unQualIdent i) +- cop = head op ++ ppApp as (EVar i) = case as of ++ [a, b] | isOperChar cop -> parens $ ppE a <+> text op <+> ppExpr b ++ [a] | isOperChar cop -> parens $ ppE a <+> text op ++ _ | cop == ',' && length op + 1 == length as -> ppE (ETuple as) ++ | op == "[]" && length as == 1 -> ppE (EListish (LList as)) ++ where op = unIdent (unQualIdent i) ++ cop = head op + ppApp as f = ppApply f as + ppApply f as = parens $ hsep (map ppE (f:as)) + +@@ -1212,5 +1212,5 @@ getImplies _ = Nothing + + dropForallContext :: EType -> EType + dropForallContext (EForall _ _ t) = dropForallContext t +-dropForallContext t | Just (_, t') <- getImplies t = dropForallContext t' ++dropForallContext t | isJust (getImplies t) = let Just (_, t') = getImplies t in dropForallContext t' + | otherwise = t +diff --git a/src/MicroHs/FFI.hs b/src/MicroHs/FFI.hs +index 4e79ab18..292a28fb 100644 +--- a/src/MicroHs/FFI.hs ++++ b/src/MicroHs/FFI.hs +@@ -1,6 +1,7 @@ + module MicroHs.FFI(makeFFI) where + import qualified Prelude(); import MHSPrelude + import Data.List ++import Data.Maybe(fromJust, isJust) + import MicroHs.Desugar(LDef) + import MicroHs.Exp + import MicroHs.Expr +@@ -175,7 +176,8 @@ arity = length . fst . getArrows + cTypeHsName :: HasCallStack => EType -> String + cTypeHsName (EApp (EVar ptr) _t) | ptr == identPtr = "Ptr" + | ptr == identFunPtr = "FunPtr" +-cTypeHsName (EVar i) | Just c <- lookup (unIdent i) cHsTypes = c ++cTypeHsName (EVar i) | isJust mc = fromJust mc ++ where mc = lookup (unIdent i) cHsTypes + cTypeHsName t = errorMessage (getSLoc t) $ "Not a valid C type: " ++ showEType t + + cHsTypes :: [(String, String)] +@@ -193,7 +195,8 @@ cHsTypes = + -- Use to construct 'foreign export ccall' signature. + cTypeName :: EType -> String + cTypeName (EApp (EVar ptr) _t) | ptr == identPtr = "void*" +-cTypeName (EVar i) | Just c <- lookup (unIdent i) cTypes = c ++cTypeName (EVar i) | isJust mc = fromJust mc ++ where mc = lookup (unIdent i) cTypes + cTypeName t = errorMessage (getSLoc t) $ "Not a valid C type: " ++ showEType t + + cTypes :: [(String, String)] +@@ -211,7 +214,8 @@ cTypes = + -- Use to construct 'foreign import javascript' return value wrapper. + jsTypeNameR :: EType -> String + jsTypeNameR (EApp (EVar ptr) _) | ptr == identPtr = "PTR" +-jsTypeNameR (EVar i) | Just c <- lookup (unIdent i) jsTypesR = c ++jsTypeNameR (EVar i) | isJust mc = fromJust mc ++ where mc = lookup (unIdent i) jsTypesR + jsTypeNameR t = errorMessage (getSLoc t) $ "Not a valid Javascript return type: " ++ showEType t + + jsTypesR :: [(String, String)] +@@ -224,7 +228,8 @@ jsTypesR = + -- Use to construct 'foreign import javascript' argument wrapper. + jsTypeName :: EType -> String + jsTypeName (EApp (EVar ptr) _) | ptr == identPtr = "Ptr" +-jsTypeName (EVar i) | Just c <- lookup (unIdent i) jsTypes = c ++jsTypeName (EVar i) | isJust mc = fromJust mc ++ where mc = lookup (unIdent i) jsTypes + jsTypeName t = errorMessage (getSLoc t) $ "Not a valid Javascript argument type: " ++ showEType t + + jsTypes :: [(String, String)] +diff --git a/src/MicroHs/Lex.hs b/src/MicroHs/Lex.hs +index 12e0213f..ebe591df 100644 +--- a/src/MicroHs/Lex.hs ++++ b/src/MicroHs/Lex.hs +@@ -8,7 +8,7 @@ module MicroHs.Lex( + import qualified Prelude(); import MHSPrelude hiding(lex) + import Data.Char + import Data.List +-import Data.Maybe (fromJust) ++import Data.Maybe (fromJust, isJust) + import MicroHs.Ident + import Text.ParserComb(TokenMachine(..)) + +@@ -101,14 +101,14 @@ lex loc ('(':dcs@(d:cs)) | d == '#' = TSpec loc 'L' : lex (addCol loc 2) cs + | otherwise = TSpec loc '(' : lex (addCol loc 1) dcs + lex loc ('#':')':cs) = TSpec loc 'R' : lex (addCol loc 2) cs + -- Recognize #line 123 "file/name.hs" +-lex loc ('#':xcs) | (SLoc _ _ 1) <- loc, Just cs <- stripPrefix "line " xcs = ++lex (SLoc _ _ 1) ('#':'l':'i':'n':'e':' ':cs) = + case span (/= '\n') cs of + (line, rs) -> -- rs will contain the '\n', so subtract 1 below + let ws = words line + file = tail $ init $ ws!!1 -- strip the initial and final '"' + loc' = SLoc file (readInt (ws!!0) - 1) 1 + in lex loc' rs +- | (SLoc _ 1 1) <- loc, take 1 xcs == "!" = ++lex loc@(SLoc _ 1 1) ('#':xcs@('!':cs)) = + -- It's a shebang (#!), ignore the rest of the line + skipLine loc xcs + lex loc ('!':' ':cs) = -- ! followed by a space is always an operator +@@ -231,7 +231,7 @@ tIndent ts = TIndent (tokensLoc ts) : ts + + lexLitStr :: SLoc -> SLoc -> (String -> Token) -> (String -> Maybe Int) -> (String -> String) -> String -> [Token] + lexLitStr oloc loc mk end post acs = loop loc [] acs +- where loop l rs cs | Just k <- end cs = mk (decodeEscs $ post $ reverse rs) : lex (addCol l k) (drop k cs) ++ where loop l rs cs | isJust (end cs) = let Just k = end cs in mk (decodeEscs $ post $ reverse rs) : lex (addCol l k) (drop k cs) + loop l rs ('\\':c:cs) | isSpace c = remGap l rs cs + loop l rs ('\\':'^':'\\':cs) = loop (addCol l 3) ('\\':'^':'\\':rs) cs -- special hack for unescaped \ + loop l rs ('\\':cs) = loop' (addCol l 1) ('\\':rs) cs +@@ -270,8 +270,10 @@ decodeEsc ('x':cs) = conv 16 0 cs + decodeEsc ('o':cs) = conv 8 0 cs + decodeEsc ('^':c:cs) | '@' <= c && c <= '_' = chr (ord c - ord '@') : decodeEscs cs + decodeEsc cs@(c:_) | isDigit c = conv 10 0 cs +-decodeEsc (c1:c2:c3:cs) | Just c <- lookup [c1,c2,c3] ctlCodes = c : decodeEscs cs +-decodeEsc (c1:c2:cs) | Just c <- lookup [c1,c2] ctlCodes = c : decodeEscs cs ++decodeEsc (c1:c2:c3:cs) | isJust mc = let Just c = mc in c : decodeEscs cs ++ where mc = lookup [c1,c2,c3] ctlCodes ++decodeEsc (c1:c2:cs) | isJust mc = let Just c = mc in c : decodeEscs cs ++ where mc = lookup [c1,c2] ctlCodes + decodeEsc (c :cs) = c : decodeEscs cs + decodeEsc [] = mhsError "Bad \\ escape" + +@@ -417,7 +419,7 @@ pragma loc cs = + in case words cs of + p : _ | map toUpper p == "SOURCE" -> TPragma loc p : skip + -- hsc2hs generates LINE pragmas +- p : ln@(_:_) : fn : _ | map toUpper p == "LINE", all isDigit ln -> ++ p : ln@(_:_) : fn : _ | map toUpper p == "LINE" && all isDigit ln -> + let f = tail (init fn) + l = readInt ln - 1 + in seq l $ skipNest (SLoc f l 1) 1 ('#':cs) +diff --git a/src/MicroHs/Main.hs b/src/MicroHs/Main.hs +index 913c197b..7f17e313 100644 +--- a/src/MicroHs/Main.hs ++++ b/src/MicroHs/Main.hs +@@ -141,16 +141,16 @@ decodeArgs f mdls (arg:args) = + "-z" -> decodeArgs f{compress = True} mdls args + "-b64" -> decodeArgs f{base64 = True} mdls args + "-Q" -> decodeArgs f{installPkg = True} mdls args +- "-o" | s : args' <- args +- -> decodeArgs f{output = s} mdls args' +- "-optc" | s : args' <- args +- -> decodeArgs f{cArgs = cArgs f ++ [s]} mdls args' +- "-optl" | s : args' <- args +- -> decodeArgs f{lArgs = lArgs f ++ [s]} mdls args' +- "-optF" | s : args' <- args +- -> decodeArgs f{fArgs = fArgs f ++ [s]} mdls args' +- "-pgmF" | s : args' <- args +- -> decodeArgs f{fPgm = Just s} mdls args' ++ "-o" | not (null args) ++ -> let s : args' = args in decodeArgs f{output = s} mdls args' ++ "-optc" | not (null args) ++ -> let s : args' = args in decodeArgs f{cArgs = cArgs f ++ [s]} mdls args' ++ "-optl" | not (null args) ++ -> let s : args' = args in decodeArgs f{lArgs = lArgs f ++ [s]} mdls args' ++ "-optF" | not (null args) ++ -> let s : args' = args in decodeArgs f{fArgs = fArgs f ++ [s]} mdls args' ++ "-pgmF" | not (null args) ++ -> let s : args' = args in decodeArgs f{fPgm = Just s} mdls args' + "-F" -> decodeArgs f{doF = True} mdls args + '-':'i':[] -> decodeArgs f{paths = []} mdls args + '-':'i':s -> decodeArgs f{paths = paths f ++ [s]} mdls args +@@ -163,7 +163,7 @@ decodeArgs f mdls (arg:args) = + '-':'a':s -> decodeArgs f{pkgPath = pkgPath f ++ [s]} mdls args + '-':'L':s -> decodeArgs f{listPkg = Just s} mdls args + '-':'p':s -> decodeArgs f{preload = preload f ++ [s]} mdls args +- '-':'d':'d':'u':'m':'p':'-':r | Just d <- lookup r dumpFlagTable -> ++ '-':'d':'d':'u':'m':'p':'-':r | isJust (lookup r dumpFlagTable) -> let Just d = lookup r dumpFlagTable in + decodeArgs f{dumpFlags = d : dumpFlags f} mdls args + "--stdin" -> decodeArgs f{useStdin = True} mdls args + '-':_ -> mhsError $ "Unknown flag: " ++ arg ++ "\n" ++ usage +diff --git a/src/MicroHs/TypeCheck.hs b/src/MicroHs/TypeCheck.hs +index db7f3527..b006e8f9 100644 +--- a/src/MicroHs/TypeCheck.hs ++++ b/src/MicroHs/TypeCheck.hs +@@ -824,7 +824,7 @@ tInst :: HasCallStack => Expr -> EType -> T (Expr, EType) + tInst ae (EForall _ vks t) = do + t' <- tInstForall vks t + tInst ae t' +-tInst ae at | Just (ctx, t) <- getImplies at = do ++tInst ae at | isJust (getImplies at) = let Just (ctx, t) = getImplies at in do + --tcTrace $ "tInst: addConstraint: " ++ show ae ++ ", " ++ show d ++ " :: " ++ show ctx + {- + if eqExpr ae eCannotHappen then +@@ -1326,7 +1326,7 @@ expandClass d = return [d] + -- Ignoring initial quantifiers and context, how many arrows does the type have? + countArrows :: EType -> Int + countArrows (EForall _ _ t) = countArrows t +-countArrows t | Just (_, t') <- getImplies t = countArrows t' ++countArrows t | isJust (getImplies t) = let Just (_, t') = getImplies t in countArrows t' + | otherwise = length . fst . getArrows $ t + + simpleEqn :: Expr -> [Eqn] +@@ -1772,7 +1772,7 @@ tInferExpr = tInfer tcExpr + + tCheckExpr :: HasCallStack => + EType -> Expr -> T Expr +-tCheckExpr t e | Just (ctx, t') <- getImplies t = do ++tCheckExpr t e | isJust (getImplies t) = let Just (ctx, t') = getImplies t in do + -- tcTrace $ "tCheckExpr: " ++ show (e, ctx, t') + xt <- expandSyn t + unless (eqEType t xt) undefined +@@ -2125,7 +2125,7 @@ needDsCase ex lbls ae = + vt <- gets valueTable + case stLookupGlbUnqMany lbl vt of + -- check the return type of an unambiguous label +- Just [Entry _ t] | (t':_, _) <- getArrows (dropForallContext t) -> needT t' ++ Just [Entry _ t] | not $ null $ fst $ getArrows (dropForallContext t) -> needT $ head $ fst $ getArrows $ dropForallContext t + _ -> return Nothing + + -- Do a record update using case. +@@ -2184,8 +2184,8 @@ tcExprAp mt ae args = do + EUVar r -> fmap (fromMaybe t) (getUVar r) + _ -> return t + -- tcTrace $ "exExprAp: EVar " ++ showIdent i ++ " :: " ++ showExpr t ++ " = " ++ showExpr t' ++ " mt=" ++ show mt +- case fn of +- EVar ii | ii == mkIdent "Data.Function.$", f:as <- args -> tcExprAp mt f as ++ case (fn, args) of ++ (EVar ii, f:as) | ii == mkIdent "Data.Function.$" -> tcExprAp mt f as + _ -> tcExprApFn mt fn t' args + EQVar f t -> -- already resolved + tcExprApFn mt f t args +@@ -2216,17 +2216,17 @@ tcExprApFn mt fn atfn aargs = do + let -- loop _ats aas ft | trace ("loop: " ++ show (aas, ft)) False = undefined + loop ats [] ft = final (reverse ats) ft + loop ats aas@(a:as) aft = do +- case nextArg aft of +- AReqd (IdKind i k) ft -> useType i k a ft +- AForall _ (IdKind i k:iks) ft | ETypeArg t <- a -> do ++ case (nextArg aft, a) of ++ (AReqd (IdKind i k) ft, _) -> useType i k a ft ++ (AForall _ (IdKind i k:iks) ft, ETypeArg t) -> do + -- traceM ("AForall " ++ show (i, t)) + useType i k t (EForall QExpl iks ft) +- AForall _ iks ft -> do ++ (AForall _ iks ft, _) -> do + ft' <- tInstForall iks ft + loop ats aas ft' +- AConstaint ctx ft -> ++ (AConstaint ctx ft, _) -> + loop (ArgCtx ctx : ats) aas ft +- ARet aft' -> do ++ (ARet aft', _) -> do + (at, rt) <- unArrow loc aft' + --traceM ("ARet " ++ show (at, rt)) + loop (ArgExpr a at : ats) as rt +@@ -2543,7 +2543,7 @@ nextArg :: EType -> Arg + nextArg (EForall _ [] t) = nextArg t + nextArg (EForall QReqd (ik:iks) t) = AReqd ik (EForall QReqd iks t) + nextArg (EForall q iks t) = AForall q iks t +-nextArg t | Just (ctx, t') <- getImplies t = AConstaint ctx t' ++nextArg t | isJust (getImplies t) = let Just (ctx, t') = getImplies t in AConstaint ctx t' + | otherwise = ARet t + + tcExprLam :: HasCallStack => Expected -> SLoc -> [Eqn] -> T Expr +@@ -2559,7 +2559,7 @@ tcEqns' top at eqns = + case at of + EForall QExpl iks t -> withExtTyps iks $ tcEqns' top t eqns + EForall QImpl _ t -> tcEqns' top t eqns +- _ | Just (ctx, t') <- getImplies at -> do ++ _ | isJust (getImplies at) -> let Just (ctx, t') = getImplies at in do + let loc = getSLoc eqns + d <- newADictIdent loc + f <- newIdent loc "fcnD" +@@ -3109,7 +3109,7 @@ skolemise (EForall _ tvs ty) = do -- Rule PRPOLY + (sks1, ty') <- shallowSkolemise tvs ty + (sks2, ty'') <- skolemise ty' + return (sks1 ++ sks2, ty'') +-skolemise t@(EApp _ _) | Just (arg_ty, res_ty) <- getArrow t = do ++skolemise t@(EApp _ _) | isJust (getArrow t) = let Just (arg_ty, res_ty) = getArrow t in do + (sks, res_ty') <- skolemise res_ty + return (sks, arg_ty `tArrow` res_ty') + skolemise (EApp f a) = do +@@ -3178,13 +3178,13 @@ subsCheckRho loc exp1 (EForall _ vs1 t1) (EForall _ vs2 t2) | length vs1 == leng + subsCheckRho loc exp1 sigma1@EForall{} rho2 = do -- Rule SPEC + (exp1', rho1) <- tInst exp1 sigma1 + subsCheckRho loc exp1' rho1 rho2 +-subsCheckRho loc exp1 arho1 rho2 | Just _ <- getImplies arho1 = do ++subsCheckRho loc exp1 arho1 rho2 | isJust (getImplies arho1) = do + (exp1', rho1) <- tInst exp1 arho1 + subsCheckRho loc exp1' rho1 rho2 +-subsCheckRho loc exp1 rho1 rho2 | Just (a2, r2) <- getArrow rho2 = do -- Rule FUN ++subsCheckRho loc exp1 rho1 rho2 | isJust (getArrow rho2) = let Just (a2, r2) = getArrow rho2 in do -- Rule FUN + (a1, r1) <- unArrow loc rho1 + subsCheckFun loc exp1 a1 r1 a2 r2 +-subsCheckRho loc exp1 rho1 rho2 | Just (a1, r1) <- getArrow rho1 = do -- Rule FUN ++subsCheckRho loc exp1 rho1 rho2 | isJust (getArrow rho1) = let Just (a1, r1) = getArrow rho1 in do -- Rule FUN + (a2,r2) <- unArrow loc rho2 + subsCheckFun loc exp1 a1 r1 a2 r2 + subsCheckRho loc exp1 tau1 tau2 = do -- Rule MONO +@@ -3366,10 +3366,12 @@ canonPatSynType at = do + pure $ mkTyp [] emptyCtx [] emptyCtx ty + + splitPatSynType :: EType -> ([IdKind], EConstraint, [IdKind], EConstraint, EType) +-splitPatSynType (EForall _ vks1 t0) +- | Just (ctx1, EForall _ vks2 t1) <- getImplies t0 +- , Just (ctx2, ty) <- getImplies t1 +- = (vks1, ctx1, vks2, ctx2, ty) ++splitPatSynType (EForall _ vks1 t0) | isJust x = fromJust x ++ where ++ x = do ++ (ctx1, EForall _ vks2 t1) <- getImplies t0 ++ (ctx2, ty) <- getImplies t1 ++ Just (vks1, ctx1, vks2, ctx2, ty) + splitPatSynType t = impossibleShow t + + ----- +@@ -3465,7 +3467,7 @@ defaultOneTyVar tv = do + -- traceM $ "defaultOneTyVar: cvs = " ++ show cvs + dvs <- getSuperClasses cvs -- add superclasses + -- traceM $ "defaultOneTyVar: dvs = " ++ show dvs +- let oneCls c | Just ts <- M.lookup c (defaults old) = ++ let oneCls c | isJust (M.lookup c $ defaults old) = let Just ts = M.lookup c (defaults old) in + take 1 $ filter (\ t -> all (\ cc -> soluble cc t) cvs) ts + | otherwise = [] + soluble c t = fst $ flip tcRun old $ do +@@ -3571,7 +3573,7 @@ solvers = + -- Examine each goal, either solve it (possibly producing new goals) or let it remain unsolved. + solveMany :: [Goal] -> [UGoal] -> [(EType, Soln)] -> [Improve] -> T ([UGoal], [Soln], [Improve]) + solveMany [] uns sol imp = return (uns, map snd sol, imp) +-solveMany ((di, ct) : cnss) uns sol imp | Just (_, (dd, _)) <- find (eqEType ct . fst) sol = ++solveMany ((di, ct) : cnss) uns sol imp | isJust (find (eqEType ct . fst) sol) = let Just (_, (dd, _)) = find (eqEType ct . fst) sol in + solveMany cnss uns ((ct, (di, EVar dd)) : sol) imp + -- Need to handle ct of the form C => T, and forall a . T + solveMany (cns@(di, ct) : cnss) uns sol imp = do +@@ -3889,7 +3891,7 @@ solveEq eqs t1 t2 | normTypeEq eqs t1 `eqEType` normTypeEq eqs t2 = Just [] + -- XXX This guaranteed by how it's called, but I'm not sure it always works properly. + addTypeEq :: EType -> EType -> TypeEqTable -> TypeEqTable + addTypeEq t1 t2 aeqs = +- let deref (EVar i) | Just t <- lookup i aeqs = t ++ let deref (EVar i) | isJust (lookup i aeqs) = fromJust $ lookup i aeqs + deref (ESign t _) = t + deref t = t + t1' = deref t1 +@@ -3990,7 +3992,7 @@ standaloneDeriving str narg act = do + -- traceM ("standaloneDeriving 1 " ++ show (_vks, _ctx, cc)) + (cls, ts, tname) <- + case getAppM cc of +- Just (c, ts@(_:_)) | Just (n, _) <- getAppM (last ts) -> return (c, init ts, n) ++ Just (c, ts@(_:_)) | isJust (getAppM $ last ts) -> let Just (n, _) = getAppM (last ts) in return (c, init ts, n) + _ -> tcError (getSLoc act) "malformed standalone deriving" + -- traceM ("standaloneDeriving 2 " ++ show (act, cls, tname)) + dtable <- gets dataTable +diff --git a/src/Text/ParserComb.hs b/src/Text/ParserComb.hs +index 6efd5a3f..8ab72759 100644 +--- a/src/Text/ParserComb.hs ++++ b/src/Text/ParserComb.hs +@@ -127,7 +127,9 @@ satisfy msg f = P $ \ acs -> + satisfyM :: forall tm t a . TokenMachine tm t => String -> (t -> Maybe a) -> Prsr tm t a + satisfyM msg f = P $ \ acs -> + case tmNextToken acs of +- (c, cs) | Just a <- f c -> Success a cs noFail ++ (c, cs) -> case f c of ++ Just a -> Success a cs noFail ++ _ -> Failure (LastFail (tmLeft acs) (firstToken acs) [msg]) + _ -> Failure (LastFail (tmLeft acs) (firstToken acs) [msg]) + + infixl 9 diff --git a/pkgs/development/compilers/microhs/patches/hugs.patch b/pkgs/development/compilers/microhs/patches/hugs.patch new file mode 100644 index 000000000000..2948380da664 --- /dev/null +++ b/pkgs/development/compilers/microhs/patches/hugs.patch @@ -0,0 +1,365 @@ +This patch is based on https://github.com/augustss/MicroHs/pull/429 +If you need to update it, rebase the above PR onto the new version's tag. + +diff --git a/hugs/Data/Semigroup.hs b/hugs/Data/Semigroup.hs +index b7360013..eab8c48d 100644 +--- a/hugs/Data/Semigroup.hs ++++ b/hugs/Data/Semigroup.hs +@@ -18,11 +18,11 @@ class Semigroup a where + | otherwise = f x0 y0 + where + f x y +- | even y == 0 = f (x <> x) (y `quot` 2) ++ | even y = f (x <> x) (y `quot` 2) + | y == 1 = x + | otherwise = g (x <> x) (y `quot` 2) x + g x y z +- | even y == 0 = g (x <> x) (y `quot` 2) z ++ | even y = g (x <> x) (y `quot` 2) z + | y == 1 = x <> z + | otherwise = g (x <> x) (y `quot` 2) (x <> z) + +diff --git a/hugs/Data/String.hs b/hugs/Data/String.hs +new file mode 100644 +index 00000000..1de782d3 +--- /dev/null ++++ b/hugs/Data/String.hs +@@ -0,0 +1,17 @@ ++module Data.String( ++ IsString(..), ++ String, ++ lines, unlines, ++ words, unwords, ++ ) where ++ ++import qualified Data.ByteString.Char8 as BS8 ++ ++class IsString a where ++ fromString :: String -> a ++ ++instance IsString [Char] where ++ fromString s = s ++ ++instance IsString BS8.ByteString where ++ fromString = BS8.pack +diff --git a/hugs/Data/Text.hs b/hugs/Data/Text.hs +index fbd1c731..75f8e829 100644 +--- a/hugs/Data/Text.hs ++++ b/hugs/Data/Text.hs +@@ -8,6 +8,7 @@ module Data.Text( + null, + head, + tail, ++ cons, + uncons, + ) where + import Prelude hiding(head, tail, null) +@@ -64,6 +65,9 @@ head (T t) = Prelude.head t + tail :: Text -> Text + tail (T t) = T (Prelude.tail t) + ++cons :: Char -> Text -> Text ++cons c (T t) = T (c : t) ++ + uncons :: Text -> Maybe (Char, Text) + uncons t | null t = Nothing + | otherwise = Just (head t, tail t) +diff --git a/hugs/MHSPrelude.hs b/hugs/MHSPrelude.hs +index cb6b36f6..cb47e041 100644 +--- a/hugs/MHSPrelude.hs ++++ b/hugs/MHSPrelude.hs +@@ -4,10 +4,11 @@ module MHSPrelude( + module Prelude, + module MHSPrelude, + -- module Control.Monad.Fail, +- module Control.Arrow, ++ -- Exporting these with 'module Control.Arrow' does not work ++ first, second, + module Data.Monoid, + module Data.Semigroup, +- (<$>), Applicative(..), (*>), ++ (<$>), Applicative(..), (*>), (<*), (>=>), (<=<) + ) where + import Hugs.Prelude() + import Prelude hiding(fail) +@@ -16,6 +17,7 @@ import Control.Arrow(first, second) + import Control.Applicative + import Control.Exception(Exception, try) + --import Control.Monad.Fail ++import Data.Int + import Data.List + import Data.Maybe + import Data.Monoid +@@ -55,6 +57,12 @@ spanEnd p xs = (dropWhileEnd p xs, takeWhileEnd p xs) + breakEnd :: (a -> Bool) -> [a] -> ([a], [a]) + breakEnd p = spanEnd (not . p) + ++subsequences :: [a] -> [[a]] ++subsequences xs = [] : sub xs ++ where sub [] = [] ++ sub (x:xs) = [x] : foldr f [] (sub xs) ++ where f ys r = ys : (x : ys) : r ++ + ------- Version -------- + + makeVersion :: [Int] -> Version +@@ -193,6 +201,7 @@ force :: (NFData a) => a -> a + force x = x `deepseq` x + + instance NFData Int ++instance NFData Int64 + instance NFData Word + instance NFData Float + instance NFData Double +@@ -229,3 +238,11 @@ instance NFData MD5CheckSum + + class HasCallStack + instance HasCallStack ++ ++(<=<) :: forall m a b c . Monad m => (b -> m c) -> (a -> m b) -> (a -> m c) ++f <=< g = \ a -> do ++ b <- g a ++ f b ++ ++(>=>) :: forall m a b c . Monad m => (a -> m b) -> (b -> m c) -> (a -> m c) ++(>=>) = flip (<=<) +diff --git a/src/MicroHs/Compile.hs b/src/MicroHs/Compile.hs +index ddec7993..643319aa 100644 +--- a/src/MicroHs/Compile.hs ++++ b/src/MicroHs/Compile.hs +@@ -123,12 +123,17 @@ compile flags nm ach = do + return ((tModuleName cm, concatMap tBindingsOf $ cachedModules ch), syms, ch) + + -- Compile a module for the interactive system +-compileInteractive :: Flags -> EModule -> CM (TModule [LDef], Symbols, TCState) +-compileInteractive flags mdl = do +- ((dmdl, syms, _, _, _), tcstate) <- compileModuleP flags ImpNormal mdl ++compileInteractive :: Flags -> EModule -> Maybe TCState -> CM (TModule [LDef], Symbols, TCState) ++compileInteractive flags mdl mtcstate = do ++ ((dmdl, syms, _, _, _), tcstate') <- compile ++ flags ImpNormal mdl + loadBoots flags + loadDependencies flags +- return (dmdl, syms, tcstate) ++ return (dmdl, syms, tcstate') ++ where ++ compile = case mtcstate of ++ Nothing -> compileModuleP ++ Just tcstate -> compileModuleP' (\flags _ impt aimps mdl -> typeCheck' flags impt (map filterImports aimps) mdl tcstate) + + -- Compile a module with the given name. + -- If the module has already been compiled, return the cached result. +@@ -233,7 +238,12 @@ compileModule flags impt mn pathfn file = do + return (cmdl, syms, tThis + tImp) + + compileModuleP :: Flags -> ImpType -> EModule -> CM ((TModule [LDef], Symbols, [(ImpType, IdentModule)], Time, Time), TCState) +-compileModuleP flags impt mdl@(EModule _ _ defs) = do ++compileModuleP = compileModuleP' typeCheck ++ ++compileModuleP' ++ :: (Flags -> GlobTables -> ImpType -> [(ImportSpec, TModule [LDef])] -> EModule -> (TModule [EDef], GlobTables, Symbols, TCState)) ++ -> Flags -> ImpType -> EModule -> CM ((TModule [LDef], Symbols, [(ImpType, IdentModule)], Time, Time), TCState) ++compileModuleP' tc flags impt mdl@(EModule _ _ defs) = do + -- liftIO $ putStrLn $ showEModule mdl + -- liftIO $ putStrLn $ showEDefs defs + let +@@ -244,7 +254,7 @@ compileModuleP flags impt mdl@(EModule _ _ defs) = do + t3 <- liftIO getTimeMilli + glob <- gets getCacheTables + let +- (tmdl, glob', syms, tcstate) = typeCheck flags glob impt (zip specs impMdls) mdl ++ (tmdl, glob', syms, tcstate) = tc flags glob impt (zip specs impMdls) mdl + modify $ setCacheTables glob' + dumpIf flags Dtypecheck $ + liftIO $ putStrLn $ "type checked:\n" ++ showTModule showEDefs tmdl ++ "-----\n" +@@ -258,9 +268,9 @@ compileModuleP flags impt mdl@(EModule _ _ defs) = do + return ((dmdl, syms, imported, tThis, tImp), tcstate) + + compileToCombinators :: TModule [LDef] -> TModule [LDef] +-compileToCombinators dmdl = do ++compileToCombinators dmdl = + let cmdl = setBindings dmdl [ (i, compileOpt e) | (i, e) <- tBindingsOf dmdl ] +- seq (rnf cmdl) cmdl -- This makes execution slower, but speeds up GC ++ in seq (rnf cmdl) cmdl -- This makes execution slower, but speeds up GC + + -- Add implicit imports: + -- import Prelude +diff --git a/src/MicroHs/Expr.hs b/src/MicroHs/Expr.hs +index 84578594..bd05f1bc 100644 +--- a/src/MicroHs/Expr.hs ++++ b/src/MicroHs/Expr.hs +@@ -57,11 +57,11 @@ module MicroHs.Expr( + dropForallContext, + ) where + import qualified Prelude(); import MHSPrelude hiding ((<>)) ++import Data.Int + import Data.List + import Data.Maybe + import MicroHs.Builtin + import MicroHs.Ident +-import {-# SOURCE #-} MicroHs.TCMonad(TCState) + import Text.PrettyPrint.HughesPJLite + + type IdentModule = Ident +@@ -96,8 +96,6 @@ data EDef + | Pattern LHS EPat (Maybe [Eqn]) + | StandDeriving DerStrategy Int EConstraint + | DfltSign Ident EType -- only in class declarations +- -- Only used by interactive system to load a cached TCState to avoid import processing +- | SetTCState TCState + --DEBUG deriving (Show) + + instance NFData EDef where +@@ -118,7 +116,6 @@ instance NFData EDef where + rnf (Pattern a b c) = rnf a `seq` rnf b `seq` rnf c + rnf (StandDeriving a b c) = rnf a `seq` rnf b `seq` rnf c + rnf (DfltSign a b) = rnf a `seq` rnf b +- rnf (SetTCState a) = seq a () + + data ImpType = ImpNormal | ImpBoot + deriving (Eq) +@@ -900,7 +897,6 @@ ppEDef def = + Pattern lhs@(i,_) p meqns -> text "pattern" <+> ppLHS lhs <+> text "=" <+> ppExpr p <+> maybe empty (ppWhere (text ";") . (:[]) . Fcn i) meqns + StandDeriving _s _narg ct -> text "deriving instance" <+> ppEType ct + DfltSign i t -> text "default" <+> ppIdent i <+> text "::" <+> ppEType t +- SetTCState _ -> text "SetTCState ..." + + ppDerivings :: [Deriving] -> Doc + ppDerivings = sep . map ppDeriving +diff --git a/src/MicroHs/Interactive.hs b/src/MicroHs/Interactive.hs +index ebb33b43..7b70064a 100644 +--- a/src/MicroHs/Interactive.hs ++++ b/src/MicroHs/Interactive.hs +@@ -295,11 +295,11 @@ compile file = do + let mdl@(EModule mn es _) = parseDie pTopModule "" file + defs <- updateTCStateCache mdl + (_, tcstate, _) <- gets isCComp +- let mdl' = EModule mn es (SetTCState tcstate : defs) ++ let mdl' = EModule mn es defs + flgs <- gets isFlags + cash <- gets isCache + -- putStrLnI $ " tryCompile compile " ++ show mdl' +- ((dmdl, _, tcstate'), _) <- liftIO $ runStateIO (compileInteractive flgs mdl') cash ++ ((dmdl, _, tcstate'), _) <- liftIO $ runStateIO (compileInteractive flgs mdl' $ Just tcstate) cash + cmdl <- liftIO $ evaluate $ compileToCombinators dmdl + -- putStrLnI $ " tryCompile dmdl = " ++ (show $ tBindingsOf dmdl) + return (tBindingsOf cmdl, tcstate') +@@ -398,7 +398,7 @@ updateTCStateCache (EModule mn es ds) = do + cash <- gets isCache + -- putStrLnI "*** update tcstate" + let mdl' = addPreludeImport mdl +- ((_, syms, tcstate), ch) <- liftIO $ runStateIO (compileInteractive flgs mdl') cash ++ ((_, syms, tcstate), ch) <- liftIO $ runStateIO (compileInteractive flgs mdl' Nothing) cash + let idmap = translateMap $ concatMap tBindingsOf $ cachedModules ch + -- putStrLnI $ "*** update isFast " ++ show nImps + modify $ \ is -> is{ isCComp = (nImps, tcstate, idmap), isCache = ch, isSymbols = syms } +diff --git a/src/MicroHs/Parse.hs b/src/MicroHs/Parse.hs +index 821718a7..6a68a01a 100644 +--- a/src/MicroHs/Parse.hs ++++ b/src/MicroHs/Parse.hs +@@ -791,7 +791,7 @@ pDo = do + case last ss of + SThen e -> + pure $ EDo q [SRec (init ss), SThen e] +- _ -> fail "mdo" ++ _ -> Control.Monad.Fail.fail "mdo" + else + pure (EDo q ss) + +diff --git a/src/MicroHs/TCMonad.hs-boot b/src/MicroHs/TCMonad.hs-boot +deleted file mode 100644 +index f88ad533..00000000 +--- a/src/MicroHs/TCMonad.hs-boot ++++ /dev/null +@@ -1,2 +0,0 @@ +-module MicroHs.TCMonad where +-data TCState +diff --git a/src/MicroHs/TypeCheck.hs b/src/MicroHs/TypeCheck.hs +index 47f2b461..db7f3527 100644 +--- a/src/MicroHs/TypeCheck.hs ++++ b/src/MicroHs/TypeCheck.hs +@@ -2,7 +2,7 @@ + -- See LICENSE file for full license. + {-# OPTIONS_GHC -Wno-incomplete-uni-patterns -Wno-unused-imports -Wno-unused-do-bind #-} + module MicroHs.TypeCheck( +- typeCheck, ++ typeCheck, typeCheck', filterImports, + TModule(..), showTModule, + GlobTables, emptyGlobTables, mergeGlobTables, + impossible, impossibleShow, +@@ -102,35 +102,34 @@ type Sigma = EType + type Rho = EType + + typeCheck :: Flags -> GlobTables -> ImpType -> [(ImportSpec, TModule a)] -> EModule -> (TModule [EDef], GlobTables, Symbols, TCState) +-typeCheck flags globs impt aimps (EModule mn exps defs) = ++typeCheck flags globs impt aimps mdl@(EModule mn exps defs) = + -- trace (unlines $ map (showTModuleExps . snd) aimps) $ +- let +- imps = map filterImports aimps +- tc = +- case defs of +- SetTCState tcs : _ -> tcs -- hack to set the saved TCState +- _ -> mkTCState mn globs imps +- in case tcRun (tcDefs flags impt defs) tc of +- (tds, tcs) -> +- let +- thisMdl = (mn, mkTModule tds tcs) +- impMdls = [(fromMaybe m mm, tm) | (ImportSpec _ _ m mm _, tm) <- imps] +- allMdls = thisMdl : impMdls +- (texps, vexps) = +- unzip $ map (getTVExps impMap (typeTable tcs) (valueTable tcs) (assocTable tcs)) exps +- where impMap = M.fromListWith (++) [(i, [m]) | (i, m) <- allMdls] +- fexps = map (tFixDefs . snd) allMdls +- sexps = synTable tcs +- dexps = dataTable tcs +- iexps = instTable tcs +- ctbl = classTable tcs +- dflts = M.fromList $ filter ((`elem` ds) . fst) $ M.toList $ defaults tcs +- where ds = [ tyQIdent $ expLookup ti (typeTable tcs) | ExpDefault ti <- exps ] +- in ( tModule mn (nubBy ((==) `on` fst) (concat fexps)) (concat texps) (concat vexps) dflts tds +- , GlobTables { gSynTable = sexps, gDataTable = dexps, gClassTable = ctbl, gInstInfo = iexps } +- , (typeTable tcs, valueTable tcs) +- , tcs +- ) ++ let imps = map filterImports aimps ++ in typeCheck' flags impt imps mdl $ mkTCState mn globs imps ++ ++typeCheck' :: Flags -> ImpType -> [(ImportSpec, TModule a)] -> EModule -> TCState -> (TModule [EDef], GlobTables, Symbols, TCState) ++typeCheck' flags impt imps (EModule mn exps defs) tc = ++ case tcRun (tcDefs flags impt defs) tc of ++ (tds, tcs) -> ++ let ++ thisMdl = (mn, mkTModule tds tcs) ++ impMdls = [(fromMaybe m mm, tm) | (ImportSpec _ _ m mm _, tm) <- imps] ++ allMdls = thisMdl : impMdls ++ (texps, vexps) = ++ unzip $ map (getTVExps impMap (typeTable tcs) (valueTable tcs) (assocTable tcs)) exps ++ where impMap = M.fromListWith (++) [(i, [m]) | (i, m) <- allMdls] ++ fexps = map (tFixDefs . snd) allMdls ++ sexps = synTable tcs ++ dexps = dataTable tcs ++ iexps = instTable tcs ++ ctbl = classTable tcs ++ dflts = M.fromList $ filter ((`elem` ds) . fst) $ M.toList $ defaults tcs ++ where ds = [ tyQIdent $ expLookup ti (typeTable tcs) | ExpDefault ti <- exps ] ++ in ( tModule mn (nubBy ((==) `on` fst) (concat fexps)) (concat texps) (concat vexps) dflts tds ++ , GlobTables { gSynTable = sexps, gDataTable = dexps, gClassTable = ctbl, gInstInfo = iexps } ++ , (typeTable tcs, valueTable tcs) ++ , tcs ++ ) + + -- A hack to force evaluation of errors. + -- This should be redone to all happen in the T monad. +diff --git a/src/Text/ParserComb.hs b/src/Text/ParserComb.hs +index 5b0e8753..6efd5a3f 100644 +--- a/src/Text/ParserComb.hs ++++ b/src/Text/ParserComb.hs +@@ -115,7 +115,7 @@ instance TokenMachine tm t => Alternative (Prsr tm t) where + r -> r + + instance TokenMachine tm t => MonadPlus (Prsr tm t) where +- mzero = fail "mzero" ++ mzero = F.fail "mzero" + mplus = (<|>) + + satisfy :: forall tm t . TokenMachine tm t => String -> (t -> Bool) -> Prsr tm t t diff --git a/pkgs/development/compilers/microhs/patches/link-math.patch b/pkgs/development/compilers/microhs/patches/link-math.patch new file mode 100644 index 000000000000..a9df7bf53cbe --- /dev/null +++ b/pkgs/development/compilers/microhs/patches/link-math.patch @@ -0,0 +1,21 @@ +commit beaea6f66e4f53d617418a4c155b9a14e2c9327e +Author: Alex Tunstall +Date: Fri Mar 20 06:52:08 2026 +0000 + + Add -lm to default link flags + + MicroHs should always link with -lm because its RTS requires it. + +diff --git a/src/MicroHs/Flags.hs b/src/MicroHs/Flags.hs +index e20797c6..df89730e 100644 +--- a/src/MicroHs/Flags.hs ++++ b/src/MicroHs/Flags.hs +@@ -54,7 +54,7 @@ defaultFlags dir = Flags { + doCPP = False, + cppArgs = [], + cArgs = [], +- lArgs = [], ++ lArgs = ["-lm"], + compress = False, + base64 = False, + buildPkg = Nothing, diff --git a/pkgs/development/compilers/microhs/patches/simple-unicode.patch b/pkgs/development/compilers/microhs/patches/simple-unicode.patch new file mode 100644 index 000000000000..ac32c35d9952 --- /dev/null +++ b/pkgs/development/compilers/microhs/patches/simple-unicode.patch @@ -0,0 +1,35 @@ +commit bf89dce66a0833c1ace0a253ef597531435a6798 +Author: Alex Tunstall +Date: Tue Sep 23 04:48:17 2025 +0100 + + Disable Unicode support for Hugs bootstrap + +diff --git a/lib/Data/Char/Unicode.hs b/lib/Data/Char/Unicode.hs +index 4bb46cc2..7180e2d7 100644 +--- a/lib/Data/Char/Unicode.hs ++++ b/lib/Data/Char/Unicode.hs +@@ -207,23 +207,12 @@ decompressRLE = BS.pack . de 0 . BS.unpack + -- XXX Instead of having a totally decompressed (large!) bytestring, + -- we could build a search tree from the RLE encoding. + generalCategory :: Char -> GeneralCategory +-generalCategory c = +- let i = primOrd c +- in if i < 0 || i >= BS.length bytestringGCTable then +- NotAssigned +- else +- toEnum (fromEnum (BS.primBSindex bytestringGCTable i)) +- +-bytestringGCTable :: BS.ByteString +-bytestringGCTable = decompressRLE compressedGCTable ++generalCategory c = error "generalCategory: unsupported" + + -- These tables are generated by unicode/UniParse.hs + -- This is for Unicode 17.0.0 + unicodeVersion :: Version + unicodeVersion = makeVersion [17,0,0] +-compressedGCTable :: ByteString +-compressedGCTable = +- "\159\25\22\130\17\19\130\17\13\14\17\18\17\12\17\17\137\8\17\17\130\18\17\17\153\0\13\17\14\20\11\20\153\1\13\18\14\18\160\25\22\17\131\19\21\17\20\21\4\15\18\26\21\20\21\18\10\10\20\1\17\17\20\10\4\16\130\10\17\150\0\18\134\0\151\1\18\135\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\0\1\0\1\0\130\1\0\0\1\0\1\0\0\1\130\0\1\1\131\0\1\0\0\1\130\0\130\1\0\0\1\0\0\1\0\1\0\1\0\0\1\0\1\1\0\1\0\0\1\130\0\1\0\1\0\0\1\1\4\0\130\1\131\4\0\2\1\0\2\1\0\2\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\1\0\2\1\0\1\130\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\134\1\0\0\1\0\0\1\1\0\1\131\0\1\0\1\0\1\0\1\0\196\1\4\4\153\1\145\3\131\20\139\3\141\20\132\3\134\20\3\20\3\144\20\239\5\0\1\0\1\3\20\0\1\29\29\3\130\1\17\0\131\29\20\20\0\17\130\0\29\0\29\0\0\1\144\0\29\136\0\162\1\0\1\1\130\0\130\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\132\1\0\1\18\0\1\0\0\1\1\178\0\175\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\21\132\5\7\7\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\0\1\0\1\0\1\0\1\0\1\0\1\0\1\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\29\165\0\29\29\3\133\17\168\1\17\12\29\29\21\21\19\29\172\5\12\5\17\5\5\17\5\5\17\5\135\29\154\4\131\29\131\4\17\17\138\29\133\26\130\18\17\17\19\17\17\21\21\138\5\17\26\130\17\159\4\3\137\4\148\5\137\8\131\17\4\4\5\226\4\17\4\134\5\26\21\133\5\3\3\5\5\21\131\5\4\4\137\8\130\4\21\21\4\141\17\29\26\4\5\157\4\154\5\29\29\216\4\138\5\4\141\29\137\8\160\4\136\5\3\3\21\130\17\3\29\29\5\19\19\149\4\131\5\3\136\5\3\130\5\3\132\5\29\29\142\17\29\152\4\130\5\29\29\17\29\138\4\132\29\151\4\20\134\4\26\26\132\29\136\5\168\4\3\151\5\26\159\5\6\181\4\5\6\5\4\130\6\135\5\131\6\5\6\6\4\134\5\137\4\5\5\17\17\137\8\17\3\142\4\5\6\6\29\135\4\29\29\4\4\29\29\149\4\29\134\4\29\4\130\29\131\4\29\29\5\4\130\6\131\5\29\29\6\6\29\29\6\6\5\4\135\29\6\131\29\4\4\29\130\4\5\5\29\29\137\8\4\4\19\19\133\10\21\19\4\17\5\29\29\5\5\6\29\133\4\131\29\4\4\29\29\149\4\29\134\4\29\4\4\29\4\4\29\4\4\29\29\5\29\130\6\5\5\131\29\5\5\29\29\130\5\130\29\5\134\29\131\4\29\4\134\29\137\8\5\5\130\4\5\17\137\29\5\5\6\29\136\4\29\130\4\29\149\4\29\134\4\29\4\4\29\132\4\29\29\5\4\130\6\132\5\29\5\5\6\29\6\6\5\29\29\4\142\29\4\4\5\5\29\29\137\8\17\19\134\29\4\133\5\29\5\6\6\29\135\4\29\29\4\4\29\29\149\4\29\134\4\29\4\4\29\132\4\29\29\5\4\6\5\6\131\5\29\29\6\6\29\29\6\6\5\134\29\5\5\6\131\29\4\4\29\130\4\5\5\29\29\137\8\21\4\133\10\137\29\5\4\29\133\4\130\29\130\4\29\131\4\130\29\4\4\29\4\29\4\4\130\29\4\4\130\29\130\4\130\29\139\4\131\29\6\6\5\6\6\130\29\130\6\29\130\6\5\29\29\4\133\29\6\141\29\137\8\130\10\133\21\19\21\132\29\5\130\6\5\135\4\29\130\4\29\150\4\29\143\4\29\29\5\4\130\5\131\6\29\130\5\29\131\5\134\29\5\5\29\130\4\29\4\4\29\29\4\4\5\5\29\29\137\8\134\29\17\134\10\21\4\5\6\6\17\135\4\29\130\4\29\150\4\29\137\4\29\132\4\29\29\5\4\6\5\132\6\29\5\6\6\29\6\6\5\5\134\29\6\6\132\29\130\4\29\4\4\5\5\29\29\137\8\29\4\4\6\139\29\5\5\6\6\136\4\29\130\4\29\168\4\5\5\4\130\6\131\5\29\130\6\29\130\6\5\4\21\131\29\130\4\6\134\10\130\4\5\5\29\29\137\8\136\10\21\133\4\29\5\6\6\29\145\4\130\29\151\4\29\136\4\29\4\29\29\134\4\130\29\5\131\29\130\6\130\5\29\5\29\135\6\133\29\137\8\29\29\6\6\17\139\29\175\4\5\4\4\134\5\131\29\19\133\4\3\135\5\17\137\8\17\17\164\29\4\4\29\4\29\132\4\29\151\4\29\4\29\137\4\5\4\4\136\5\4\29\29\132\4\29\3\29\134\5\29\137\8\29\29\131\4\159\29\4\130\21\142\17\21\17\130\21\5\5\133\21\137\8\137\10\21\5\21\5\21\5\13\14\13\14\6\6\135\4\29\163\4\131\29\141\5\6\132\5\17\5\5\132\4\138\5\29\163\5\29\135\21\5\133\21\29\21\21\132\17\131\21\17\17\164\29\170\4\6\6\131\5\6\133\5\6\5\5\6\6\5\5\4\137\8\133\17\133\4\6\6\5\5\131\4\130\5\4\130\6\4\4\134\6\130\4\131\5\140\4\5\6\6\5\5\133\6\5\4\6\137\8\130\6\5\21\21\165\0\29\0\132\29\0\29\29\170\1\17\3\130\1\130\200\4\29\131\4\29\29\134\4\29\4\29\131\4\29\29\168\4\29\131\4\29\29\160\4\29\131\4\29\29\134\4\29\4\29\131\4\29\29\142\4\29\184\4\29\131\4\29\29\194\4\29\29\130\5\136\17\147\10\130\29\143\4\137\21\133\29\213\0\29\29\133\1\29\29\12\132\235\4\21\17\144\4\22\153\4\13\14\130\29\202\4\130\17\130\9\135\4\134\29\145\4\130\5\6\136\29\146\4\5\5\6\17\17\136\29\145\4\5\5\139\29\140\4\29\130\4\29\5\5\139\29\179\4\5\5\6\134\5\135\6\5\6\6\138\5\130\17\3\130\17\19\4\5\29\29\137\8\133\29\137\10\133\29\133\17\12\131\17\130\5\26\5\137\8\133\29\162\4\3\180\4\134\29\132\4\5\5\161\4\5\4\132\29\197\4\137\29\158\4\29\130\5\131\6\5\5\130\6\131\29\6\6\5\133\6\130\5\131\29\21\130\29\17\17\137\8\157\4\29\29\132\4\138\29\171\4\131\29\153\4\133\29\137\8\10\130\29\161\21\150\4\5\5\6\6\5\29\29\17\17\180\4\6\5\6\134\5\29\5\6\5\6\6\135\5\133\6\137\5\29\29\5\137\8\133\29\137\8\133\29\134\17\3\133\17\29\29\141\5\7\158\5\29\29\139\5\147\29\131\5\6\174\4\5\6\132\5\6\5\132\6\5\6\6\135\4\29\17\17\137\8\134\17\137\21\136\5\136\21\130\17\5\5\6\157\4\6\131\5\6\6\5\5\6\130\5\4\4\137\8\171\4\5\6\5\5\130\6\5\6\130\5\6\6\135\29\131\17\163\4\135\6\135\5\6\6\5\5\130\29\132\17\137\8\130\29\130\4\137\8\157\4\133\3\17\17\136\1\0\1\132\29\170\0\29\29\130\0\135\17\135\29\130\5\17\140\5\6\134\5\131\4\5\133\4\5\4\4\6\5\5\4\132\29\171\1\190\3\140\1\3\161\1\164\3\191\5\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\136\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\136\1\135\0\133\1\29\29\133\0\29\29\135\1\135\0\135\1\135\0\133\1\29\29\133\0\29\29\135\1\29\0\29\0\29\0\29\0\135\1\135\0\141\1\29\29\135\1\135\2\135\1\135\2\135\1\135\2\132\1\29\1\1\131\0\2\20\1\130\20\130\1\29\1\1\131\0\2\130\20\131\1\29\29\1\1\131\0\29\130\20\135\1\132\0\130\20\29\29\130\1\29\1\1\131\0\2\20\20\29\138\22\132\26\133\12\17\17\15\16\13\15\15\16\13\15\135\17\23\24\132\26\22\136\17\15\16\131\17\11\11\130\17\18\13\14\138\17\18\17\11\137\17\22\132\26\29\137\26\10\3\29\29\133\10\130\18\13\14\3\137\10\130\18\13\14\29\140\3\130\29\161\19\141\29\140\5\131\7\5\130\7\139\5\142\29\21\21\0\131\21\0\21\21\1\130\0\1\1\130\0\1\21\0\21\21\18\132\0\133\21\0\21\0\21\0\21\131\0\21\1\131\0\1\131\4\1\21\21\1\1\0\0\132\18\0\131\1\21\18\21\21\1\21\143\10\162\9\0\1\131\9\10\21\21\131\29\132\18\132\21\18\18\131\21\18\21\21\18\21\21\18\134\21\18\158\21\18\18\21\21\18\21\18\158\21\130\139\18\135\21\13\14\13\14\147\21\18\18\134\21\13\14\208\21\18\157\21\152\18\167\21\133\18\199\21\149\29\138\21\148\29\187\10\205\21\149\10\129\182\21\18\136\21\18\181\21\135\18\238\21\18\129\247\21\13\14\13\14\13\14\13\14\13\14\13\14\13\14\157\10\171\21\132\18\13\14\158\18\13\14\13\14\13\14\13\14\13\14\143\18\129\255\21\129\130\18\13\14\13\14\13\14\13\14\13\14\13\14\13\14\13\14\13\14\13\14\13\14\190\18\13\14\13\14\159\18\13\14\130\129\18\175\21\148\18\21\21\133\18\166\21\29\29\129\137\21\175\0\175\1\0\1\130\0\1\1\0\1\0\1\0\1\131\0\1\0\1\1\0\133\1\3\3\130\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\1\133\21\0\1\0\1\130\5\0\1\132\29\131\17\10\17\17\165\1\29\1\132\29\1\29\29\183\4\134\29\3\17\141\29\5\150\4\136\29\134\4\29\134\4\29\134\4\29\134\4\29\134\4\29\134\4\29\134\4\29\134\4\29\159\5\17\17\15\16\15\16\130\17\15\16\17\15\16\136\17\12\17\17\12\17\15\16\17\17\15\16\13\14\13\14\13\14\13\14\132\17\3\137\17\12\12\131\17\12\17\13\140\17\21\21\130\17\13\14\13\14\13\14\13\14\12\161\29\153\21\29\216\21\139\29\129\213\21\153\29\143\21\22\130\17\21\3\4\9\13\14\13\14\13\14\13\14\13\14\21\21\13\14\13\14\13\14\13\14\12\13\14\14\21\136\9\131\5\6\6\12\132\3\21\21\130\9\3\4\17\21\21\29\213\4\29\29\5\5\20\20\3\3\4\12\217\4\17\130\3\4\132\29\170\4\29\221\4\29\21\21\131\10\137\21\159\4\165\21\136\29\21\143\4\158\21\29\137\10\157\21\135\10\21\142\10\159\21\137\10\166\21\142\10\130\191\21\4\179\189\29\4\191\21\4\129\163\253\29\149\4\3\136\246\4\130\29\182\21\136\29\167\4\133\3\17\17\130\139\4\3\130\17\143\4\137\8\4\4\147\29\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\4\5\130\7\17\137\5\17\3\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\3\3\5\5\197\4\137\9\5\5\133\17\135\29\150\20\136\3\20\20\0\1\0\1\0\1\0\1\0\1\0\1\0\130\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\3\135\1\0\1\0\1\0\0\1\0\1\0\1\0\1\0\1\3\20\20\0\1\0\1\4\0\1\0\130\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\132\0\1\132\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\131\0\1\0\1\0\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\147\29\131\3\0\1\4\3\3\1\134\4\5\130\4\5\131\4\5\150\4\6\6\5\5\6\131\21\5\130\29\133\10\21\21\19\21\133\29\179\4\131\17\135\29\6\6\177\4\143\6\5\5\135\29\17\17\137\8\133\29\145\5\133\4\130\17\4\17\4\4\5\137\8\155\4\135\5\17\17\150\4\138\5\6\6\138\29\17\156\4\130\29\130\5\6\174\4\5\6\6\131\5\6\6\5\5\130\6\140\17\29\3\137\8\131\29\17\17\132\4\5\3\136\4\137\8\132\4\29\168\4\133\5\6\6\5\5\6\6\5\5\136\29\130\4\5\135\4\5\6\29\29\137\8\29\29\131\17\143\4\3\133\4\130\21\4\6\5\6\177\4\5\4\130\5\4\4\5\5\132\4\5\5\4\5\4\151\29\4\4\3\17\17\138\4\6\5\5\6\6\17\17\4\3\3\6\5\137\29\133\4\29\29\133\4\29\29\133\4\136\29\134\4\29\134\4\29\170\1\20\131\3\136\1\3\20\20\131\29\207\1\162\4\6\6\5\6\6\5\6\6\17\6\5\29\29\137\8\133\29\4\215\161\29\4\139\29\150\4\131\29\176\4\131\29\27\134\253\29\27\27\253\29\27\27\135\253\29\27\28\177\253\29\28\130\237\4\29\29\233\4\165\29\134\1\139\29\132\1\132\29\4\5\137\4\18\140\4\29\132\4\29\4\29\4\4\29\4\4\29\235\4\144\20\143\21\130\234\4\14\13\143\21\191\4\21\21\181\4\135\21\159\29\139\4\19\130\21\143\5\134\17\13\14\17\133\29\143\5\17\12\12\11\11\13\14\13\14\13\14\13\14\13\14\13\14\13\14\13\14\17\17\13\14\131\17\130\11\130\17\29\131\17\12\13\14\13\14\13\14\130\17\18\12\130\18\29\17\19\17\17\131\29\132\4\29\129\134\4\29\29\26\29\130\17\19\130\17\13\14\17\18\17\12\17\17\137\8\17\17\130\18\17\17\153\0\13\17\14\20\11\20\153\1\13\18\14\18\13\14\17\13\14\17\17\137\4\3\172\4\3\3\158\4\130\29\133\4\29\29\133\4\29\29\133\4\29\29\130\4\130\29\19\19\18\20\21\19\19\29\21\131\18\21\21\137\29\130\26\21\21\29\29\139\4\29\153\4\29\146\4\29\4\4\29\142\4\29\29\141\4\161\29\250\4\132\29\130\17\131\29\172\10\130\29\136\21\180\9\131\10\144\21\10\10\130\21\29\140\21\130\29\21\174\29\172\21\5\129\129\29\156\4\130\29\176\4\142\29\5\154\10\131\29\159\4\131\10\136\29\147\4\9\135\4\9\132\29\165\4\132\5\132\29\157\4\29\17\163\4\131\29\135\4\17\132\9\169\29\167\0\167\1\205\4\29\29\137\8\133\29\163\0\131\29\163\1\131\29\167\4\135\29\179\4\138\29\17\138\0\29\142\0\29\134\0\29\0\0\29\138\1\29\142\1\29\134\1\29\1\1\130\29\179\4\139\29\130\182\4\136\29\149\4\137\29\135\4\151\29\133\3\29\169\3\29\136\3\196\29\133\4\29\29\4\29\171\4\29\4\4\130\29\4\29\29\150\4\29\17\135\10\150\4\21\21\134\10\158\4\135\29\136\10\175\29\146\4\29\4\4\132\29\132\10\149\4\133\10\130\29\17\153\4\132\29\17\153\4\165\29\183\4\131\29\10\10\4\4\143\10\29\29\173\10\4\130\5\29\5\5\132\29\131\5\131\4\29\130\4\29\156\4\29\29\130\5\131\29\5\136\10\134\29\136\17\134\29\156\4\10\10\17\156\4\130\10\159\29\135\4\21\155\4\5\5\131\29\132\10\134\17\136\29\181\4\130\29\134\17\149\4\29\29\135\10\146\4\132\29\135\10\145\4\134\29\131\17\139\29\134\10\207\29\200\4\182\29\178\0\140\29\178\1\134\29\133\10\163\4\131\5\135\29\137\8\133\29\137\8\131\4\3\4\149\0\130\29\132\5\12\3\149\1\135\29\18\18\129\207\29\158\10\29\169\4\29\5\5\12\29\29\4\4\143\29\130\4\3\4\4\135\29\17\135\21\160\29\133\5\156\4\137\10\4\135\29\149\4\138\5\131\10\132\17\149\29\145\4\131\5\131\17\165\29\148\4\134\10\147\29\150\4\136\29\6\5\6\180\4\142\5\134\17\131\29\147\10\137\8\5\4\4\5\5\4\136\29\130\5\6\172\4\130\6\131\5\6\6\5\5\17\17\26\131\17\5\137\29\26\29\29\152\4\134\29\137\8\133\29\130\5\163\4\132\5\6\135\5\29\137\8\131\17\4\6\6\4\135\29\162\4\5\17\17\4\136\29\5\5\6\175\4\130\6\136\5\6\6\131\4\131\17\131\5\17\6\5\137\8\4\17\4\130\17\29\147\10\138\29\145\4\29\152\4\130\6\130\5\6\6\5\6\5\5\133\17\5\4\4\5\189\29\134\4\29\4\29\131\4\29\142\4\29\137\4\17\133\29\174\4\5\130\6\135\5\132\29\137\8\133\29\5\5\6\6\29\135\4\29\29\4\4\29\29\149\4\29\134\4\29\4\4\29\132\4\29\5\5\4\6\6\5\131\6\29\29\6\6\29\29\130\6\29\29\4\133\29\6\132\29\132\4\6\6\29\29\134\5\130\29\132\5\138\29\137\4\29\4\29\29\4\29\165\4\29\4\130\6\133\5\29\6\29\29\6\29\131\6\29\6\6\5\6\5\4\5\4\17\17\29\17\17\135\29\5\5\156\29\180\4\130\6\135\5\6\6\130\5\6\5\131\4\132\17\137\8\17\17\29\17\5\130\4\157\29\175\4\130\6\133\5\6\5\131\6\5\5\6\5\5\4\4\17\4\135\29\137\8\129\165\29\174\4\130\6\131\5\29\29\131\6\5\5\6\5\5\150\17\131\4\5\5\161\29\175\4\130\6\135\5\6\6\5\6\5\5\130\17\4\138\29\137\8\133\29\140\17\146\29\170\4\5\6\5\6\6\133\5\6\5\4\17\133\29\137\8\133\29\147\8\155\29\154\4\29\29\5\6\5\6\6\131\5\6\132\5\131\29\137\8\10\10\130\17\21\134\4\129\184\29\171\4\130\6\136\5\6\5\5\17\227\29\159\0\159\1\137\8\136\10\139\29\135\4\29\29\4\29\29\135\4\29\4\4\29\151\4\133\6\29\6\6\29\29\5\5\6\5\4\6\4\6\5\130\17\136\29\137\8\197\29\135\4\29\29\166\4\130\6\131\5\29\29\5\5\131\6\5\4\17\4\6\154\29\4\137\5\167\4\133\5\6\4\131\5\135\17\5\135\29\4\133\5\6\6\130\5\173\4\140\5\6\5\5\130\17\4\132\17\140\29\200\4\134\29\137\17\213\29\5\6\130\5\6\5\6\215\29\160\4\17\141\29\137\8\133\29\136\4\29\164\4\6\134\5\29\133\5\6\5\4\132\17\137\29\137\8\146\10\130\29\17\17\157\4\29\29\149\5\29\6\134\5\6\5\5\6\5\5\200\29\134\4\29\4\4\29\165\4\133\5\130\29\5\29\5\5\29\134\5\4\5\135\29\137\8\133\29\133\4\29\4\4\29\159\4\132\6\29\5\5\29\6\6\5\6\5\4\134\29\137\8\133\29\168\4\3\4\4\131\29\137\8\129\245\29\146\4\5\5\6\6\17\17\134\29\5\5\4\6\140\4\29\161\4\6\6\132\5\130\29\6\6\5\6\5\140\17\137\8\5\212\29\4\142\29\148\10\135\21\131\19\144\21\140\29\17\135\153\4\229\29\238\9\29\132\17\138\29\129\195\4\148\203\29\224\4\17\17\140\29\136\175\4\143\26\5\133\4\142\5\137\29\159\154\4\132\29\132\198\4\181\184\29\157\4\139\5\130\6\130\5\137\8\141\197\29\132\184\4\134\29\158\4\29\137\8\131\29\17\17\206\4\29\137\8\133\29\157\4\29\29\132\5\17\137\29\175\4\134\5\132\17\131\21\131\3\17\21\137\29\137\8\29\134\10\29\148\4\132\29\146\4\131\175\29\130\3\167\4\3\3\130\17\137\8\129\197\29\159\0\159\1\150\10\131\17\132\29\152\0\29\29\152\1\171\29\202\4\131\29\5\4\182\6\134\29\131\5\140\3\191\29\3\3\17\3\5\138\29\6\6\3\3\130\9\136\29\4\175\253\29\137\214\4\168\29\4\4\156\29\4\224\29\242\4\195\252\29\131\3\29\134\3\29\3\3\29\130\162\4\142\29\4\156\29\130\4\29\29\4\141\29\131\4\135\29\131\139\4\146\131\29\234\4\132\29\140\4\130\29\136\4\134\29\137\4\29\29\21\5\5\17\131\26\158\219\29\129\239\21\137\8\130\21\130\29\131\179\21\133\29\150\21\142\29\143\21\18\142\29\173\5\29\29\150\5\136\29\243\21\187\29\129\245\21\137\29\166\21\29\29\187\21\6\6\130\5\130\21\133\6\135\26\135\5\21\21\134\5\157\21\131\5\188\21\148\29\193\21\130\5\21\249\29\147\10\139\29\147\10\139\29\214\21\136\29\152\10\129\134\29\153\0\153\1\153\0\134\1\29\145\1\153\0\153\1\0\29\0\0\29\29\0\29\29\0\0\29\29\131\0\29\135\0\131\1\29\1\29\134\1\29\138\1\153\0\153\1\0\0\29\131\0\29\29\135\0\29\134\0\29\153\1\0\0\29\131\0\29\132\0\29\0\130\29\134\0\29\153\1\153\0\153\1\153\0\153\1\153\0\153\1\153\0\153\1\153\0\153\1\153\0\155\1\29\29\152\0\18\152\1\18\133\1\152\0\18\152\1\18\133\1\152\0\18\152\1\18\133\1\152\0\18\152\1\18\133\1\152\0\18\152\1\18\133\1\0\1\29\29\177\8\131\255\21\182\5\131\21\177\5\135\21\5\141\21\5\21\21\132\17\142\29\132\5\29\142\5\136\207\29\137\1\4\147\1\133\29\133\1\129\212\29\134\5\29\144\5\29\29\134\5\29\5\5\29\132\5\132\29\189\3\160\29\5\239\29\172\4\130\29\134\5\134\3\29\29\137\8\131\29\4\21\130\191\29\157\4\5\144\29\171\4\131\5\137\8\132\29\19\131\207\29\154\4\3\131\5\137\8\129\213\29\157\4\5\5\4\137\8\131\29\17\129\191\29\158\4\29\130\4\5\4\4\5\134\4\5\5\132\4\5\135\29\4\3\129\223\29\134\4\29\131\4\29\4\4\29\142\4\29\129\196\4\29\29\136\10\134\5\168\29\161\0\161\1\134\5\3\131\29\137\8\131\29\17\17\134\144\29\186\10\21\130\10\19\131\10\203\29\172\10\21\142\10\129\193\29\131\4\29\154\4\29\4\4\29\4\29\29\4\29\137\4\29\131\4\29\4\29\4\133\29\4\131\29\4\29\4\29\4\29\130\4\29\4\4\29\4\29\29\4\29\4\29\4\29\4\29\4\29\4\4\29\4\29\29\131\4\29\134\4\29\131\4\29\131\4\29\4\29\137\4\29\144\4\132\29\130\4\29\132\4\29\144\4\179\29\18\18\130\141\29\171\21\131\29\227\21\139\29\142\21\29\29\142\21\29\142\21\29\164\21\137\29\140\10\129\160\21\183\29\156\21\140\29\171\21\131\29\136\21\134\29\21\21\141\29\133\21\129\153\29\129\250\21\132\20\133\216\21\130\29\144\21\130\29\140\21\130\29\129\217\21\133\29\139\21\131\29\21\142\29\139\21\131\29\183\21\135\29\137\21\133\29\167\21\135\29\157\21\29\29\139\21\131\29\21\21\141\29\136\18\166\29\130\215\21\135\29\141\21\29\29\140\21\130\29\138\21\130\29\184\21\29\21\131\29\143\21\29\29\139\21\131\29\137\21\134\29\129\146\21\29\219\21\137\8\21\136\132\29\4\130\205\221\29\4\159\29\4\160\189\29\4\4\129\219\29\4\29\29\4\173\139\29\4\29\29\4\186\174\29\4\142\29\4\132\235\29\4\147\161\29\132\157\4\139\225\29\4\166\200\29\4\132\29\4\160\221\29\4\4\161\199\29\4\171\151\134\29\26\157\29\223\26\255\29\129\239\5\131\252\143\29\28\131\255\251\29\28\29\29\28\131\255\251\29\28" + + tcTable :: [(Int, Int, Int)] + tcTable = diff --git a/pkgs/development/compilers/microhs/stage1.nix b/pkgs/development/compilers/microhs/stage1.nix new file mode 100644 index 000000000000..625f1e05ac44 --- /dev/null +++ b/pkgs/development/compilers/microhs/stage1.nix @@ -0,0 +1,36 @@ +{ + lib, + args, + microhs-boot, + stdenv, +}: + +stdenv.mkDerivation ( + finalAttrs: + let + args' = args finalAttrs; + in + args' + // { + pname = "microhs-stage1"; + patches = + (args'.patches or [ ]) + ++ lib.optionals microhs-boot.usesHugs [ + patches/simple-unicode.patch + ]; + + makeFlags = [ "PREFIX=${placeholder "out"}" ]; + installTargets = [ + "targets.conf" + "oldinstall" + ]; + + buildPhase = '' + runHook preBuild + mkdir -p bin + printf 'Building bin/mhs using ${microhs-boot}/bin/mhs\n' + ${microhs-boot}/bin/mhs -l -imhs -isrc -ipaths MicroHs.Main -o bin/mhs + runHook postBuild + ''; + } +) diff --git a/pkgs/development/compilers/microhs/stage2.nix b/pkgs/development/compilers/microhs/stage2.nix new file mode 100644 index 000000000000..fa8b9d3640f3 --- /dev/null +++ b/pkgs/development/compilers/microhs/stage2.nix @@ -0,0 +1,61 @@ +{ + args, + cpphs, + microcabal-stage1, + microhs-stage1, + stdenv, + callPackage, +}: + +stdenv.mkDerivation ( + finalAttrs: + let + args' = args finalAttrs; + haskellCompilerName = "mhs-${args'.version}"; + in + args' + // { + pname = "microhs"; + + nativeBuildInputs = [ + microcabal-stage1 + microhs-stage1 + ]; + + env = { + CABALDIR = "${placeholder "out"}/lib/mcabal"; + }; + + dontBuild = true; + + installPhase = '' + runHook preInstall + + pushd lib + mcabal -v install + popd + mcabal -v install + + mkdir -p $out/bin + ln -s ../lib/mcabal/bin/mhs $out/bin/mhs + + runHook postInstall + ''; + + passthru = { + inherit + haskellCompilerName + cpphs + microcabal-stage1 + microhs-stage1 + ; + targetPrefix = ""; + isMhs = true; + usesHugs = false; + + tests = { + hello-world = callPackage ./test-hello-world.nix { microhs = finalAttrs.finalPackage; }; + }; + }; + } +) diff --git a/pkgs/by-name/mi/microhs/test-hello-world.nix b/pkgs/development/compilers/microhs/test-hello-world.nix similarity index 100% rename from pkgs/by-name/mi/microhs/test-hello-world.nix rename to pkgs/development/compilers/microhs/test-hello-world.nix diff --git a/pkgs/development/compilers/microhs/wrapper.nix b/pkgs/development/compilers/microhs/wrapper.nix new file mode 100644 index 000000000000..50b496bb7b41 --- /dev/null +++ b/pkgs/development/compilers/microhs/wrapper.nix @@ -0,0 +1,52 @@ +{ + lib, + runCommand, + runtimeShell, + writeShellScript, +}: + +{ + microhs, + packages, +}: + +let + packages' = [ microhs ] ++ lib.filter (p: p != null) packages; + extraFlags = lib.concatMapStringsSep " " ( + p: "-a${p}/lib/mcabal/${microhs.haskellCompilerName}" + ) packages'; + + wrapper = writeShellScript "mhs-wrapper" '' + args=("$@") + noExtra=0 + for ((i=0; i<"''${#args[@]}"; ++i)); do + case "''${args[i]}" in + --version | --numeric-version) + noExtra=1 + ;; + *) + ;; + esac + done + if test "$noExtra" -eq 0; then + for arg in ${extraFlags}; do + args[i++]="$arg" + done + fi + if (( "''${NIX_DEBUG:-0}" >= 1 )); then + printf 'mhs-wrapper: mhs %s\n' "''${args[*]}" >&2 + fi + exec ${microhs}/bin/mhs "''${args[@]}" + ''; + +in +runCommand "${microhs.name}-wrapped" + { + inherit (microhs) passthru; + } + '' + mkdir -p $out/bin + cp -rs ${microhs}/bin/* $out/bin/ + rm $out/bin/mhs 2>/dev/null || true + cp ${wrapper} $out/bin/mhs + '' diff --git a/pkgs/development/haskell-modules/configuration-microhs.nix b/pkgs/development/haskell-modules/configuration-microhs.nix new file mode 100644 index 000000000000..bdf91c6423ed --- /dev/null +++ b/pkgs/development/haskell-modules/configuration-microhs.nix @@ -0,0 +1,78 @@ +{ pkgs, haskellLib }: + +with haskellLib; + +self: super: { + # Disable MicroHs core libraries + base = null; + bytestring = null; + deepseq = null; + directory = null; + process = null; + text = null; + MicroHs = null; + + # External MicroHs core libraries + ghc-compat = markUnbroken super.ghc-compat; + + # Bootstrap MicroCabal + MicroCabal = self.mkDerivation { + pname = "MicroCabal"; + version = self.ghc.microcabal-stage1.version; + src = self.ghc.microcabal-stage1.src; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = with self; [ base ]; + inherit (self.ghc.microcabal-stage1.meta) + description + homepage + license + mainProgram + maintainers + ; + }; + + # hackage-packages does not include GHC core libraries + binary = self.binary_0_8_9_3; + Cabal = self.Cabal_3_16_1_0; + Cabal-syntax = self.Cabal-syntax_3_16_1_0; + containers = self.containers_0_8; + exceptions = self.exceptions_0_10_12; + filepath = self.filepath_1_5_5_0; + ghc-bignum = null; + ghc-boot = null; + ghc-boot-th = null; + ghc-compact = null; + ghc-heap = null; + ghc-internal = null; + ghc-platform = null; + ghc-prim = null; + ghci = null; + haskeline = self.haskeline_0_8_4_1; + hpc = self.hpc_0_7_0_2; + integer-gmp = self.integer-gmp_1_1; + libiserv = null; + mtl = self.mtl_2_3_2; + os-string = self.os-string_2_0_10; + parsec = self.parsec_3_1_18_0; + pretty = self.pretty_1_1_3_6; + rts = null; + semaphore-compat = null; + stm = null; + system-cxx-std-lib = null; + template-haskell = null; + terminfo = self.terminfo_0_4_1_7; + time = self.time_1_15; + transformers = self.transformers_0_6_3_0; + unix = self.unix_2_8_8_0; + xhtml = self.xhtml_3000_4_0_0; + + # MicroHs replacements for widely used libraries + array = self.array-mhs; + array-mhs = markUnbroken super.array-mhs; + random = self.random-mhs; + random-mhs = markUnbroken super.random-mhs; + + # Depends on time when not using GHC + splitmix = addBuildDepends [ self.time ] super.splitmix; +} diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 70998a96e822..f413d9b198a3 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -48,50 +48,64 @@ let inherit (lib) fix' extends makeOverridable; inherit (haskellLib) overrideCabal; - mkDerivationImpl = pkgs.callPackage ./generic-builder.nix { - inherit stdenv haskellLib; - nodejs = buildPackages.nodejs-slim; - inherit (self) - buildHaskellPackages - ghc - ghcWithHoogle - ghcWithPackages - ; - iserv-proxy = { - build = buildHaskellPackages.iserv-proxy; - host = self.iserv-proxy; - }; - inherit (self.buildHaskellPackages) jailbreak-cabal; - hscolour = overrideCabal (drv: { - isLibrary = false; - doHaddock = false; - hyperlinkSource = false; # Avoid depending on hscolour for this build. - postFixup = "rm -rf $out/lib $out/share $out/nix-support"; - }) self.buildHaskellPackages.hscolour; - cpphs = - overrideCabal - (drv: { - isLibrary = false; - postFixup = "rm -rf $out/lib $out/share $out/nix-support"; - }) - ( - self.cpphs.overrideScope ( - self: super: { - mkDerivation = - drv: - super.mkDerivation ( - drv - // { - enableSharedExecutables = false; - enableSharedLibraries = false; - doHaddock = false; - useCpphs = false; - } - ); - } - ) - ); - }; + builder = if !(ghc.isMhs or false) then ./generic-builder.nix else ./microhs-builder.nix; + + mkDerivationImpl = pkgs.callPackage builder ( + { + inherit stdenv; + inherit (self) + buildHaskellPackages + ghc + ; + inherit (self.buildHaskellPackages) jailbreak-cabal; + } + // lib.optionalAttrs (!(ghc.isMhs or false)) { + inherit haskellLib; + inherit (self) + ghcWithHoogle + ghcWithPackages + ; + nodejs = buildPackages.nodejs-slim; + iserv-proxy = { + build = buildHaskellPackages.iserv-proxy; + host = self.iserv-proxy; + }; + hscolour = overrideCabal (drv: { + isLibrary = false; + doHaddock = false; + hyperlinkSource = false; # Avoid depending on hscolour for this build. + postFixup = "rm -rf $out/lib $out/share $out/nix-support"; + }) self.buildHaskellPackages.hscolour; + cpphs = + overrideCabal + (drv: { + isLibrary = false; + postFixup = "rm -rf $out/lib $out/share $out/nix-support"; + }) + ( + self.cpphs.overrideScope ( + self: super: { + mkDerivation = + drv: + super.mkDerivation ( + drv + // { + enableSharedExecutables = false; + enableSharedLibraries = false; + doHaddock = false; + useCpphs = false; + } + ); + } + ) + ); + } + // lib.optionalAttrs (ghc.isMhs or false) { + inherit (self) wrapMhs ghc-compat; + MicroCabal = self.ghc.microcabal-stage1; + cpphs = self.ghc.cpphs; + } + ); mkDerivation = makeOverridable mkDerivationImpl; @@ -663,6 +677,8 @@ package-set { inherit pkgs lib callPackage; } self withHoogle = self.ghcWithHoogle; }; + wrapMhs = pkgs.callPackage ../compilers/microhs/wrapper.nix { }; + /* Run `cabal sdist` on a source. diff --git a/pkgs/development/haskell-modules/microhs-builder.nix b/pkgs/development/haskell-modules/microhs-builder.nix new file mode 100644 index 000000000000..1a4363d8a372 --- /dev/null +++ b/pkgs/development/haskell-modules/microhs-builder.nix @@ -0,0 +1,420 @@ +{ + buildHaskellPackages, + buildPackages, + fetchurl, + ghc, + jailbreak-cabal, + lib, + MicroCabal, + cpphs, + ghc-compat, + pkg-config, + runCommandCC, + stdenv, + wrapMhs, +}: + +let + # make-package-set always names the compiler ghc + compiler = ghc; + + isCross = stdenv.buildPlatform != stdenv.hostPlatform; + +in +{ + pname, + version, + revision ? null, + sha256 ? null, + src ? fetchurl { + url = "mirror://hackage/${pname}-${version}.tar.gz"; + inherit sha256; + }, + # Extra environment variables to set during the build. + # See: `../../../doc/languages-frameworks/haskell.section.md` + env ? { }, + buildDepends ? [ ], + setupHaskellDepends ? [ ], + libraryHaskellDepends ? [ ], + executableHaskellDepends ? [ ], + buildTools ? [ ], + libraryToolDepends ? [ ], + executableToolDepends ? [ ], + testToolDepends ? [ ], + benchmarkToolDepends ? [ ], + configureFlags ? [ ], + description ? null, + doCheck ? !isCross, + doBenchmark ? false, + editedCabalFile ? null, + extraLibraries ? [ ], + librarySystemDepends ? [ ], + executableSystemDepends ? [ ], + # On macOS, statically linking against system frameworks is not supported; + # see https://developer.apple.com/library/content/qa/qa1118/_index.html + # They must be propagated to the environment of any executable linking with the library + libraryFrameworkDepends ? [ ], + executableFrameworkDepends ? [ ], + homepage ? "https://hackage.haskell.org/package/${pname}", + platforms ? with lib.platforms; all, # GHC can cross-compile + badPlatforms ? lib.platforms.none, + hydraPlatforms ? null, + isExecutable ? false, + isLibrary ? !isExecutable, + jailbreak ? false, + license, + maintainers ? null, + teams ? null, + changelog ? null, + mainProgram ? null, + passthru ? { }, + pkg-configDepends ? [ ], + libraryPkgconfigDepends ? [ ], + executablePkgconfigDepends ? [ ], + testPkgconfigDepends ? [ ], + benchmarkPkgconfigDepends ? [ ], + testDepends ? [ ], + testHaskellDepends ? [ ], + testSystemDepends ? [ ], + testFrameworkDepends ? [ ], + benchmarkDepends ? [ ], + benchmarkHaskellDepends ? [ ], + benchmarkSystemDepends ? [ ], + benchmarkFrameworkDepends ? [ ], + broken ? false, + preCompileBuildDriver ? null, + postCompileBuildDriver ? null, + preUnpack ? null, + postUnpack ? null, + patches ? null, + patchPhase ? null, + prePatch ? "", + postPatch ? "", + preConfigure ? null, + postConfigure ? null, + preBuild ? null, + postBuild ? null, + preHaddock ? null, + postHaddock ? null, + installPhase ? null, + preInstall ? null, + postInstall ? null, + checkPhase ? null, + preCheck ? null, + postCheck ? null, + preFixup ? null, + postFixup ? null, + shellHook ? "", + ... +}@args: + +assert editedCabalFile != null -> revision != null; + +let + allPkgconfigDepends = + pkg-configDepends + ++ libraryPkgconfigDepends + ++ executablePkgconfigDepends + ++ lib.optionals doCheck testPkgconfigDepends + ++ lib.optionals doBenchmark benchmarkPkgconfigDepends; + + # MicroCabal adds a dependency on ghc-compat unless the package name is one of the following + isCorePkg = pname == "base" || pname == "ghc-compat" || pname == "MicroHs" || pname == "MicroCabal"; + buildDepends' = buildDepends ++ lib.optional (!isCorePkg) ghc-compat; + + depsBuildBuild = lib.optionals (!stdenv.hasCC) [ buildPackages.stdenv.cc ]; + collectedToolDepends = + buildTools + ++ libraryToolDepends + ++ executableToolDepends + ++ lib.optionals doCheck testToolDepends + ++ lib.optionals doBenchmark benchmarkToolDepends; + nativeBuildInputs = [ + MicroCabal + cpphs + compilerWithPkgs + buildPackages.removeReferencesTo + ]; + propagatedBuildInputs = + buildDepends' ++ libraryHaskellDepends ++ executableHaskellDepends ++ libraryFrameworkDepends; + otherBuildInputsHaskell = + lib.optionals doCheck (testDepends ++ testHaskellDepends) + ++ lib.optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends); + otherBuildInputsSystem = + extraLibraries + ++ librarySystemDepends + ++ executableSystemDepends + ++ executableFrameworkDepends + ++ allPkgconfigDepends + ++ lib.optionals doCheck (testSystemDepends ++ testFrameworkDepends) + ++ lib.optionals doBenchmark (benchmarkSystemDepends ++ benchmarkFrameworkDepends); + otherBuildInputs = otherBuildInputsHaskell ++ otherBuildInputsSystem; + + newCabalFileUrl = "mirror://hackage/${pname}-${version}/revision/${revision}.cabal"; + newCabalFile = fetchurl { + url = newCabalFileUrl; + sha256 = editedCabalFile; + name = "${pname}-${version}-r${revision}.cabal"; + }; + + hsLibBuildInputs = lib.filter (p: p ? isHaskellLibrary && p.isHaskellLibrary) propagatedBuildInputs; + compilerWithPkgs = wrapMhs { + microhs = compiler; + packages = hsLibBuildInputs; + }; + + compilerCommand' = "mhs"; + compilerCommand = "${compiler.targetPrefix}${compilerCommand'}"; + + compilerLibdir = "lib/mcabal/${compiler.haskellCompilerName}"; + + env' = { + CABALDIR = "${placeholder "out"}/lib/mcabal"; + } + // env; + +in +stdenv.mkDerivation { + inherit pname version; + + pos = builtins.unsafeGetAttrPos "pname" args; + + prePhases = [ "setupCompilerEnvironmentPhase" ]; + preConfigurePhases = [ "compileBuildDriverPhase" ]; + preInstallPhases = [ "haddockPhase" ]; + + inherit src patches; + + inherit depsBuildBuild nativeBuildInputs; + buildInputs = lib.optionals (!isLibrary) propagatedBuildInputs; + propagatedBuildInputs = lib.optionals isLibrary propagatedBuildInputs; + + env = env'; + + prePatch = + lib.optionalString (editedCabalFile != null) '' + echo "Replace Cabal file with edited version from ${newCabalFileUrl}." + cp ${newCabalFile} ${pname}.cabal + '' + + prePatch; + + postPatch = + lib.optionalString jailbreak '' + echo "Run jailbreak-cabal to lift version restrictions on build inputs." + ${jailbreak-cabal}/bin/jailbreak-cabal ${pname}.cabal + '' + + postPatch; + + setupCompilerEnvironmentPhase = '' + runHook preSetupCompilerEnvironment + + echo "Building with ${compilerWithPkgs}" + mkdir -p "$CABALDIR/${compiler.haskellCompilerName}/packages" + ${lib.concatMapStrings (p: '' + ln -s ${p}/${compilerLibdir}/packages/${p.name}.pkg $CABALDIR/${compiler.haskellCompilerName}/packages/${p.name}.pkg + '') (lib.closePropagation hsLibBuildInputs)} + + runHook postSetupCompilerEnvironment + ''; + + compileBuildDriverPhase = '' + runHook preCompileBuildDriver + + runHook postCompileBuildDriver + ''; + + buildPhase = '' + runHook preBuild + + echo "Skipping buildPhase because MicroCabal always builds on install" + + runHook postBuild + ''; + + inherit doCheck; + + checkPhase = '' + runHook preCheck + + echo "Skipping checkPhase because MicroCabal doesn't support test suites" + + runHook postCheck + ''; + + haddockPhase = '' + runHook preHaddock + + echo "Skipping haddockPhase because MicroCabal doesn't support Haddock" + + runHook postHaddock + ''; + + installPhase = '' + runHook preInstall + + mcabal -v ${lib.concatStringsSep " " configureFlags} install + mkdir -p $out/bin + find "$CABALDIR/bin" -type f -exec ln -s '{}' "$out/bin/" \; || true + find "$CABALDIR/${compiler.haskellCompilerName}/packages" -type l -delete + + runHook postInstall + ''; + + inherit + preCompileBuildDriver + postCompileBuildDriver + preUnpack + postUnpack + preConfigure + postConfigure + preBuild + postBuild + preHaddock + postHaddock + preInstall + postInstall + preCheck + postCheck + preFixup + postFixup + ; + + passthru = passthru // rec { + inherit pname version; + + compiler = ghc; + + # All this information is intended just for `shellFor`. It should be + # considered unstable and indeed we knew how to keep it private we would. + getCabalDeps = { + inherit + buildDepends' + buildTools + executableFrameworkDepends + executableHaskellDepends + executablePkgconfigDepends + executableSystemDepends + executableToolDepends + extraLibraries + libraryFrameworkDepends + libraryHaskellDepends + libraryPkgconfigDepends + librarySystemDepends + libraryToolDepends + pkg-configDepends + setupHaskellDepends + ; + } + // lib.optionalAttrs doCheck { + inherit + testDepends + testFrameworkDepends + testHaskellDepends + testPkgconfigDepends + testSystemDepends + testToolDepends + ; + } + // lib.optionalAttrs doBenchmark { + inherit + benchmarkDepends + benchmarkFrameworkDepends + benchmarkHaskellDepends + benchmarkPkgconfigDepends + benchmarkSystemDepends + benchmarkToolDepends + ; + }; + + # Attributes for the old definition of `shellFor`. Should be removed but + # this predates the warning at the top of `getCabalDeps`. + getBuildInputs = rec { + inherit propagatedBuildInputs otherBuildInputs allPkgconfigDepends; + haskellBuildInputs = isHaskellPartition.right; + systemBuildInputs = isHaskellPartition.wrong; + isHaskellPartition = lib.partition (x: x ? isHaskellLibrary) ( + propagatedBuildInputs ++ otherBuildInputs ++ depsBuildBuild ++ nativeBuildInputs + ); + }; + + isHaskellLibrary = isLibrary; + + haddockDir = null; + + # Creates a derivation containing all of the necessary dependencies for building the + # parent derivation. The attribute set that it takes as input can be viewed as: + # + # { withHoogle } + # + # The derivation that it builds contains no outpaths because it is meant for use + # as an environment + # + # # Example use + # # Creates a shell with all of the dependencies required to build the "hello" package, + # # and with python: + # + # > nix-shell -E 'with (import {}); \ + # > haskellPackages.hello.envFunc { buildInputs = [ python ]; }' + envFunc = + { + # Unsupported + withHoogle ? false, + }: + let + name = "microhs-shell-for-${pname}"; + + compilerCommandCaps = lib.toUpper compilerCommand'; + in + runCommandCC name { + inherit shellHook; + + nativeBuildInputs = [ + compilerWithPkgs + ] + ++ lib.optional (allPkgconfigDepends != [ ]) pkg-config + ++ collectedToolDepends; + buildInputs = otherBuildInputsSystem; + + env = { + "NIX_${compilerCommandCaps}" = "${compiler}/bin/${compilerCommand}"; + # TODO: is this still valid? + "NIX_${compilerCommandCaps}_LIBDIR" = "${compiler}/${compilerLibdir}"; + } + // lib.optionalAttrs (stdenv.buildPlatform.libc == "glibc") { + # TODO: Why is this written in terms of `buildPackages`, unlike + # the outer `env`? + # + # According to @sternenseemann [1]: + # + # > The condition is based on `buildPlatform`, so it needs to + # > match. `LOCALE_ARCHIVE` is set to accompany `LANG` which + # > concerns things we execute on the build platform like + # > `haddock`. + # > + # > Arguably the outer non `buildPackages` one is incorrect and + # > probably works by accident in most cases since the locale + # > archive is not platform specific (the trouble is that it + # > may sometimes be impossible to cross-compile). At least + # > that would be my assumption. + # + # [1]: https://github.com/NixOS/nixpkgs/pull/424368#discussion_r2202683378 + LOCALE_ARCHIVE = "${buildPackages.glibcLocales}/lib/locale/locale-archive"; + } + // env'; + } "echo $nativeBuildInputs $buildInputs > $out"; + + env = envFunc { }; + }; + + meta = { + inherit homepage license platforms; + } + // lib.optionalAttrs (args ? broken) { inherit broken; } + // lib.optionalAttrs (args ? description) { inherit description; } + // lib.optionalAttrs (args ? maintainers) { inherit maintainers; } + // lib.optionalAttrs (args ? teams) { inherit teams; } + // lib.optionalAttrs (args ? hydraPlatforms) { inherit hydraPlatforms; } + // lib.optionalAttrs (args ? badPlatforms) { inherit badPlatforms; } + // lib.optionalAttrs (args ? changelog) { inherit changelog; } + // lib.optionalAttrs (args ? mainProgram) { inherit mainProgram; }; +} diff --git a/pkgs/development/tools/haskell/microcabal/0.5.3.0-31f1b5dec81561a1b1d36b8e3065ce091dce2ec6.nix b/pkgs/development/tools/haskell/microcabal/0.5.3.0-31f1b5dec81561a1b1d36b8e3065ce091dce2ec6.nix new file mode 100644 index 000000000000..9917f7b4cd29 --- /dev/null +++ b/pkgs/development/tools/haskell/microcabal/0.5.3.0-31f1b5dec81561a1b1d36b8e3065ce091dce2ec6.nix @@ -0,0 +1,7 @@ +import ./common.nix rec { + # MicroCabal has important changes to mirror some changes in MicroHs but its + # version releases are not frequent enough, so we need to use newer commits + version = "0.5.3.0-${rev}"; + rev = "31f1b5dec81561a1b1d36b8e3065ce091dce2ec6"; + hash = "sha256-/oTcWGA43KQwniQKyZEPOlpmoRusDjb+k29GWc8wZzw="; +} diff --git a/pkgs/development/tools/haskell/microcabal/common.nix b/pkgs/development/tools/haskell/microcabal/common.nix new file mode 100644 index 000000000000..bbe7773fbfa7 --- /dev/null +++ b/pkgs/development/tools/haskell/microcabal/common.nix @@ -0,0 +1,69 @@ +{ + version, + rev, + hash, +}: + +{ + lib, + microhs, + stdenv, + fetchFromGitHub, + fetchpatch, +}: + +stdenv.mkDerivation { + pname = "microcabal-stage1"; + inherit version; + + src = fetchFromGitHub { + owner = "augustss"; + repo = "MicroCabal"; + inherit rev hash; + }; + + patches = [ + (fetchpatch { + # https://github.com/augustss/MicroCabal/pull/23 + name = "remove-mtl-mhs-override.patch"; + url = "https://github.com/AlexandreTunstall/MicroCabal/commit/ad30461aaf3dd295f4f5cf5db12635e42557cbfa.patch"; + hash = "sha256-Gmlt76C19ZtCHpKyNim0ggtjXnVuq5F0ywvX8BW15uM="; + }) + (fetchpatch { + # https://github.com/augustss/MicroCabal/pull/34 + name = "package-install-path.patch"; + url = "https://github.com/augustss/MicroCabal/commit/dc358bbab312e1788564fbb36f835347c21792c0.patch"; + hash = "sha256-aUQwuyp+ihXZ9PeSCqGUylcvzA6/ktZyeyBXiEoVY54="; + }) + (fetchpatch { + # https://github.com/augustss/MicroCabal/pull/34 + name = "package-search-path.patch"; + url = "https://github.com/augustss/MicroCabal/commit/3898e5f0596a7391818a0a2cfa994317cda62479.patch"; + hash = "sha256-76yEUpzH5xZZt3U+BCSqyWsImfpOEowupd5YCaYVTO0="; + }) + ]; + + makeFlags = [ + "MHS=${microhs}/bin/mhs" + "MHSDIR=${microhs}/lib/mhs" + ]; + + installPhase = '' + runHook preInstall + install -m755 -d $out/bin + install -m755 bin/mcabal $out/bin/mcabal + runHook postInstall + ''; + + meta = { + description = "A partial Cabal replacement"; + longDescription = '' + A portable subset of the Cabal functionality. + ''; + homepage = "https://github.com/augustss/MicroCabal"; + license = lib.licensesSpdx."Apache-2.0"; + mainProgram = "mcabal"; + maintainers = with lib.maintainers; [ AlexandreTunstall ]; + platforms = lib.platforms.all; + }; +} diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index 5c5c7fff8c94..a8146c05d831 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -68,6 +68,9 @@ let ghc910 = sets.ghc9103; ghc912 = sets.ghc9122; ghc914 = sets.ghc9141; + + microhs_0_15 = sets.microhs_0_15_4_0; + microhs = sets.microhs_0_15; }; in { @@ -220,15 +223,24 @@ in # with "native" and "gmp" backends. native-bignum = let - nativeBignumGhcNames = pkgs.lib.filter (name: !(builtins.elem name nativeBignumExcludes)) ( - pkgs.lib.attrNames compiler - ); + isNativeBignumGhc = + name: + !(builtins.elem name nativeBignumExcludes) && !(compiler.${name} ? isMhs && compiler.${name}.isMhs); + nativeBignumGhcNames = pkgs.lib.filter isNativeBignumGhc (pkgs.lib.attrNames compiler); in pkgs.lib.recurseIntoAttrs ( pkgs.lib.genAttrs nativeBignumGhcNames ( name: compiler.${name}.override { enableNativeBignum = true; } ) ); + + microhs-boot = callPackage ../development/compilers/microhs/boot.nix { + microhs-src = bb.compiler.microhs_0_15_4_0; + }; + + microhs_0_15_4_0 = callPackage ../development/compilers/microhs/0.15.4.0.nix { + inherit (bb.compiler) microhs-boot; + }; } // chooseDefaultVersions compiler // pkgs.lib.optionalAttrs config.allowAliases { @@ -332,6 +344,13 @@ in buildHaskellPackages = bh.packages.native-bignum.${name}; } ); + + microhs_0_15_4_0 = callPackage ../development/haskell-modules { + buildHaskellPackages = bh.packages.microhs_0_15_4_0; + ghc = bh.compiler.microhs_0_15_4_0; + compilerConfig = callPackage ../development/haskell-modules/configuration-microhs.nix { }; + packageSetConfig = bootstrapPackageSet; + }; } // chooseDefaultVersions packages // pkgs.lib.optionalAttrs config.allowAliases { From 903ce1aac6c503cd4f8a091dbb849e226948e0b8 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Wed, 8 Apr 2026 17:04:50 +0200 Subject: [PATCH 2/5] microhs: make alias/shortcut for haskell.compiler.microhs --- pkgs/top-level/all-packages.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 11eb191e29f0..f7125655a811 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4265,6 +4265,9 @@ with pkgs; haskell.compiler.ghc910 ); + # TODO(@NixOS/haskell): deprecate this alias? + microhs = targetPackages.haskell.packages.microhs.ghc or haskell.compiler.microhs; + alex = haskell.lib.compose.justStaticExecutables haskellPackages.alex; happy = haskell.lib.compose.justStaticExecutables haskellPackages.happy; From 74f842ffbed24fdce1f702e7b3e71e2b06ceb431 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Wed, 8 Apr 2026 17:05:16 +0200 Subject: [PATCH 3/5] top-level/release-haskell.nix: test some pkgs with MicroHs --- pkgs/top-level/release-haskell.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkgs/top-level/release-haskell.nix b/pkgs/top-level/release-haskell.nix index 1515645fb40e..fab634c34802 100644 --- a/pkgs/top-level/release-haskell.nix +++ b/pkgs/top-level/release-haskell.nix @@ -574,6 +574,23 @@ let compilerNames.ghc9122 compilerNames.ghc9123 ] released; + + # MicroHs + array = [ + compilerNames.microhs + ]; + ghc-compat = [ + compilerNames.microhs + ]; + hscolour = [ + compilerNames.microhs + ]; + MicroCabal = [ + compilerNames.microhs + ]; + random = [ + compilerNames.microhs + ]; }) { mergeable = pkgs.releaseTools.aggregate { From b23b370052efe85a0235a8865fc7613cdc1942d3 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Thu, 9 Apr 2026 17:13:35 +0100 Subject: [PATCH 4/5] top-level/release-haskell.nix: test GHC boot pkgs Test the GHC boot packages that are known to work with MicroHs and mark those that don't work as broken. --- .../haskell-modules/configuration-microhs.nix | 12 ++--- pkgs/top-level/release-haskell.nix | 45 ++++++++++++++++--- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/pkgs/development/haskell-modules/configuration-microhs.nix b/pkgs/development/haskell-modules/configuration-microhs.nix index bdf91c6423ed..afeb84ac4217 100644 --- a/pkgs/development/haskell-modules/configuration-microhs.nix +++ b/pkgs/development/haskell-modules/configuration-microhs.nix @@ -33,7 +33,7 @@ self: super: { }; # hackage-packages does not include GHC core libraries - binary = self.binary_0_8_9_3; + binary = markBroken self.binary_0_8_9_3; Cabal = self.Cabal_3_16_1_0; Cabal-syntax = self.Cabal-syntax_3_16_1_0; containers = self.containers_0_8; @@ -49,13 +49,13 @@ self: super: { ghc-prim = null; ghci = null; haskeline = self.haskeline_0_8_4_1; - hpc = self.hpc_0_7_0_2; - integer-gmp = self.integer-gmp_1_1; + hpc = markBroken self.hpc_0_7_0_2; + integer-gmp = markBroken self.integer-gmp_1_1; libiserv = null; mtl = self.mtl_2_3_2; os-string = self.os-string_2_0_10; parsec = self.parsec_3_1_18_0; - pretty = self.pretty_1_1_3_6; + pretty = markBroken self.pretty_1_1_3_6; rts = null; semaphore-compat = null; stm = null; @@ -64,8 +64,8 @@ self: super: { terminfo = self.terminfo_0_4_1_7; time = self.time_1_15; transformers = self.transformers_0_6_3_0; - unix = self.unix_2_8_8_0; - xhtml = self.xhtml_3000_4_0_0; + unix = markBroken self.unix_2_8_8_0; + xhtml = markBroken self.xhtml_3000_4_0_0; # MicroHs replacements for widely used libraries array = self.array-mhs; diff --git a/pkgs/top-level/release-haskell.nix b/pkgs/top-level/release-haskell.nix index fab634c34802..94d921fe217f 100644 --- a/pkgs/top-level/release-haskell.nix +++ b/pkgs/top-level/release-haskell.nix @@ -575,17 +575,50 @@ let compilerNames.ghc9123 ] released; - # MicroHs - array = [ - compilerNames.microhs - ]; + # MicroHs core packages ghc-compat = [ compilerNames.microhs ]; - hscolour = [ + MicroCabal = [ compilerNames.microhs ]; - MicroCabal = [ + + # MicroHs-specific replacement packages + array = [ + compilerNames.microhs + ]; + + # GHC boot packages known to be compatible with MicroHs + containers = [ + compilerNames.microhs + ]; + exceptions = [ + compilerNames.microhs + ]; + filepath = [ + compilerNames.microhs + ]; + mtl = [ + compilerNames.microhs + ]; + os-string = [ + compilerNames.microhs + ]; + parsec = [ + compilerNames.microhs + ]; + terminfo = [ + compilerNames.microhs + ]; + time = [ + compilerNames.microhs + ]; + transformers = [ + compilerNames.microhs + ]; + + # MicroHs upstream tested + hscolour = [ compilerNames.microhs ]; random = [ From 8fbef8091f94074bcfab1db5c7613aeedf85da80 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Thu, 9 Apr 2026 22:45:25 +0200 Subject: [PATCH 5/5] haskell.packages.microhs: add doDistribute where necessary Packages that have an empty hydraPlatforms won't be tested on Hydra otherwise, even if explicitly requested. --- .../haskell-modules/configuration-microhs.nix | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pkgs/development/haskell-modules/configuration-microhs.nix b/pkgs/development/haskell-modules/configuration-microhs.nix index afeb84ac4217..182394c829f5 100644 --- a/pkgs/development/haskell-modules/configuration-microhs.nix +++ b/pkgs/development/haskell-modules/configuration-microhs.nix @@ -13,7 +13,7 @@ self: super: { MicroHs = null; # External MicroHs core libraries - ghc-compat = markUnbroken super.ghc-compat; + ghc-compat = doDistribute (markUnbroken super.ghc-compat); # Bootstrap MicroCabal MicroCabal = self.mkDerivation { @@ -34,11 +34,11 @@ self: super: { # hackage-packages does not include GHC core libraries binary = markBroken self.binary_0_8_9_3; - Cabal = self.Cabal_3_16_1_0; - Cabal-syntax = self.Cabal-syntax_3_16_1_0; - containers = self.containers_0_8; - exceptions = self.exceptions_0_10_12; - filepath = self.filepath_1_5_5_0; + Cabal = doDistribute self.Cabal_3_16_1_0; + Cabal-syntax = doDistribute self.Cabal-syntax_3_16_1_0; + containers = doDistribute self.containers_0_8; + exceptions = doDistribute self.exceptions_0_10_12; + filepath = doDistribute self.filepath_1_5_5_0; ghc-bignum = null; ghc-boot = null; ghc-boot-th = null; @@ -48,30 +48,30 @@ self: super: { ghc-platform = null; ghc-prim = null; ghci = null; - haskeline = self.haskeline_0_8_4_1; + haskeline = doDistribute self.haskeline_0_8_4_1; hpc = markBroken self.hpc_0_7_0_2; integer-gmp = markBroken self.integer-gmp_1_1; libiserv = null; - mtl = self.mtl_2_3_2; - os-string = self.os-string_2_0_10; - parsec = self.parsec_3_1_18_0; + mtl = doDistribute self.mtl_2_3_2; + os-string = doDistribute self.os-string_2_0_10; + parsec = doDistribute self.parsec_3_1_18_0; pretty = markBroken self.pretty_1_1_3_6; rts = null; semaphore-compat = null; stm = null; system-cxx-std-lib = null; template-haskell = null; - terminfo = self.terminfo_0_4_1_7; - time = self.time_1_15; - transformers = self.transformers_0_6_3_0; + terminfo = doDistribute self.terminfo_0_4_1_7; + time = doDistribute self.time_1_15; + transformers = doDistribute self.transformers_0_6_3_0; unix = markBroken self.unix_2_8_8_0; xhtml = markBroken self.xhtml_3000_4_0_0; # MicroHs replacements for widely used libraries array = self.array-mhs; - array-mhs = markUnbroken super.array-mhs; + array-mhs = doDistribute (markUnbroken super.array-mhs); random = self.random-mhs; - random-mhs = markUnbroken super.random-mhs; + random-mhs = doDistribute (markUnbroken super.random-mhs); # Depends on time when not using GHC splitmix = addBuildDepends [ self.time ] super.splitmix;