git.iko.soy/lynxjs-elm/compiler
on master help sign in
Fork Elm compiler as lynxjs-elm targeting LynxJS native rendering
43aef00iko
.gitignore+2
@@ -7,3 +7,5 @@ cabal.sandbox.config
7.DS_Store
7.DS_Store
8*~
8*~
9travis.log
9travis.log
10+.stack-work/
11+stack.yaml.lock
builder/src/Stuff.hs+2−2
@@ -172,7 +172,7 @@ getCacheDir projectName =
172
172
173getElmHome :: IO FilePath
173getElmHome :: IO FilePath
174getElmHome =
174getElmHome =
175− do maybeCustomHome <- Env.lookupEnv "ELM_HOME"
175+ do maybeCustomHome <- Env.lookupEnv "LYNXJS_ELM_HOME"
176 case maybeCustomHome of
176 case maybeCustomHome of
177 Just customHome -> return customHome
177 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)
23import qualified Data.Version as Version
23import qualified Data.Version as Version
24import Data.Word (Word8, Word16)
24import Data.Word (Word8, Word16)
25import Foreign.Ptr (Ptr, plusPtr, minusPtr)
25import Foreign.Ptr (Ptr, plusPtr, minusPtr)
26−import qualified Paths_elm
26+import qualified Paths_lynxjs_elm
27
27
28import qualified Json.Decode as D
28import qualified Json.Decode as D
29import qualified Json.Encode as E
29import qualified Json.Encode as E
@@ -56,7 +56,7 @@ max =
56
56
57compiler :: Version
57compiler :: Version
58compiler =
58compiler =
59− case map fromIntegral (Version.versionBranch Paths_elm.version) of
59+ case map fromIntegral (Version.versionBranch Paths_lynxjs_elm.version) of
60 major : minor : patch : _ ->
60 major : minor : patch : _ ->
61 Version major minor patch
61 Version major minor patch
62
62
compiler/src/Generate/Html.hs+3−33
@@ -18,36 +18,6 @@ import Text.RawString.QQ (r)
18sandwich :: Name.Name -> B.Builder -> B.Builder
18sandwich :: Name.Name -> B.Builder -> B.Builder
19sandwich moduleName javascript =
19sandwich moduleName javascript =
20 let name = Name.toBuilder moduleName in
20 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|
21+ javascript <> [r|
36−
37− var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm") });
22+var app = Elm.|] <> name <> [r|.init({});
38−}
23+|]
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>|]
elm.cabal → lynxjs-elm.cabalrenamed+6−6
@@ -1,13 +1,13 @@
1
1
2−Name: elm
2+Name: lynxjs-elm
3Version: 0.19.1
3Version: 0.19.1
4
4
5Synopsis:
5Synopsis:
6− The `elm` command line interface.
6+ The `lynxjs-elm` command line interface.
7
7
8Description:
8Description:
9− This includes commands like `elm make`, `elm repl`, and many others
9+ Elm compiler targeting LynxJS native rendering instead of browser DOM.
10− for helping make Elm developers happy and productive.
10+ Fork of the Elm compiler with modified code generation for LynxJS PAPIs.
11
11
12Homepage: https://elm-lang.org
12Homepage: https://elm-lang.org
13
13
@@ -34,7 +34,7 @@ Flag dev {
34}
34}
35
35
36
36
37−Executable elm
37+Executable lynxjs-elm
38 ghc-options: -O2 -rtsopts -threaded "-with-rtsopts=-N -qg -A128m" -Wall -Werror
38 ghc-options: -O2 -rtsopts -threaded "-with-rtsopts=-N -qg -A128m" -Wall -Werror
39 -- add -eventlog for (elm make src/Main.elm +RTS -l; threadscope elm.eventlog)
39 -- add -eventlog for (elm make src/Main.elm +RTS -l; threadscope elm.eventlog)
40 -- https://www.oreilly.com/library/view/parallel-and-concurrent/9781449335939/
40 -- https://www.oreilly.com/library/view/parallel-and-concurrent/9781449335939/
@@ -197,7 +197,7 @@ Executable elm
197 Type.Type
197 Type.Type
198 Type.Unify
198 Type.Unify
199 Type.UnionFind
199 Type.UnionFind
200− Paths_elm
200+ Paths_lynxjs_elm
201
201
202 Build-depends:
202 Build-depends:
203 ansi-terminal,
203 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
46intro =
46intro =
47 P.vcat
47 P.vcat
48 [ P.fillSep
48 [ P.fillSep
49− ["Hi,","thank","you","for","trying","out"
49+ ["Hi,","welcome","to"
50− ,P.green "Elm"
50+ ,P.green "lynxjs-elm"
51 ,P.green (P.text (V.toChars V.compiler)) <> "."
51 ,P.green (P.text (V.toChars V.compiler)) <> "."
52− ,"I hope you like it!"
52+ ,"Elm","targeting","LynxJS","native","rendering."
53 ]
53 ]
54 , ""
54 , ""
55 , P.black "-------------------------------------------------------------------------------"
55 , P.black "-------------------------------------------------------------------------------"
56− , P.black "I highly recommend working through <https://guide.elm-lang.org> to get started."
56+ , P.black "This is a fork of the Elm compiler that outputs LynxJS element trees"
57− , P.black "It teaches many important concepts, including how to use `elm` in the terminal."
57+ , P.black "instead of browser DOM. See <https://guide.elm-lang.org> for Elm basics."
58 , P.black "-------------------------------------------------------------------------------"
58 , P.black "-------------------------------------------------------------------------------"
59 ]
59 ]
60
60
terminal/src/Make.hs+1−1
@@ -94,7 +94,7 @@ runHelp root paths style (Flags debug optimize maybeOutput _ maybeDocs) =
94
94
95 [name] ->
95 [name] ->
96 do builder <- toBuilder root details desiredMode artifacts
96 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 [])
98
98
99 name:names ->
99 name:names ->
100 do builder <- toBuilder root details desiredMode artifacts
100 do builder <- toBuilder root details desiredMode artifacts