on master help sign in
Got haskell working
371dc9diko
.gitignore+3
@@ -1,3 +1,6 @@
1build
1build
2.clickable
2.clickable
3static/elm.js
3static/elm.js
4+dist-newstyle
5+result
6+static/backend.js
backend/.vscode/settings.jsonnew file+5
@@ -0,0 +1,5 @@
1+{
2+ "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix",
3+ "haskell.serverExecutablePath": "haskell-language-server",
4+ "editor.formatOnSave": true
5+}
backend/backend.cabalnew file+69
@@ -0,0 +1,69 @@
1+cabal-version: 2.4
2+name: backend
3+version: 0.1.0.0
4+author: iko
5+maintainer: ilyakooo0@gmail.com
6+extra-source-files: CHANGELOG.md
7+
8+executable backend
9+ ghcjs-options: -dedupe
10+ ghcjs-options: -DGHCJS_BUSY_YIELD=20 -DGHCJS_GC_INTERVAL=60000
11+ main-is: Main.hs
12+ other-modules: FFI
13+ build-depends:
14+ , aeson <2.0.0.0
15+ , base
16+ , bytestring
17+ , containers
18+ , ghcjs-base-stub ==0.3.0.1
19+ , relude
20+ , text
21+ , time
22+
23+ hs-source-dirs: src
24+ default-language: Haskell2010
25+ ghc-options:
26+ -Weverything -Wno-implicit-prelude -Wno-missing-safe-haskell-mode
27+ -Wno-safe -Wno-prepositive-qualified-module
28+ -Wno-missing-import-lists -Wno-all-missed-specialisations
29+ -Wno-missing-local-signatures -Wno-partial-fields -Wno-unsafe
30+ -Wno-monomorphism-restriction -Wno-missed-specialisations
31+ -Wno-unused-packages -Wno-partial-type-signatures
32+ -Wno-unticked-promoted-constructors -threaded
33+
34+ default-extensions:
35+ AllowAmbiguousTypes
36+ ApplicativeDo
37+ BlockArguments
38+ ConstraintKinds
39+ DataKinds
40+ DefaultSignatures
41+ DeriveAnyClass
42+ DeriveFunctor
43+ DeriveGeneric
44+ DerivingVia
45+ DuplicateRecordFields
46+ FlexibleContexts
47+ FlexibleInstances
48+ FunctionalDependencies
49+ GADTs
50+ GeneralizedNewtypeDeriving
51+ LambdaCase
52+ MonoLocalBinds
53+ MultiParamTypeClasses
54+ OverloadedLabels
55+ OverloadedStrings
56+ PartialTypeSignatures
57+ PolyKinds
58+ RankNTypes
59+ RecordWildCards
60+ RecursiveDo
61+ ScopedTypeVariables
62+ StandaloneDeriving
63+ StandaloneKindSignatures
64+ TupleSections
65+ TypeApplications
66+ TypeFamilies
67+ TypeOperators
68+ UndecidableInstances
69+ ViewPatterns
backend/flake.locknew file+453
@@ -0,0 +1,453 @@
1+{
2+ "nodes": {
3+ "HTTP": {
4+ "flake": false,
5+ "locked": {
6+ "lastModified": 1451647621,
7+ "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=",
8+ "owner": "phadej",
9+ "repo": "HTTP",
10+ "rev": "9bc0996d412fef1787449d841277ef663ad9a915",
11+ "type": "github"
12+ },
13+ "original": {
14+ "owner": "phadej",
15+ "repo": "HTTP",
16+ "type": "github"
17+ }
18+ },
19+ "cabal-32": {
20+ "flake": false,
21+ "locked": {
22+ "lastModified": 1603716527,
23+ "narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=",
24+ "owner": "haskell",
25+ "repo": "cabal",
26+ "rev": "48bf10787e27364730dd37a42b603cee8d6af7ee",
27+ "type": "github"
28+ },
29+ "original": {
30+ "owner": "haskell",
31+ "ref": "3.2",
32+ "repo": "cabal",
33+ "type": "github"
34+ }
35+ },
36+ "cabal-34": {
37+ "flake": false,
38+ "locked": {
39+ "lastModified": 1640353650,
40+ "narHash": "sha256-N1t6M3/wqj90AEdRkeC8i923gQYUpzSr8b40qVOZ1Rk=",
41+ "owner": "haskell",
42+ "repo": "cabal",
43+ "rev": "942639c18c0cd8ec53e0a6f8d120091af35312cd",
44+ "type": "github"
45+ },
46+ "original": {
47+ "owner": "haskell",
48+ "ref": "3.4",
49+ "repo": "cabal",
50+ "type": "github"
51+ }
52+ },
53+ "cabal-36": {
54+ "flake": false,
55+ "locked": {
56+ "lastModified": 1641652457,
57+ "narHash": "sha256-BlFPKP4C4HRUJeAbdembX1Rms1LD380q9s0qVDeoAak=",
58+ "owner": "haskell",
59+ "repo": "cabal",
60+ "rev": "f27667f8ec360c475027dcaee0138c937477b070",
61+ "type": "github"
62+ },
63+ "original": {
64+ "owner": "haskell",
65+ "ref": "3.6",
66+ "repo": "cabal",
67+ "type": "github"
68+ }
69+ },
70+ "cardano-shell": {
71+ "flake": false,
72+ "locked": {
73+ "lastModified": 1608537748,
74+ "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=",
75+ "owner": "input-output-hk",
76+ "repo": "cardano-shell",
77+ "rev": "9392c75087cb9a3d453998f4230930dea3a95725",
78+ "type": "github"
79+ },
80+ "original": {
81+ "owner": "input-output-hk",
82+ "repo": "cardano-shell",
83+ "type": "github"
84+ }
85+ },
86+ "flake-compat": {
87+ "flake": false,
88+ "locked": {
89+ "lastModified": 1650374568,
90+ "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
91+ "owner": "edolstra",
92+ "repo": "flake-compat",
93+ "rev": "b4a34015c698c7793d592d66adbab377907a2be8",
94+ "type": "github"
95+ },
96+ "original": {
97+ "owner": "edolstra",
98+ "repo": "flake-compat",
99+ "type": "github"
100+ }
101+ },
102+ "flake-utils": {
103+ "locked": {
104+ "lastModified": 1656928814,
105+ "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
106+ "owner": "numtide",
107+ "repo": "flake-utils",
108+ "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
109+ "type": "github"
110+ },
111+ "original": {
112+ "owner": "numtide",
113+ "repo": "flake-utils",
114+ "type": "github"
115+ }
116+ },
117+ "flake-utils_2": {
118+ "locked": {
119+ "lastModified": 1644229661,
120+ "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
121+ "owner": "numtide",
122+ "repo": "flake-utils",
123+ "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
124+ "type": "github"
125+ },
126+ "original": {
127+ "owner": "numtide",
128+ "repo": "flake-utils",
129+ "type": "github"
130+ }
131+ },
132+ "ghc-8.6.5-iohk": {
133+ "flake": false,
134+ "locked": {
135+ "lastModified": 1600920045,
136+ "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=",
137+ "owner": "input-output-hk",
138+ "repo": "ghc",
139+ "rev": "95713a6ecce4551240da7c96b6176f980af75cae",
140+ "type": "github"
141+ },
142+ "original": {
143+ "owner": "input-output-hk",
144+ "ref": "release/8.6.5-iohk",
145+ "repo": "ghc",
146+ "type": "github"
147+ }
148+ },
149+ "hackage": {
150+ "flake": false,
151+ "locked": {
152+ "lastModified": 1658195491,
153+ "narHash": "sha256-PFpjvu2WnOq3qWRZcFtf72Zrx8ZEaDUpGSGX6TnOcmA=",
154+ "owner": "input-output-hk",
155+ "repo": "hackage.nix",
156+ "rev": "50330b825035bf45d680e7fa14810a18c811603c",
157+ "type": "github"
158+ },
159+ "original": {
160+ "owner": "input-output-hk",
161+ "repo": "hackage.nix",
162+ "type": "github"
163+ }
164+ },
165+ "haskellNix": {
166+ "inputs": {
167+ "HTTP": "HTTP",
168+ "cabal-32": "cabal-32",
169+ "cabal-34": "cabal-34",
170+ "cabal-36": "cabal-36",
171+ "cardano-shell": "cardano-shell",
172+ "flake-utils": "flake-utils_2",
173+ "ghc-8.6.5-iohk": "ghc-8.6.5-iohk",
174+ "hackage": "hackage",
175+ "hpc-coveralls": "hpc-coveralls",
176+ "hydra": "hydra",
177+ "nix-tools": "nix-tools",
178+ "nixpkgs": [
179+ "haskellNix",
180+ "nixpkgs-unstable"
181+ ],
182+ "nixpkgs-2003": "nixpkgs-2003",
183+ "nixpkgs-2105": "nixpkgs-2105",
184+ "nixpkgs-2111": "nixpkgs-2111",
185+ "nixpkgs-2205": "nixpkgs-2205",
186+ "nixpkgs-unstable": "nixpkgs-unstable",
187+ "old-ghc-nix": "old-ghc-nix",
188+ "stackage": "stackage"
189+ },
190+ "locked": {
191+ "lastModified": 1658216441,
192+ "narHash": "sha256-eWsrJFBZ4fMC/UN7c09GNXVfVIrJzW9RvfdD0RfaisU=",
193+ "owner": "input-output-hk",
194+ "repo": "haskell.nix",
195+ "rev": "0dca71e2f3f3d63eeab01136138e0e1ceab5320d",
196+ "type": "github"
197+ },
198+ "original": {
199+ "owner": "input-output-hk",
200+ "repo": "haskell.nix",
201+ "type": "github"
202+ }
203+ },
204+ "hpc-coveralls": {
205+ "flake": false,
206+ "locked": {
207+ "lastModified": 1607498076,
208+ "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=",
209+ "owner": "sevanspowell",
210+ "repo": "hpc-coveralls",
211+ "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430",
212+ "type": "github"
213+ },
214+ "original": {
215+ "owner": "sevanspowell",
216+ "repo": "hpc-coveralls",
217+ "type": "github"
218+ }
219+ },
220+ "hydra": {
221+ "inputs": {
222+ "nix": "nix",
223+ "nixpkgs": [
224+ "haskellNix",
225+ "hydra",
226+ "nix",
227+ "nixpkgs"
228+ ]
229+ },
230+ "locked": {
231+ "lastModified": 1646878427,
232+ "narHash": "sha256-KtbrofMtN8GlM7D+n90kixr7QpSlVmdN+vK5CA/aRzc=",
233+ "owner": "NixOS",
234+ "repo": "hydra",
235+ "rev": "28b682b85b7efc5cf7974065792a1f22203a5927",
236+ "type": "github"
237+ },
238+ "original": {
239+ "id": "hydra",
240+ "type": "indirect"
241+ }
242+ },
243+ "lowdown-src": {
244+ "flake": false,
245+ "locked": {
246+ "lastModified": 1633514407,
247+ "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
248+ "owner": "kristapsdz",
249+ "repo": "lowdown",
250+ "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
251+ "type": "github"
252+ },
253+ "original": {
254+ "owner": "kristapsdz",
255+ "repo": "lowdown",
256+ "type": "github"
257+ }
258+ },
259+ "nix": {
260+ "inputs": {
261+ "lowdown-src": "lowdown-src",
262+ "nixpkgs": "nixpkgs",
263+ "nixpkgs-regression": "nixpkgs-regression"
264+ },
265+ "locked": {
266+ "lastModified": 1643066034,
267+ "narHash": "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=",
268+ "owner": "NixOS",
269+ "repo": "nix",
270+ "rev": "a1cd7e58606a41fcf62bf8637804cf8306f17f62",
271+ "type": "github"
272+ },
273+ "original": {
274+ "owner": "NixOS",
275+ "ref": "2.6.0",
276+ "repo": "nix",
277+ "type": "github"
278+ }
279+ },
280+ "nix-tools": {
281+ "flake": false,
282+ "locked": {
283+ "lastModified": 1649424170,
284+ "narHash": "sha256-XgKXWispvv5RCvZzPb+p7e6Hy3LMuRjafKMl7kXzxGw=",
285+ "owner": "input-output-hk",
286+ "repo": "nix-tools",
287+ "rev": "e109c94016e3b6e0db7ed413c793e2d4bdb24aa7",
288+ "type": "github"
289+ },
290+ "original": {
291+ "owner": "input-output-hk",
292+ "repo": "nix-tools",
293+ "type": "github"
294+ }
295+ },
296+ "nixpkgs": {
297+ "locked": {
298+ "lastModified": 1632864508,
299+ "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=",
300+ "owner": "NixOS",
301+ "repo": "nixpkgs",
302+ "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234",
303+ "type": "github"
304+ },
305+ "original": {
306+ "id": "nixpkgs",
307+ "ref": "nixos-21.05-small",
308+ "type": "indirect"
309+ }
310+ },
311+ "nixpkgs-2003": {
312+ "locked": {
313+ "lastModified": 1620055814,
314+ "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=",
315+ "owner": "NixOS",
316+ "repo": "nixpkgs",
317+ "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205",
318+ "type": "github"
319+ },
320+ "original": {
321+ "owner": "NixOS",
322+ "ref": "nixpkgs-20.03-darwin",
323+ "repo": "nixpkgs",
324+ "type": "github"
325+ }
326+ },
327+ "nixpkgs-2105": {
328+ "locked": {
329+ "lastModified": 1655034179,
330+ "narHash": "sha256-rf1/7AbzuYDw6+8Xvvf3PtEOygymLBrFsFxvext5ZjI=",
331+ "owner": "NixOS",
332+ "repo": "nixpkgs",
333+ "rev": "046ee4af7a9f016a364f8f78eeaa356ba524ac31",
334+ "type": "github"
335+ },
336+ "original": {
337+ "owner": "NixOS",
338+ "ref": "nixpkgs-21.05-darwin",
339+ "repo": "nixpkgs",
340+ "type": "github"
341+ }
342+ },
343+ "nixpkgs-2111": {
344+ "locked": {
345+ "lastModified": 1656782578,
346+ "narHash": "sha256-1eMCBEqJplPotTo/SZ/t5HU6Sf2I8qKlZi9MX7jv9fw=",
347+ "owner": "NixOS",
348+ "repo": "nixpkgs",
349+ "rev": "573603b7fdb9feb0eb8efc16ee18a015c667ab1b",
350+ "type": "github"
351+ },
352+ "original": {
353+ "owner": "NixOS",
354+ "ref": "nixpkgs-21.11-darwin",
355+ "repo": "nixpkgs",
356+ "type": "github"
357+ }
358+ },
359+ "nixpkgs-2205": {
360+ "locked": {
361+ "lastModified": 1657876628,
362+ "narHash": "sha256-URmf0O2cQ/3heg2DJOeLyU/JmfVMqG4X5t9crQXMaeY=",
363+ "owner": "NixOS",
364+ "repo": "nixpkgs",
365+ "rev": "549d82bdd40f760a438c3c3497c1c61160f3de55",
366+ "type": "github"
367+ },
368+ "original": {
369+ "owner": "NixOS",
370+ "ref": "nixpkgs-22.05-darwin",
371+ "repo": "nixpkgs",
372+ "type": "github"
373+ }
374+ },
375+ "nixpkgs-regression": {
376+ "locked": {
377+ "lastModified": 1643052045,
378+ "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
379+ "owner": "NixOS",
380+ "repo": "nixpkgs",
381+ "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
382+ "type": "github"
383+ },
384+ "original": {
385+ "id": "nixpkgs",
386+ "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
387+ "type": "indirect"
388+ }
389+ },
390+ "nixpkgs-unstable": {
391+ "locked": {
392+ "lastModified": 1657888067,
393+ "narHash": "sha256-GnwJoFBTPfW3+mz7QEeJEEQ9OMHZOiIJ/qDhZxrlKh8=",
394+ "owner": "NixOS",
395+ "repo": "nixpkgs",
396+ "rev": "65fae659e31098ca4ac825a6fef26d890aaf3f4e",
397+ "type": "github"
398+ },
399+ "original": {
400+ "owner": "NixOS",
401+ "ref": "nixpkgs-unstable",
402+ "repo": "nixpkgs",
403+ "type": "github"
404+ }
405+ },
406+ "old-ghc-nix": {
407+ "flake": false,
408+ "locked": {
409+ "lastModified": 1631092763,
410+ "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=",
411+ "owner": "angerman",
412+ "repo": "old-ghc-nix",
413+ "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8",
414+ "type": "github"
415+ },
416+ "original": {
417+ "owner": "angerman",
418+ "ref": "master",
419+ "repo": "old-ghc-nix",
420+ "type": "github"
421+ }
422+ },
423+ "root": {
424+ "inputs": {
425+ "flake-compat": "flake-compat",
426+ "flake-utils": "flake-utils",
427+ "haskellNix": "haskellNix",
428+ "nixpkgs": [
429+ "haskellNix",
430+ "nixpkgs-unstable"
431+ ]
432+ }
433+ },
434+ "stackage": {
435+ "flake": false,
436+ "locked": {
437+ "lastModified": 1658106847,
438+ "narHash": "sha256-xcq/FgP1eNxaq7BaI+k0bkXfy+MFGib5I44VGGFQZdQ=",
439+ "owner": "input-output-hk",
440+ "repo": "stackage.nix",
441+ "rev": "0fbfc3a3fb735e6bd5c81f614d8ed5308e501496",
442+ "type": "github"
443+ },
444+ "original": {
445+ "owner": "input-output-hk",
446+ "repo": "stackage.nix",
447+ "type": "github"
448+ }
449+ }
450+ },
451+ "root": "root",
452+ "version": 7
453+}
backend/flake.nixnew file+88
@@ -0,0 +1,88 @@
1+{
2+ description = "A very basic flake";
3+
4+ inputs = {
5+ haskellNix.url = "github:input-output-hk/haskell.nix";
6+ nixpkgs.follows = "haskellNix/nixpkgs-unstable";
7+ flake-utils.url = "github:numtide/flake-utils";
8+ flake-compat = {
9+ url = "github:edolstra/flake-compat";
10+ flake = false;
11+ };
12+ };
13+
14+ outputs = { self, nixpkgs, flake-utils, haskellNix, flake-compat }:
15+ flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system:
16+ let
17+ overlays = [
18+ haskellNix.overlay
19+ (self: super: {
20+ gpr = self.grpc;
21+ })
22+ ];
23+
24+
25+ compiler = "ghc8107";
26+ pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
27+
28+ project = { production }: pkgs.haskell-nix.cabalProject {
29+ compiler-nix-name = compiler;
30+ shell = {
31+ exactDeps = false;
32+ # crossPlatforms = p: [ p.ghcjs ];
33+ tools = {
34+ cabal = "latest";
35+ haskell-language-server = "latest";
36+ hlint = { };
37+ # haskell-language-server = {
38+ # version = "latest";
39+
40+ # cabalProject = ''
41+ # packages: .
42+
43+ # package haskell-language-server
44+ # flags: -haddockcomments
45+ # constraints:
46+ # some == 1.0.3
47+ # '';
48+ # modules = [{
49+ # reinstallableLibGhc = true;
50+ # }];
51+ # };
52+ };
53+ };
54+ src = ./.;
55+ modules =
56+ pkgs.lib.optional production {
57+ ghcOptions = [
58+ "-O2"
59+ "-fexpose-all-unfoldings"
60+ "-fspecialise-aggressively"
61+ ];
62+ dontStrip = false;
63+ dontPatchELF = false;
64+ enableDeadCodeElimination = true;
65+ # packages.nobullshit-vpn.ghcOptions = [
66+ # "-O2"
67+ # "-fexpose-all-unfoldings"
68+ # "-fspecialise-aggressively"
69+ # "-Werror"
70+ # ];
71+ };
72+ };
73+ flake = (project { production = false; }).flake {
74+ crossPlatforms = p: [ p.ghcjs ];
75+ };
76+ flakeProd = (project { production = true; }).flake { };
77+ # presearch = flake.packages."presearch:exe:presearch";
78+ in
79+ flake // { packages.default = flake.packages."js-unknown-ghcjs:backend:exe:backend"; });
80+ # {
81+ # devShell = flake.devShell;
82+ # packages = {
83+ # # default = presearch;
84+ # # presearch-bin = flakeProd.packages."presearch:exe:presearch" + "/bin/presearch";
85+ # };
86+ # inherit flake;
87+ # });
88+}
backend/shell.nixnew file+10
@@ -0,0 +1,10 @@
1+(import
2+ (
3+ let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
4+ fetchTarball {
5+ url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
6+ sha256 = lock.nodes.flake-compat.locked.narHash;
7+ }
8+ )
9+ { src = ./.; }
10+).shellNix
backend/src/FFI.hsnew file+12
@@ -0,0 +1,12 @@
1+{-# LANGUAGE CPP #-}
2+
3+module FFI (launchElm) where
4+import Data.JSString (JSString)
5+
6+#ifdef __GHCJS__
7+foreign import javascript unsafe "Elm.Main.init({node: document.getElementById($1)})"
8+ launchElm
9+#else
10+launchElm = undefined
11+#endif
12+ :: JSString -> IO ()
backend/src/Main.hsnew file+9
@@ -0,0 +1,9 @@
1+module Main (main) where
2+
3+import Data.JSString
4+import qualified FFI
5+
6+main :: IO ()
7+main = do
8+ FFI.launchElm "elm"
9+ putStrLn "Hello, Haskell!"
dev/build-backend.shnew file+3
@@ -0,0 +1,3 @@
1+#!/bin/sh
2+
3+cp "$(nix build --print-out-paths ./backend)/bin/backend.jsexe/all.js" static/backend.js
static/index.html+1−1
@@ -13,7 +13,7 @@
13
13
14<body>
14<body>
15 <div id="elm"></div>
15 <div id="elm"></div>
16− <script src="script.js"></script>
16+ <script src="backend.js"></script>
17</body>
17</body>
18
18
19</html>
19</html>