git.iko.soy/lynxjs-elm/compiler
on master help sign in
Fork Elm compiler as lynxjs-elm targeting LynxJS native rendering

- Rename binary from elm to lynxjs-elm (elm.cabal -> lynxjs-elm.cabal) - Html.sandwich: emit plain JS bootstrap instead of HTML document wrapper - Make.hs: default single-main output to elm.js instead of index.html - Stuff.hs: use ~/.lynxjs-elm as default package cache (LYNXJS_ELM_HOME env var) - stack.yaml: add build config, exclude worker package (elm-lang.org web service) - Update intro message to identify as LynxJS fork

commit43aef00e42b07e13656b228a9acab1ef511b402a authoriko <mail@iko.soy> dateMon 16 Mar 2026, 08:34 (7 months ago) parentcce7a8b
8 files changed+94−49
.gitignore+2 builder/src/Stuff.hs+2−2 compiler/src/Elm/Version.hs+2−2 compiler/src/Generate/Html.hs+3−33 elm.cabal → lynxjs-elm.cabal+6−6 stack.yaml+73 terminal/src/Main.hs+5−5 terminal/src/Make.hs+1−1
.gitignore+2
@@ -7,3 +7,5 @@ cabal.sandbox.config
77.DS_Store
88*~
99travis.log
10+.stack-work/
11+stack.yaml.lock
builder/src/Stuff.hs+2−2
@@ -172,7 +172,7 @@ getCacheDir projectName =
172172
173173getElmHome :: IO FilePath
174174getElmHome =
175− do maybeCustomHome <- Env.lookupEnv "ELM_HOME"
175+ do maybeCustomHome <- Env.lookupEnv "LYNXJS_ELM_HOME"
176176 case maybeCustomHome of
177177 Just customHome -> return customHome
178− Nothing -> Dir.getAppUserDataDirectory "elm"
178+ Nothing -> Dir.getAppUserDataDirectory "lynxjs-elm"
compiler/src/Elm/Version.hs+2−2
@@ -23,7 +23,7 @@ import Data.Binary (Binary, get, put, getWord8, putWord8)
2323import qualified Data.Version as Version
2424import Data.Word (Word8, Word16)
2525import Foreign.Ptr (Ptr, plusPtr, minusPtr)
26−import qualified Paths_elm
26+import qualified Paths_lynxjs_elm
2727
2828import qualified Json.Decode as D
2929import qualified Json.Encode as E
@@ -56,7 +56,7 @@ max =
5656
5757compiler :: Version
5858compiler =
59− case map fromIntegral (Version.versionBranch Paths_elm.version) of
59+ case map fromIntegral (Version.versionBranch Paths_lynxjs_elm.version) of
6060 major : minor : patch : _ ->
6161 Version major minor patch
6262
compiler/src/Generate/Html.hs+3−33
@@ -18,36 +18,6 @@ import Text.RawString.QQ (r)
1818sandwich :: Name.Name -> B.Builder -> B.Builder
1919sandwich moduleName javascript =
2020 let name = Name.toBuilder moduleName in
21− [r|<!DOCTYPE HTML>
22−<html>
23−<head>
24− <meta charset="UTF-8">
25− <title>|] <> name <> [r|</title>
26− <style>body { padding: 0; margin: 0; }</style>
27−</head>
28−
29−<body>
30−
31−<pre id="elm"></pre>
32−
33−<script>
34−try {
35−|] <> javascript <> [r|
36−
37− var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm") });
38−}
39−catch (e)
40−{
41− // display initialization errors (e.g. bad flags, infinite recursion)
42− var header = document.createElement("h1");
43− header.style.fontFamily = "monospace";
44− header.innerText = "Initialization Error";
45− var pre = document.getElementById("elm");
46− document.body.insertBefore(header, pre);
47− pre.innerText = e;
48− throw e;
49−}
50−</script>
51−
52−</body>
53−</html>|]
21+ javascript <> [r|
22+var app = Elm.|] <> name <> [r|.init({});
23+|]
elm.cabal → lynxjs-elm.cabalrenamed+6−6
@@ -1,13 +1,13 @@
11
2−Name: elm
2+Name: lynxjs-elm
33Version: 0.19.1
44
55Synopsis:
6− The `elm` command line interface.
6+ The `lynxjs-elm` command line interface.
77
88Description:
9− This includes commands like `elm make`, `elm repl`, and many others
10− for helping make Elm developers happy and productive.
9+ Elm compiler targeting LynxJS native rendering instead of browser DOM.
10+ Fork of the Elm compiler with modified code generation for LynxJS PAPIs.
1111
1212Homepage: https://elm-lang.org
1313
@@ -34,7 +34,7 @@ Flag dev {
3434}
3535
3636
37−Executable elm
37+Executable lynxjs-elm
3838 ghc-options: -O2 -rtsopts -threaded "-with-rtsopts=-N -qg -A128m" -Wall -Werror
3939 -- add -eventlog for (elm make src/Main.elm +RTS -l; threadscope elm.eventlog)
4040 -- https://www.oreilly.com/library/view/parallel-and-concurrent/9781449335939/
@@ -197,7 +197,7 @@ Executable elm
197197 Type.Type
198198 Type.Unify
199199 Type.UnionFind
200− Paths_elm
200+ Paths_lynxjs_elm
201201
202202 Build-depends:
203203 ansi-terminal,
stack.yamlnew file+73
@@ -0,0 +1,73 @@
1+# This file was automatically generated by 'stack init'
2+#
3+# Some commonly used options have been documented as comments in this file.
4+# For advanced use and comprehensive documentation of the format, please see:
5+# https://docs.haskellstack.org/en/stable/configure/yaml/
6+
7+nix:
8+ enable: true
9+ packages:
10+ - zlib
11+
12+# A 'specific' Stackage snapshot or a compiler version.
13+# A snapshot resolver dictates the compiler version and the set of packages
14+# to be used for project dependencies. For example:
15+#
16+# snapshot: lts-23.24
17+# snapshot: nightly-2025-06-15
18+# snapshot: ghc-9.8.4
19+#
20+# The location of a snapshot can be provided as a file or url. Stack assumes
21+# a snapshot provided as a file might change, whereas a url resource does not.
22+#
23+# snapshot: ./custom-snapshot.yaml
24+# snapshot: https://example.com/snapshots/2024-01-01.yaml
25+snapshot: lts-24.34
26+
27+# User packages to be built.
28+# Various formats can be used as shown in the example below.
29+#
30+# packages:
31+# - some-directory
32+# - https://example.com/foo/bar/baz-0.0.2.tar.gz
33+# subdirs:
34+# - auto-update
35+# - wai
36+packages:
37+ - .
38+# Dependency packages to be pulled from upstream that are not in the snapshot.
39+# These entries can reference officially published versions as well as
40+# forks / in-progress versions pinned to a git hash. For example:
41+#
42+# extra-deps:
43+# - acme-missiles-0.3
44+# - git: https://github.com/commercialhaskell/stack.git
45+# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
46+#
47+extra-deps:
48+ - ansi-wl-pprint-0.6.9@sha256:fb737bc96e2aef34ad595d54ced7a73f648c521ebcb00fe0679aff45ccd49212,2448
49+ - ansi-terminal-1.0.2@sha256:1f90bb88e670ce63fbf2c9216d50857f2419582f1c6791e542c3eab97ecfd364,2897
50+ - ansi-terminal-types-0.11.5@sha256:f78440dfd95c4509e88855ac7cc2d9566ddf956a92c1290404cac93ad1a1b00a,1482
51+# Override default flag values for project packages and extra-deps
52+# flags: {}
53+
54+# Extra package databases containing global packages
55+# extra-package-dbs: []
56+
57+# Control whether we use the GHC we find on the path
58+# system-ghc: true
59+#
60+# Require a specific version of Stack, using version ranges
61+# require-stack-version: -any # Default
62+# require-stack-version: ">=3.7"
63+#
64+# Override the architecture used by Stack, especially useful on Windows
65+# arch: i386
66+# arch: x86_64
67+#
68+# Extra directories used by Stack for building
69+# extra-include-dirs: [/path/to/dir]
70+# extra-lib-dirs: [/path/to/dir]
71+#
72+# Allow a newer minor version of GHC than the snapshot specifies
73+# compiler-check: newer-minor
terminal/src/Main.hs+5−5
@@ -46,15 +46,15 @@ intro :: P.Doc
4646intro =
4747 P.vcat
4848 [ P.fillSep
49− ["Hi,","thank","you","for","trying","out"
50− ,P.green "Elm"
49+ ["Hi,","welcome","to"
50+ ,P.green "lynxjs-elm"
5151 ,P.green (P.text (V.toChars V.compiler)) <> "."
52− ,"I hope you like it!"
52+ ,"Elm","targeting","LynxJS","native","rendering."
5353 ]
5454 , ""
5555 , P.black "-------------------------------------------------------------------------------"
56− , P.black "I highly recommend working through <https://guide.elm-lang.org> to get started."
57− , P.black "It teaches many important concepts, including how to use `elm` in the terminal."
56+ , P.black "This is a fork of the Elm compiler that outputs LynxJS element trees"
57+ , P.black "instead of browser DOM. See <https://guide.elm-lang.org> for Elm basics."
5858 , P.black "-------------------------------------------------------------------------------"
5959 ]
6060
terminal/src/Make.hs+1−1
@@ -94,7 +94,7 @@ runHelp root paths style (Flags debug optimize maybeOutput _ maybeDocs) =
9494
9595 [name] ->
9696 do builder <- toBuilder root details desiredMode artifacts
97− generate style "index.html" (Html.sandwich name builder) (NE.List name [])
97+ generate style "elm.js" (Html.sandwich name builder) (NE.List name [])
9898
9999 name:names ->
100100 do builder <- toBuilder root details desiredMode artifacts