on c3da07b help sign in
.github/pull_request_template.md−2
since splitsnapshots
unifiedsplit
@@ -3,8 +3,6 @@
3I have:
3I have:
4
4
5 - [ ] Based work on latest `develop` branch
5 - [ ] Based work on latest `develop` branch
6− - [ ] Followed the [contribution guide](https://github.com/obsidiansystems/obelisk/blob/develop/CONTRIBUTING.md#submitting-changes)
7 - [ ] Looked for lint in my changes with `hlint .` (lint found code you did not write can be left alone)
6 - [ ] Looked for lint in my changes with `hlint .` (lint found code you did not write can be left alone)
8 - [ ] Run the test suite: `$(nix-build -A selftest --no-out-link)`
7 - [ ] Run the test suite: `$(nix-build -A selftest --no-out-link)`
9− - [ ] [Updated the changelog](https://github.com/obsidiansystems/obelisk/blob/develop/CONTRIBUTING.md#in-the-changelog)
10 - [ ] (Optional) Run CI tests locally: `nix-build release.nix -A build.x86_64-linux --no-out-link` (or `x86_64-darwin` on macOS)
8 - [ ] (Optional) Run CI tests locally: `nix-build release.nix -A build.x86_64-linux --no-out-link` (or `x86_64-darwin` on macOS)
ChangeLog.md+1−19
@@ -2,26 +2,8 @@
2
2
3This project's release branch is `master`. This log is written from the perspective of the release branch: when changes hit `master`, they are considered released.
3This project's release branch is `master`. This log is written from the perspective of the release branch: when changes hit `master`, they are considered released.
4
4
5−## v0.9.1.0
5+## Unreleased
6
6
7−* [#801](https://github.com/obsidiansystems/obelisk/pull/801): Remove errors and warning for local packages without a library component
8−* [#812](https://github.com/obsidiansystems/obelisk/pull/812): Add support for `NoImplicitPrelude` and other extensions disabled via `No`
9−* Pinned version bumps:
10− * reflex-platform [0.7.0.0](https://github.com/reflex-frp/reflex-platform/releases/tag/v0.7.0.0)
11− * hnix 0.8.0
12−* [#787](https://github.com/obsidiansystems/obelisk/pull/787): Set `immutable` cache control directive when serving content-addressed static assets
13−* Use iOS SDK 13.2
14−
15−
16−## v0.9.0.1
17−
18−* ([#810](https://github.com/obsidiansystems/obelisk/pull/810)) Fix loading of `all.js` in fully compiled web apps.
19−
20−## v0.9.0.0
21−
22−* **(Breaking change)** Backport nixpkgs upgrades to ACME/Let's Encrypt handling so that HTTPS deployments continue to work flawlessly. If your deployment is having trouble renewing [Let's Encrypt](https://letsencrypt.org/) certificates, upgrade to this version.
23− * **IMPORTANT:** In order to use [Let's Encrypt](https://letsencrypt.org/) you must now accept their [terms of service](https://letsencrypt.org/repository/). To do that, add `terms.security.acme.acceptTerms = true;` to the `import ./.obelisk/impl {` section in your `default.nix`. The new skeleton application may serve as an [example](https://github.com/obsidiansystems/obelisk/blob/4759342ab3570888c027d4c58cb5694cb832d624/skeleton/default.nix#L13).
24−* Update reflex-platform dependency to v0.6.0.0
25* ([#715](https://github.com/obsidiansystems/obelisk/pull/715)) In `Obelisk.Route` deprecate `isoEncoder` and `prismEncoder` in favor of more precisely named `viewEncoder` and `reviewEncoder` (respectively) and improve documentation regarding contravariance of `reviewEncoder`.
7* ([#715](https://github.com/obsidiansystems/obelisk/pull/715)) In `Obelisk.Route` deprecate `isoEncoder` and `prismEncoder` in favor of more precisely named `viewEncoder` and `reviewEncoder` (respectively) and improve documentation regarding contravariance of `reviewEncoder`.
26* ([#739](https://github.com/obsidiansystems/obelisk/pull/739)) Improve `ob shell` by allowing commands to be passed verbatim after a `--` argument. For example, `ob shell 'run command'` can now be written `ob shell -- run command`.
8* ([#739](https://github.com/obsidiansystems/obelisk/pull/739)) Improve `ob shell` by allowing commands to be passed verbatim after a `--` argument. For example, `ob shell 'run command'` can now be written `ob shell -- run command`.
27* ([#735](https://github.com/obsidiansystems/obelisk/pull/735)) Fix regression causing custom `Prelude`s to break `ob run`/`ob watch`/`ob repl`.
9* ([#735](https://github.com/obsidiansystems/obelisk/pull/735)) Fix regression causing custom `Prelude`s to break `ob run`/`ob watch`/`ob repl`.
README.md+4−7
@@ -13,10 +13,10 @@ Functional reactive web and mobile applications, with batteries included. Obelis
13- [Developing an Obelisk project](#developing-an-obelisk-project)
13- [Developing an Obelisk project](#developing-an-obelisk-project)
14 - [IDE Support](#ide-support)
14 - [IDE Support](#ide-support)
15- [Deploying](#deploying)
15- [Deploying](#deploying)
16+ - [Locally](#locally)
16 - [Default EC2 Deployment](#default-ec2-deployment)
17 - [Default EC2 Deployment](#default-ec2-deployment)
17 - [Custom Non-EC2 Deployment](#custom-non-ec2-deployment)
18 - [Custom Non-EC2 Deployment](#custom-non-ec2-deployment)
18 - [VirtualBox Deployment](#virtualbox-deployment)
19 - [VirtualBox Deployment](#virtualbox-deployment)
19− - [Locally](#locally)
20 - [From macOS](#from-macos)
20 - [From macOS](#from-macos)
21 - [Deploying an updated version](#deploying-an-updated-version)
21 - [Deploying an updated version](#deploying-an-updated-version)
22- [Mobile](#mobile)
22- [Mobile](#mobile)
@@ -66,10 +66,7 @@ Obelisk assumes basic knowledge of [Haskell](https://www.haskell.org/) and [Refl
66 sudo launchctl stop org.nixos.nix-daemon
66 sudo launchctl stop org.nixos.nix-daemon
67 sudo launchctl start org.nixos.nix-daemon
67 sudo launchctl start org.nixos.nix-daemon
68 ```
68 ```
69−1. Install obelisk:
70− ```bash
71− nix-env -f https://github.com/obsidiansystems/obelisk/archive/master.tar.gz -iA command
69+1. Install obelisk: `nix-env -f https://github.com/obsidiansystems/obelisk/archive/master.tar.gz -iA command`
72− ```
73
70
74### Accessing private repositories
71### Accessing private repositories
75
72
@@ -114,7 +111,7 @@ First create a new EC2 instance:
1141. Launch a NixOS 19.09 EC2 instance (we recommend [this AMI](https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-00a8eeaf232a74f84))
1111. Launch a NixOS 19.09 EC2 instance (we recommend [this AMI](https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-00a8eeaf232a74f84))
1151. In the instance configuration wizard ensure that your instance has at least 1GB RAM and 10GB disk space.
1121. In the instance configuration wizard ensure that your instance has at least 1GB RAM and 10GB disk space.
1161. When prompted save your AWS private key (`~/myaws.pem`) somewhere safe. We'll need it later during deployment.
1131. When prompted save your AWS private key (`~/myaws.pem`) somewhere safe. We'll need it later during deployment.
117−1. Go to "Security Groups", select your instance's security group and under "Inbound" tab add a new rule for HTTP port 80 and HTTPS port 443.
114+1. Go to "Security Groups", select your instance's security group and under "Inbound" tab add a new rule for HTTP port 80 and 443.
118
115
119At this stage your instance should be booting and become accessible shortly. Note down the hostname of your EC2 instance.
116At this stage your instance should be booting and become accessible shortly. Note down the hostname of your EC2 instance.
120
117
@@ -221,7 +218,7 @@ Your account must also belong to an Apple Developer Team, if you want to access
2211. Click accept to authorize on both the computer and the iPhone.
2181. Click accept to authorize on both the computer and the iPhone.
222
219
223##### Xcode
220##### Xcode
224−Install Xcode 11.2 (contains iOS SDK 13.2) and open it so that it runs its post install tool setup.
221+Install Xcode 8.2 (contains iOS SDK 10.2) and open it so that it runs its post install tool setup.
225
222
226These versions will work out of the box but iOS SDKs prior to 11.3 should also work. You can choose another installed version in `default.nix`
223These versions will work out of the box but iOS SDKs prior to 11.3 should also work. You can choose another installed version in `default.nix`
227
224
all-builds.nix+1−1
@@ -1,6 +1,6 @@
1{ self-args ? {
1{ self-args ? {
2 config.android_sdk.accept_license = true;
2 config.android_sdk.accept_license = true;
3− iosSdkVersion = "13.2";
3+ iosSdkVersion = "10.2";
4 }
4 }
5, local-self ? import ./. self-args
5, local-self ? import ./. self-args
6, supportedSystems ? [ builtins.currentSystem ]
6, supportedSystems ? [ builtins.currentSystem ]
default.nix+16−29
@@ -1,10 +1,7 @@
1{ system ? builtins.currentSystem
1{ system ? builtins.currentSystem
2, profiling ? false
2, profiling ? false
3−, iosSdkVersion ? "13.2"
3+, iosSdkVersion ? "10.2"
4, config ? {}
4, config ? {}
5−, terms ? { # Accepted terms, conditions, and licenses
6− security.acme.acceptTerms = false;
7− }
8, reflex-platform-func ? import ./dep/reflex-platform
5, reflex-platform-func ? import ./dep/reflex-platform
9}:
6}:
10let
7let
@@ -46,7 +43,7 @@ in rec {
46 pathGit = ./.; # Used in CI by the migration graph hash algorithm to correctly ignore files.
43 pathGit = ./.; # Used in CI by the migration graph hash algorithm to correctly ignore files.
47 path = reflex-platform.filterGit ./.;
44 path = reflex-platform.filterGit ./.;
48 obelisk = ghcObelisk;
45 obelisk = ghcObelisk;
49− obeliskEnvs = pkgs.lib.filterAttrs (k: _: k == "tabulation" || pkgs.lib.strings.hasPrefix "obelisk-" k) ghcObeliskEnvs; #TODO: use thunkSet https://github.com/reflex-frp/reflex-platform/pull/671
46+ obeliskEnvs = pkgs.lib.filterAttrs (k: _: pkgs.lib.strings.hasPrefix "obelisk-" k) ghcObeliskEnvs;
50 command = ghcObelisk.obelisk-command;
47 command = ghcObelisk.obelisk-command;
51 shell = pinBuildInputs "obelisk-shell" ([command] ++ command.commandRuntimeDeps);
48 shell = pinBuildInputs "obelisk-shell" ([command] ++ command.commandRuntimeDeps);
52
49
@@ -77,20 +74,16 @@ in rec {
77 '';
74 '';
78
75
79 compressedJs = frontend: optimizationLevel: pkgs.runCommand "compressedJs" {} ''
76 compressedJs = frontend: optimizationLevel: pkgs.runCommand "compressedJs" {} ''
80− set -euo pipefail
77+ mkdir $out
78+ cd $out
79+ # TODO profiling + static shouldn't break and need an ad-hoc workaround like that
81− cd '${haskellLib.justStaticExecutables frontend}'
80+ ln -s "${haskellLib.justStaticExecutables frontend}/bin/frontend.jsexe/all.js" all.unminified.js
82− shopt -s globstar
83− for f in **/all.js; do
84− dir="$out/$(basename "$(dirname "$f")")"
85− mkdir -p "$dir"
86− ln -s "$(realpath "$f")" "$dir/all.unminified.js"
87− ${if optimizationLevel == null then ''
81+ ${if optimizationLevel == null then ''
88− ln -s "$dir/all.unminified.js" "$dir/all.js"
82+ ln -s all.unminified.js all.js
89− '' else ''
83+ '' else ''
90− '${pkgs.closurecompiler}/bin/closure-compiler' --externs '${reflex-platform.ghcjsExternsJs}' -O '${optimizationLevel}' --jscomp_warning=checkVars --create_source_map="$dir/all.js.map" --source_map_format=V3 --js_output_file="$dir/all.js" "$dir/all.unminified.js"
84+ ${pkgs.closurecompiler}/bin/closure-compiler --externs "${reflex-platform.ghcjsExternsJs}" -O ${optimizationLevel} --jscomp_warning=checkVars --create_source_map="all.js.map" --source_map_format=V3 --js_output_file="all.js" all.unminified.js
91− echo '//# sourceMappingURL=all.js.map' >> "$dir/all.js"
85+ echo "//# sourceMappingURL=all.js.map" >> all.js
92− ''}
86+ ''}
93− done
94 '';
87 '';
95
88
96 serverModules = {
89 serverModules = {
@@ -117,7 +110,7 @@ in rec {
117 "${routeHost}".email = adminEmail;
110 "${routeHost}".email = adminEmail;
118 } else {};
111 } else {};
119
112
120− security.acme.${if enableHttps && (terms.security.acme.acceptTerms or false) then "acceptTerms" else null} = true;
113+ security.acme.${if enableHttps then "acceptTerms" else null} = true;
121 };
114 };
122
115
123 mkObeliskApp =
116 mkObeliskApp =
@@ -134,16 +127,12 @@ in rec {
134 }: {...}: {
127 }: {...}: {
135 services.nginx = {
128 services.nginx = {
136 enable = true;
129 enable = true;
137− recommendedProxySettings = true;
138 virtualHosts."${routeHost}" = {
130 virtualHosts."${routeHost}" = {
139 enableACME = enableHttps;
131 enableACME = enableHttps;
140 forceSSL = enableHttps;
132 forceSSL = enableHttps;
141 locations.${baseUrl} = {
133 locations.${baseUrl} = {
142 proxyPass = "http://127.0.0.1:" + toString internalPort;
134 proxyPass = "http://127.0.0.1:" + toString internalPort;
143 proxyWebsockets = true;
135 proxyWebsockets = true;
144− extraConfig = ''
145− access_log off;
146− '';
147 };
136 };
148 };
137 };
149 };
138 };
@@ -184,11 +173,9 @@ in rec {
184 pkgs.runCommand "serverExe" {} ''
173 pkgs.runCommand "serverExe" {} ''
185 mkdir $out
174 mkdir $out
186 set -eux
175 set -eux
187− ln -s '${if profiling then backend else haskellLib.justStaticExecutables backend}'/bin/* $out/
176+ ln -s "${if profiling then backend else haskellLib.justStaticExecutables backend}"/bin/* $out/
188− ln -s '${mkAssets assets}' $out/static.assets
177+ ln -s "${mkAssets assets}" $out/static.assets
189− for d in '${mkAssets (compressedJs frontend optimizationLevel)}'/*/; do
178+ ln -s ${mkAssets (compressedJs frontend optimizationLevel)} $out/frontend.jsexe.assets
190− ln -s "$d" "$out"/"$(basename "$d").assets"
191− done
192 echo ${version} > $out/version
179 echo ${version} > $out/version
193 '';
180 '';
194
181
dep/reflex-platform/github.json+3−3
@@ -1,8 +1,8 @@
1{
1{
2 "owner": "reflex-frp",
2 "owner": "reflex-frp",
3 "repo": "reflex-platform",
3 "repo": "reflex-platform",
4− "branch": "release/0.7.0.0",
4+ "branch": "develop",
5 "private": false,
5 "private": false,
6− "rev": "27a7851a780ff21472d85f9a02fb84635ef9027a",
6+ "rev": "c21ec7036c8351185cd2feef9ce577b6a61c4f22",
7− "sha256": "1m4zlw91dpjlbdchjyxhvhv3k7lilm0qa17dhhww868xxc27sann"
7+ "sha256": "0m4sdpz6qvngralpyprrbvsyi2zmfh2l3q5vhihwfp3842blvbfg"
8}
8}
haskell-overlays/misc-deps.nix+2−8
@@ -9,14 +9,8 @@ let
9in
9in
10
10
11{
11{
12− regex-base = self.callHackage "regex-base" "0.94.0.0" {};
12+ hnix = haskellLib.dontCheck (haskellLib.doJailbreak (self.callCabal2nix "hnix" (hackGet ../dep/hnix) {}));
13− regex-posix = self.callHackage "regex-posix" "0.96.0.0" {};
14− regex-tdfa = self.callHackage "regex-tdfa" "1.3.1.0" {};
15− test-framework = haskellLib.dontCheck (self.callHackage "test-framework" "0.8.2.0" {});
16− hnix = haskellLib.dontCheck (self.callHackage "hnix" "0.8.0" {});
17− hnix-store-core = self.callHackage "hnix-store-core" "0.2.0.0" {};
13+ hnix-store-core = self.callHackage "hnix-store-core" "0.1.0.0" {};
18−
19− aeson-gadt-th = self.callHackage "aeson-gadt-th" "0.2.4" {};
20
14
21 ghcid = self.callCabal2nix "ghcid" (hackGet ../dep/ghcid) {};
15 ghcid = self.callCabal2nix "ghcid" (hackGet ../dep/ghcid) {};
22 # Exports more internals
16 # Exports more internals
haskell-overlays/obelisk.nix−4
@@ -19,12 +19,8 @@ in
19 obelisk-command = haskellLib.overrideCabal (self.callCabal2nix "obelisk-command" (obeliskCleanSource ../lib/command) {}) {
19 obelisk-command = haskellLib.overrideCabal (self.callCabal2nix "obelisk-command" (obeliskCleanSource ../lib/command) {}) {
20 librarySystemDepends = [
20 librarySystemDepends = [
21 pkgs.jre
21 pkgs.jre
22− pkgs.git
23 pkgs.nix
22 pkgs.nix
24 pkgs.nix-prefetch-git
23 pkgs.nix-prefetch-git
25− pkgs.openssh
26− pkgs.rsync
27− pkgs.which
28 (haskellLib.justStaticExecutables self.ghcid)
24 (haskellLib.justStaticExecutables self.ghcid)
29 ];
25 ];
30 };
26 };
lib/asset/assets.nix+5−28
@@ -20,7 +20,7 @@ zopfliEncodings = file:
20 nixpkgs.stdenv.mkDerivation {
20 nixpkgs.stdenv.mkDerivation {
21 name = "encodings";
21 name = "encodings";
22
22
23− input = mkPath file;
23+ input = file;
24
24
25 builder = builtins.toFile "builder.sh" ''
25 builder = builtins.toFile "builder.sh" ''
26 source "$stdenv/setup"
26 source "$stdenv/setup"
@@ -46,7 +46,7 @@ gzipEncodings = file:
46 nixpkgs.stdenv.mkDerivation {
46 nixpkgs.stdenv.mkDerivation {
47 name = "encodings";
47 name = "encodings";
48
48
49− input = mkPath file;
49+ input = file;
50
50
51 builder = builtins.toFile "builder.sh" ''
51 builder = builtins.toFile "builder.sh" ''
52 source "$stdenv/setup"
52 source "$stdenv/setup"
@@ -70,7 +70,7 @@ noEncodings = file:
70 nixpkgs.stdenv.mkDerivation {
70 nixpkgs.stdenv.mkDerivation {
71 name = "encodings";
71 name = "encodings";
72
72
73− input = mkPath file;
73+ input = file;
74
74
75 builder = builtins.toFile "builder.sh" ''
75 builder = builtins.toFile "builder.sh" ''
76 source "$stdenv/setup"
76 source "$stdenv/setup"
@@ -203,7 +203,7 @@ hashFile = path:
203 nixpkgs.nix
203 nixpkgs.nix
204 ];
204 ];
205 preferLocalBuild = true;
205 preferLocalBuild = true;
206− path = mkPath path;
206+ inherit path;
207 } ''
207 } ''
208 nix-hash --flat --base32 --type sha256 "$path" | tr -d '\n' >"$out"
208 nix-hash --flat --base32 --type sha256 "$path" | tr -d '\n' >"$out"
209 '');
209 '');
@@ -224,30 +224,7 @@ symlink = path: {
224 inherit path;
224 inherit path;
225};
225};
226
226
227−# Tests if a given character (string of length 1) is valid for a derivation path name.
228−# Passing a string of length other than 1 is undefined.
229−# :: Char -> Bool
230−isValidDrvNameChar = c: "a" <= c && c <= "z" || "A" <= c && c <= "Z" || "0" <= c && c <= "9" || c == "+" || c == "-" || c == "_" || c == "?" || c == "=" || c == ".";
231−
232−# Convert a string into a string that could be used in a derivation name.
233−# replacement lets you choose how to replace invalid characters. It may be any length.
234−# If it contains invalid characters then the result will also be invalid.
235−# :: { str :: String, replacement :: String } -> String
236−mkValidDrvName = { str, replacement ? "?" }:
237− let
238− newName = stringAsChars (c: if isValidDrvNameChar c then c else replacement) str;
239− in if builtins.substring 0 1 newName == "." then "_" + newName else newName;
240−
241−# Like builtins.path but always ensures the name is valid.
242−mkPath = path:
243− if builtins.typeOf path == "path" # Don't mess with non-paths
244− then builtins.path {
245− inherit path;
246− name = mkValidDrvName { str = builtins.baseNameOf path; };
247− }
248− else path;
249−
250−# Given an encoding generation function and a file entry resulting from readDirRecursive in the form { name :: String, value: { path :: String } },
227+# Given a encoding generation function and a file entry resulting from readDirRecursive in the form { name :: String, value: { path :: String } },
251# build a DirEntry for dirToPath with the various encodings of the asset for dirToPath to build into a final directory tree.
228# build a DirEntry for dirToPath with the various encodings of the asset for dirToPath to build into a final directory tree.
252mkAsset = encodings: {name, value}:
229mkAsset = encodings: {name, value}:
253 let nameWithHash = "${hashFile value.path}-${name}";
230 let nameWithHash = "${hashFile value.path}-${name}";
lib/asset/manifest/obelisk-asset-manifest.cabal+1−3
@@ -33,9 +33,7 @@ library
33 Obelisk.Asset.TH
33 Obelisk.Asset.TH
34
34
35 other-extensions: TemplateHaskell
35 other-extensions: TemplateHaskell
36− ghc-options:
37− -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O2
38− -fno-warn-unused-do-bind -funbox-strict-fields -fprof-auto-calls
36+ ghc-options: -Wall -Werror -fno-warn-unused-do-bind -fwarn-tabs -funbox-strict-fields -O2 -fprof-auto-calls
39
37
40executable obelisk-asset-manifest-generate
38executable obelisk-asset-manifest-generate
41 hs-source-dirs: src-bin
39 hs-source-dirs: src-bin
lib/asset/serve-snap/obelisk-asset-serve-snap.cabal+1−3
@@ -29,6 +29,4 @@ library
29 Obelisk.Asset.Serve.Snap
29 Obelisk.Asset.Serve.Snap
30
30
31 other-extensions: TemplateHaskell
31 other-extensions: TemplateHaskell
32− ghc-options:
33− -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O2
34− -fno-warn-unused-do-bind -funbox-strict-fields -fprof-auto-calls
32+ ghc-options: -Wall -Werror -fno-warn-unused-do-bind -fwarn-tabs -funbox-strict-fields -O2 -fprof-auto-calls
lib/backend/obelisk-backend.cabal+2−2
@@ -21,10 +21,10 @@ library
21 obelisk-frontend,
21 obelisk-frontend,
22 obelisk-route,
22 obelisk-route,
23 obelisk-snap-extras,
23 obelisk-snap-extras,
24− reflex-dom-core,
24+ reflex-dom,
25 snap,
25 snap,
26 snap-server,
26 snap-server,
27 text,
27 text,
28 universe
28 universe
29 exposed-modules: Obelisk.Backend
29 exposed-modules: Obelisk.Backend
30− ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O
30+ ghc-options: -Wall
lib/backend/src/Obelisk/Backend.hs+1−1
@@ -58,7 +58,7 @@ import qualified Obelisk.ExecutableConfig.Lookup as Lookup
58import Obelisk.Frontend
58import Obelisk.Frontend
59import Obelisk.Route
59import Obelisk.Route
60import Obelisk.Snap.Extras (doNotCache, serveFileIfExistsAs)
60import Obelisk.Snap.Extras (doNotCache, serveFileIfExistsAs)
61−import Reflex.Dom.Core
61+import Reflex.Dom
62import Snap (MonadSnap, Snap, commandLineConfig, defaultConfig, getsRequest, httpServe, modifyResponse
62import Snap (MonadSnap, Snap, commandLineConfig, defaultConfig, getsRequest, httpServe, modifyResponse
63 , rqPathInfo, rqQueryString, setContentType, writeBS, writeText
63 , rqPathInfo, rqQueryString, setContentType, writeBS, writeText
64 , rqCookies, Cookie(..) , setHeader)
64 , rqCookies, Cookie(..) , setHeader)
lib/cliapp/obelisk-cliapp.cabal+1−1
@@ -34,4 +34,4 @@ library
34 Obelisk.CliApp.TerminalString
34 Obelisk.CliApp.TerminalString
35 Obelisk.CliApp.Theme
35 Obelisk.CliApp.Theme
36 Obelisk.CliApp.Types
36 Obelisk.CliApp.Types
37− ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O
37+ ghc-options: -Wall -fobject-code
lib/cliapp/src/Obelisk/CliApp/Logging.hs+2−2
@@ -160,7 +160,7 @@ failWith :: (CliThrow e m, AsUnstructuredError e) => Text -> m a
160failWith = throwError . review asUnstructuredError
160failWith = throwError . review asUnstructuredError
161
161
162errorToWarning
162errorToWarning
163− :: (HasCliConfig e m, CliLog m)
163+ :: (HasCliConfig e m, CliThrow e m, CliLog m)
164 => e -> m ()
164 => e -> m ()
165errorToWarning e = do
165errorToWarning e = do
166 c <- getCliConfig
166 c <- getCliConfig
@@ -177,7 +177,7 @@ withExitFailMessage msg f = f `catch` \(e :: ExitCode) -> do
177 throwM e
177 throwM e
178
178
179-- | Write log to stdout, with colors (unless `noColor`)
179-- | Write log to stdout, with colors (unless `noColor`)
180−writeLog :: (MonadIO m) => Bool -> Bool -> WithSeverity Text -> m ()
180+writeLog :: (MonadIO m, MonadMask m) => Bool -> Bool -> WithSeverity Text -> m ()
181writeLog withNewLine noColor (WithSeverity severity s) = if T.null s then pure () else write
181writeLog withNewLine noColor (WithSeverity severity s) = if T.null s then pure () else write
182 where
182 where
183 write
183 write
lib/cliapp/src/Obelisk/CliApp/Process.hs+7−6
@@ -1,6 +1,7 @@
1{-# LANGUAGE FlexibleContexts #-}
1{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE LambdaCase #-}
2{-# LANGUAGE LambdaCase #-}
3{-# LANGUAGE MultiParamTypeClasses #-}
3{-# LANGUAGE MultiParamTypeClasses #-}
4+{-# LANGUAGE MultiWayIf #-}
4{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE TupleSections #-}
7{-# LANGUAGE TupleSections #-}
@@ -101,7 +102,7 @@ instance AsProcessFailure ProcessFailure where
101 asProcessFailure = id
102 asProcessFailure = id
102
103
103readProcessAndLogStderr
104readProcessAndLogStderr
104− :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadMask m)
105+ :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m, MonadMask m)
105 => Severity -> ProcessSpec -> m Text
106 => Severity -> ProcessSpec -> m Text
106readProcessAndLogStderr sev process = do
107readProcessAndLogStderr sev process = do
107 (out, _err) <- withProcess process $ \_out err -> do
108 (out, _err) <- withProcess process $ \_out err -> do
@@ -109,7 +110,7 @@ readProcessAndLogStderr sev process = do
109 liftIO $ T.decodeUtf8With lenientDecode <$> BS.hGetContents out
110 liftIO $ T.decodeUtf8With lenientDecode <$> BS.hGetContents out
110
111
111readProcessJSONAndLogStderr
112readProcessJSONAndLogStderr
112− :: (Aeson.FromJSON a, MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadMask m)
113+ :: (Aeson.FromJSON a, MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m, MonadMask m)
113 => Severity -> ProcessSpec -> m a
114 => Severity -> ProcessSpec -> m a
114readProcessJSONAndLogStderr sev process = do
115readProcessJSONAndLogStderr sev process = do
115 (out, _err) <- withProcess process $ \_out err -> do
116 (out, _err) <- withProcess process $ \_out err -> do
@@ -122,7 +123,7 @@ readProcessJSONAndLogStderr sev process = do
122 throwError $ review asProcessFailure $ ProcessFailure (Process.cmdspec $ _processSpec_createProcess process) 0
123 throwError $ review asProcessFailure $ ProcessFailure (Process.cmdspec $ _processSpec_createProcess process) 0
123
124
124readCreateProcessWithExitCode
125readCreateProcessWithExitCode
125− :: (MonadIO m, CliLog m)
126+ :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e)
126 => ProcessSpec -> m (ExitCode, String, String)
127 => ProcessSpec -> m (ExitCode, String, String)
127readCreateProcessWithExitCode procSpec = do
128readCreateProcessWithExitCode procSpec = do
128 process <- mkCreateProcess procSpec
129 process <- mkCreateProcess procSpec
@@ -158,7 +159,7 @@ readProcessAndLogOutput (sev_out, sev_err) process = do
158-- which case it is advisable to call it with a non-Error severity for stderr, like
159-- which case it is advisable to call it with a non-Error severity for stderr, like
159-- `callProcessAndLogOutput (Debug, Debug)`.
160-- `callProcessAndLogOutput (Debug, Debug)`.
160callProcessAndLogOutput
161callProcessAndLogOutput
161− :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadMask m)
162+ :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m, MonadMask m)
162 => (Severity, Severity) -> ProcessSpec -> m ()
163 => (Severity, Severity) -> ProcessSpec -> m ()
163callProcessAndLogOutput (sev_out, sev_err) process =
164callProcessAndLogOutput (sev_out, sev_err) process =
164 void $ withProcess process $ \out err -> do
165 void $ withProcess process $ \out err -> do
@@ -211,7 +212,7 @@ callCommand cmd = do
211 liftIO $ Process.callCommand cmd
212 liftIO $ Process.callCommand cmd
212
213
213withProcess
214withProcess
214− :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadMask m)
215+ :: (MonadIO m, CliLog m, CliThrow e m, AsProcessFailure e, MonadFail m, MonadMask m)
215 => ProcessSpec -> (Handle -> Handle -> m ()) -> m (Handle, Handle)
216 => ProcessSpec -> (Handle -> Handle -> m ()) -> m (Handle, Handle)
216withProcess process f =
217withProcess process f =
217 bracketOnError
218 bracketOnError
@@ -228,7 +229,7 @@ withProcess process f =
228
229
229-- | Runs a process to completion failing if it does not exit cleanly.
230-- | Runs a process to completion failing if it does not exit cleanly.
230runProcess_
231runProcess_
231− :: (MonadIO m, CliLog m, CliThrow e m, MonadMask m, AsProcessFailure e)
232+ :: (MonadIO m, CliLog m, CliThrow e m, MonadMask m, AsProcessFailure e, MonadFail m)
232 => ProcessSpec -> m ()
233 => ProcessSpec -> m ()
233runProcess_ process =
234runProcess_ process =
234 bracketOnError
235 bracketOnError
lib/command/obelisk-command.cabal+2−2
@@ -1,5 +1,5 @@
1name: obelisk-command
1name: obelisk-command
2−version: 0.9.0.1
2+version: 0.8.0.0
3cabal-version: >= 1.8
3cabal-version: >= 1.8
4build-type: Simple
4build-type: Simple
5
5
@@ -66,4 +66,4 @@ library
66executable ob
66executable ob
67 main-is: src-bin/ob.hs
67 main-is: src-bin/ob.hs
68 build-depends: base, obelisk-command
68 build-depends: base, obelisk-command
69− ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -threaded
69+ ghc-options: -Wall -O2 -threaded
lib/command/src/Obelisk/Command/Deploy.hs+15−15
@@ -85,12 +85,13 @@ deployInit' thunkPtr (DeployInitOpts deployDir sshKeyPath hostnames route adminE
85 --accidentally create a production deployment that uses development
85 --accidentally create a production deployment that uses development
86 --credentials to connect to some resources. This could result in, e.g.,
86 --credentials to connect to some resources. This could result in, e.g.,
87 --production data backed up to a dev environment.
87 --production data backed up to a dev environment.
88− withSpinner "Creating project configuration directories" $ liftIO $ do
88+ withSpinner "Creating project configuration directories" $ do
89− mapM_ (createDirectoryIfMissing True)
89+ callProcessAndLogOutput (Notice, Error) $
90+ proc "mkdir" [ "-p"
90− [ deployDir </> "config" </> "backend"
91+ , deployDir </> "config" </> "backend"
91− , deployDir </> "config" </> "common"
92+ , deployDir </> "config" </> "common"
92− , deployDir </> "config" </> "frontend"
93+ , deployDir </> "config" </> "frontend"
93− ]
94+ ]
94
95
95 let srcDir = deployDir </> "src"
96 let srcDir = deployDir </> "src"
96 withSpinner ("Creating source thunk (" <> T.pack (makeRelative deployDir srcDir) <> ")") $ do
97 withSpinner ("Creating source thunk (" <> T.pack (makeRelative deployDir srcDir) <> ")") $ do
@@ -161,8 +162,8 @@ deployPush deployPath getNixBuilders = do
161 "nix-copy-closure" ["-v", "--to", "--use-substitutes", "root@" <> host, "--gzip", outputPath]
162 "nix-copy-closure" ["-v", "--to", "--use-substitutes", "root@" <> host, "--gzip", outputPath]
162 withSpinner "Uploading config" $ ifor_ buildOutputByHost $ \host _ -> do
163 withSpinner "Uploading config" $ ifor_ buildOutputByHost $ \host _ -> do
163 callProcessAndLogOutput (Notice, Warning) $
164 callProcessAndLogOutput (Notice, Warning) $
164− proc rsyncPath
165+ proc "rsync"
165− [ "-e " <> sshPath <> " " <> unwords sshOpts
166+ [ "-e ssh " <> unwords sshOpts
166 , "-qarvz"
167 , "-qarvz"
167 , deployPath </> "config"
168 , deployPath </> "config"
168 , "root@" <> host <> ":/var/lib/backend"
169 , "root@" <> host <> ":/var/lib/backend"
@@ -170,10 +171,9 @@ deployPush deployPath getNixBuilders = do
170 --TODO: Create GC root so we're sure our closure won't go away during this time period
171 --TODO: Create GC root so we're sure our closure won't go away during this time period
171 withSpinner "Switching to new configuration" $ ifor_ buildOutputByHost $ \host outputPath -> do
172 withSpinner "Switching to new configuration" $ ifor_ buildOutputByHost $ \host outputPath -> do
172 callProcessAndLogOutput (Notice, Warning) $
173 callProcessAndLogOutput (Notice, Warning) $
173− proc sshPath $ sshOpts <>
174+ proc "ssh" $ sshOpts <>
174 [ "root@" <> host
175 [ "root@" <> host
175 , unwords
176 , unwords
176− -- Note that we don't want to $(staticWhich "nix-env") here, because this is executing on a remote machine
177 [ "nix-env -p /nix/var/nix/profiles/system --set " <> outputPath
177 [ "nix-env -p /nix/var/nix/profiles/system --set " <> outputPath
178 , "&&"
178 , "&&"
179 , "/nix/var/nix/profiles/system/bin/switch-to-configuration switch"
179 , "/nix/var/nix/profiles/system/bin/switch-to-configuration switch"
@@ -182,10 +182,10 @@ deployPush deployPath getNixBuilders = do
182 isClean <- checkGitCleanStatus deployPath True
182 isClean <- checkGitCleanStatus deployPath True
183 when (not isClean) $ do
183 when (not isClean) $ do
184 withSpinner "Committing changes to Git" $ do
184 withSpinner "Committing changes to Git" $ do
185− callProcessAndLogOutput (Debug, Error) $
185+ callProcessAndLogOutput (Debug, Error) $ proc "git"
186− gitProc deployPath ["add", "."]
186+ ["-C", deployPath, "add", "."]
187− callProcessAndLogOutput (Debug, Error) $
187+ callProcessAndLogOutput (Debug, Error) $ proc "git"
188− gitProc deployPath ["commit", "-m", "New deployment"]
188+ ["-C", deployPath, "commit", "-m", "New deployment"]
189 putLog Notice $ "Deployed => " <> T.pack route
189 putLog Notice $ "Deployed => " <> T.pack route
190 where
190 where
191 callProcess' envMap cmd args = do
191 callProcess' envMap cmd args = do
@@ -315,7 +315,7 @@ readDeployConfig deployDir fname = liftIO $ do
315
315
316verifyHostKey :: MonadObelisk m => FilePath -> FilePath -> String -> m ()
316verifyHostKey :: MonadObelisk m => FilePath -> FilePath -> String -> m ()
317verifyHostKey knownHostsPath keyPath hostName =
317verifyHostKey knownHostsPath keyPath hostName =
318− callProcessAndLogOutput (Notice, Warning) $ proc sshPath $
318+ callProcessAndLogOutput (Notice, Warning) $ proc "ssh" $
319 sshArgs knownHostsPath keyPath True <>
319 sshArgs knownHostsPath keyPath True <>
320 [ "root@" <> hostName
320 [ "root@" <> hostName
321 , "-o", "NumberOfPasswordPrompts=0"
321 , "-o", "NumberOfPasswordPrompts=0"
lib/command/src/Obelisk/Command/Preprocessor.hs+47−52
@@ -5,7 +5,6 @@ module Obelisk.Command.Preprocessor where
5
5
6import qualified Data.ByteString.Lazy as BL
6import qualified Data.ByteString.Lazy as BL
7import qualified Data.ByteString.Lazy.Builder as BU
7import qualified Data.ByteString.Lazy.Builder as BU
8−import Data.Foldable (for_)
9import Data.List (intersperse, isPrefixOf, sortOn)
8import Data.List (intersperse, isPrefixOf, sortOn)
10import Data.Maybe (fromMaybe)
9import Data.Maybe (fromMaybe)
11import qualified Data.Text.Lazy.Builder as TL
10import qualified Data.Text.Lazy.Builder as TL
@@ -18,83 +17,79 @@ import System.FilePath (hasTrailingPathSeparator, joinPath, splitPath)
18
17
19import Obelisk.Command.Run (CabalPackageInfo (..), parseCabalPackage')
18import Obelisk.Command.Run (CabalPackageInfo (..), parseCabalPackage')
20
19
21−-- | This code is intended to be executed via ghci's -pgmF preprocessor option.
22−-- The command line arguments are passed in via ghc, which dictates the first three options and meanings
23−-- In order for this code to execute, origPath must contain either a '.' character or a '/' character.
24−-- (This is to avoid the possibility of the command line syntax conflicting with another ob command)
25−-- We do have control over the remaining arguments, but they must be the same for all files.
26−-- Thus, the fourth command line argument must be "apply-packages", which has already been handled.
27−-- We assume all the remaining arguments passed in are paths to cabal or hpack package specifications.
28−-- Thus we must select among the packagePaths for the file we are going to parse.
29applyPackages :: FilePath -> FilePath -> FilePath -> [FilePath] -> IO ()
20applyPackages :: FilePath -> FilePath -> FilePath -> [FilePath] -> IO ()
30−applyPackages origPath inPath outPath packagePaths' = do
21+applyPackages origPath inPath outPath packagePaths' = withFile outPath WriteMode $ \outFile -> do
22+ -- This code is intended to be executed via ghci's -pgmF preprocessor option
23+ -- The command line arguments are passed in via ghc, which dictates the first three options and meanings
24+ -- In order for this code to execute, origPath must contain either a '.' character or a '/' character.
25+ -- (This is to avoid the possibility of the command line syntax conflicting with another ob command)
26+ -- We do have control over the remaining arguments, but they must be the same for all files.
27+ -- Thus, the fourth command line argument must be "apply-packages", which has already been handled.
28+ -- We assume all the remaining arguments passed in are paths to cabal or hpack package specifications.
29+ -- Thus we must select among the packagePaths for the file we are going to parse.
30+
31 origPathCanonical <- canonicalizePath origPath
31 origPathCanonical <- canonicalizePath origPath
32 packagePaths <- traverse canonicalizePath packagePaths'
32 packagePaths <- traverse canonicalizePath packagePaths'
33
33
34− let
35− takeDirs = takeWhile hasTrailingPathSeparator
34+ let takeDirs = takeWhile hasTrailingPathSeparator
36− packageDirs = sortOn (negate . length . takeDirs) $ map splitPath packagePaths
35+ packageDirs = sortOn (negate . length . takeDirs) $ map splitPath packagePaths
37− origDir = splitPath origPathCanonical
36+ origDir = splitPath origPathCanonical
38− matches = [ joinPath d | d <- packageDirs, takeDirs d `isPrefixOf` origDir ]
37+ matches = [ joinPath d | d <- packageDirs, takeDirs d `isPrefixOf` origDir ]
39
38
40− -- The first element of matches is going to be the deepest path to a package spec that contains
39+ -- So the first element of matches is going to be the deepest path to a package spec that contains
41 -- our file as a subdirectory.
40 -- our file as a subdirectory.
41+
42− packageInfo' <- case matches of
42+ case matches of
43− [] -> do
43+ [] ->
44 hPutStrLn stderr $ "Error: Unable to find cabal information for " <> origPath <> "; Skipping preprocessor."
44 hPutStrLn stderr $ "Error: Unable to find cabal information for " <> origPath <> "; Skipping preprocessor."
45− pure Nothing
45+ packagePath:_ -> do
46− packagePath:_ -> parseCabalPackage' packagePath >>= \case
46+ parseCabalPackage' packagePath >>= \case
47− Left err -> do
47+ Left err ->
48− hPutStrLn stderr $ "Error: Unable to parse cabal package " <> packagePath <> "; Skipping preprocessor on " <> origPath <> ". Error: " <> show err
48+ hPutStrLn stderr $ "Error: Unable to parse cabal package " <> packagePath <> "; Skipping preprocessor on " <> origPath <> ". Error: " <> show err
49− pure Nothing
50− Right (Just (_, packageInfo)) -> pure $ Just packageInfo
49+ Right (_warnings, packageInfo) ->
51− Right Nothing -> pure Nothing
50+ hPutTextBuilder outFile (generateHeader origPath packageInfo)
52
51
53− writeOutput packageInfo' inPath outPath
52+ BL.readFile inPath >>= BL.hPut outFile
54
53
55−writeOutput :: Maybe CabalPackageInfo -> FilePath -> FilePath -> IO ()
56−writeOutput packageInfo' origPath outPath = withFile outPath WriteMode $ \hOut -> do
57− for_ packageInfo' $ \packageInfo -> hPutTextBuilder hOut (generateHeader origPath packageInfo)
58− BL.readFile origPath >>= BL.hPut hOut
59 where
54 where
60 hPutTextBuilder h = BU.hPutBuilder h . TL.encodeUtf8Builder . TL.toLazyText
55 hPutTextBuilder h = BU.hPutBuilder h . TL.encodeUtf8Builder . TL.toLazyText
61
56
57+
58+ -- I'm pretty sure there's a certain amount of oversimplification in CabalPackageInfo, so I doubt this is fully robust.
59+
62generateHeader :: FilePath -> CabalPackageInfo -> TL.Builder
60generateHeader :: FilePath -> CabalPackageInfo -> TL.Builder
63generateHeader origPath packageInfo =
61generateHeader origPath packageInfo =
64 hsExtensions <> ghcOptions <> lineNumberPragma origPath
62 hsExtensions <> ghcOptions <> lineNumberPragma origPath
65 where
63 where
66 hsExtensions =
64 hsExtensions =
67− if null extList
65+ if not (null extList)
68− then mempty
66+ then TL.fromText "{-# LANGUAGE "
69− else pragma $ TL.fromText "LANGUAGE " <> mconcat (intersperse (TL.fromText ", ") extList)
67+ <> mconcat (intersperse (TL.fromText ", ") extList)
68+ <> TL.fromText " #-}\n"
69+ else mempty
70 extList = addDefaultLanguage $ concatMap showExt $ _cabalPackageInfo_defaultExtensions packageInfo
70 extList = addDefaultLanguage $ concatMap showExt $ _cabalPackageInfo_defaultExtensions packageInfo
71 addDefaultLanguage =
71 addDefaultLanguage =
72 case _cabalPackageInfo_defaultLanguage packageInfo of
72 case _cabalPackageInfo_defaultLanguage packageInfo of
73 Nothing -> id
73 Nothing -> id
74 Just x -> case x of
74 Just x -> case x of
75− UnknownLanguage ext -> (TL.fromString ext :)
75+ UnknownLanguage ext -> ( TL.fromString ext :)
76− ext -> (TL.fromString (show ext) :)
76+ ext -> ( TL.fromString (show ext) :)
77 showExt = \case
77 showExt = \case
78 EnableExtension ext -> [TL.fromString (show ext)]
78 EnableExtension ext -> [TL.fromString (show ext)]
79− DisableExtension ext -> ["No" <> TL.fromString (show ext)]
79+ DisableExtension _ -> []
80 UnknownExtension ext -> [TL.fromString ext]
80 UnknownExtension ext -> [TL.fromString ext]
81
81
82 ghcOptions =
82 ghcOptions =
83− if null optList
83+ if not (null optList)
84− then mempty
84+ then TL.fromText "{-# OPTIONS_GHC "
85− else pragma $
86− TL.fromText "OPTIONS_GHC " <> mconcat (intersperse (TL.fromText " ") (map TL.fromString optList))
85+ <> mconcat (intersperse (TL.fromText " ") optList)
87− ghcOptList
86+ <> TL.fromText " #-}\n"
87+ else mempty
88+ optList = map TL.fromString
88− = filter (not . isPrefixOf "-O")
89+ $ filter (not . isPrefixOf "-O")
89− $ fromMaybe []
90+ $ fromMaybe []
90− $ lookup GHC (_cabalPackageInfo_compilerOptions packageInfo)
91+ $ lookup GHC (_cabalPackageInfo_compilerOptions packageInfo)
91− optList = _cabalPackageInfo_cppOptions packageInfo <> ghcOptList
92
92
93lineNumberPragma :: FilePath -> TL.Builder
93lineNumberPragma :: FilePath -> TL.Builder
94+lineNumberPragma origPath =
94−lineNumberPragma origPath = pragma $ TL.fromText "LINE 1 " <> quoted '"' (TL.fromString origPath)
95+ TL.fromText "{-# LINE 1 \"" <> TL.fromString origPath <> TL.fromText "\" #-}\n"
95−
96−pragma :: TL.Builder -> TL.Builder
97−pragma x = TL.fromText "{-# " <> x <> TL.fromText " #-}\n"
98−
99−quoted :: Char -> TL.Builder -> TL.Builder
100−quoted char x = TL.singleton char <> x <> TL.singleton char
lib/command/src/Obelisk/Command/Project.hs+4−10
@@ -51,7 +51,7 @@ import Obelisk.App (MonadObelisk)
51import Obelisk.CliApp
51import Obelisk.CliApp
52import Obelisk.Command.Nix
52import Obelisk.Command.Nix
53import Obelisk.Command.Thunk
53import Obelisk.Command.Thunk
54−import Obelisk.Command.Utils (nixBuildExePath, nixExePath, toNixPath, cp, nixShellPath)
54+import Obelisk.Command.Utils (nixBuildExePath, nixExePath, toNixPath)
55
55
56--TODO: Make this module resilient to random exceptions
56--TODO: Make this module resilient to random exceptions
57
57
@@ -116,7 +116,7 @@ initProject source force = withSystemTempDirectory "ob-init" $ \tmpDir -> do
116 skel <- nixBuildAttrWithCache implDir "skeleton" --TODO: I don't think there's actually any reason to cache this
116 skel <- nixBuildAttrWithCache implDir "skeleton" --TODO: I don't think there's actually any reason to cache this
117
117
118 callProcessAndLogOutput (Notice, Error) $
118 callProcessAndLogOutput (Notice, Error) $
119− proc cp
119+ proc "cp"
120 [ "-r"
120 [ "-r"
121 , "--preserve=links"
121 , "--preserve=links"
122 , obDir
122 , obDir
@@ -126,7 +126,7 @@ initProject source force = withSystemTempDirectory "ob-init" $ \tmpDir -> do
126
126
127 withSpinner "Copying project skeleton" $ do
127 withSpinner "Copying project skeleton" $ do
128 callProcessAndLogOutput (Notice, Error) $
128 callProcessAndLogOutput (Notice, Error) $
129− proc cp
129+ proc "cp"
130 [ "-r"
130 [ "-r"
131 , "--no-preserve=mode"
131 , "--no-preserve=mode"
132 , "-T"
132 , "-T"
@@ -137,12 +137,6 @@ initProject source force = withSystemTempDirectory "ob-init" $ \tmpDir -> do
137 let configDir = "config"
137 let configDir = "config"
138 createDirectoryIfMissing False configDir
138 createDirectoryIfMissing False configDir
139 mapM_ (createDirectoryIfMissing False . (configDir </>)) ["backend", "common", "frontend"]
139 mapM_ (createDirectoryIfMissing False . (configDir </>)) ["backend", "common", "frontend"]
140− putLog Notice $ T.intercalate "\n"
141− [ "An obelisk project has been successfully initialized. Next steps:"
142− , " 'ob run': Start a development server"
143− , " 'ob watch': Watch for changes without starting a server"
144− , " 'ob repl': Load your project into GHCi"
145− ]
146
140
147callHandoffOb
141callHandoffOb
148 :: MonadObelisk m
142 :: MonadObelisk m
@@ -298,7 +292,7 @@ bashEscape :: String -> String
298bashEscape = BSU.toString . bytes . bash . BSU.fromString
292bashEscape = BSU.toString . bytes . bash . BSU.fromString
299
293
300nixShellRunProc :: NixShellConfig -> ProcessSpec
294nixShellRunProc :: NixShellConfig -> ProcessSpec
301−nixShellRunProc cfg = setDelegateCtlc True $ proc nixShellPath $ runNixShellConfig cfg
295+nixShellRunProc cfg = setDelegateCtlc True $ proc "nix-shell" $ runNixShellConfig cfg
302
296
303nixShellWithoutPkgs
297nixShellWithoutPkgs
304 :: MonadObelisk m
298 :: MonadObelisk m
lib/command/src/Obelisk/Command/Run.hs+12−13
@@ -14,7 +14,7 @@ module Obelisk.Command.Run where
14import Control.Arrow ((&&&))
14import Control.Arrow ((&&&))
15import Control.Exception (Exception, bracket)
15import Control.Exception (Exception, bracket)
16import Control.Lens (ifor, (.~), (&))
16import Control.Lens (ifor, (.~), (&))
17−import Control.Monad (filterM)
17+import Control.Monad (filterM, unless)
18import Control.Monad.Except (runExceptT, throwError)
18import Control.Monad.Except (runExceptT, throwError)
19import Control.Monad.IO.Class (liftIO)
19import Control.Monad.IO.Class (liftIO)
20import Control.Monad.Reader (MonadIO)
20import Control.Monad.Reader (MonadIO)
@@ -46,7 +46,7 @@ import Distribution.Compiler (CompilerFlavor(..))
46import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
46import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
47import Distribution.Parsec.ParseResult (runParseResult)
47import Distribution.Parsec.ParseResult (runParseResult)
48import qualified Distribution.System as Dist
48import qualified Distribution.System as Dist
49−import Distribution.Types.BuildInfo (buildable, cppOptions, defaultExtensions, defaultLanguage, hsSourceDirs, options)
49+import Distribution.Types.BuildInfo (buildable, defaultExtensions, defaultLanguage, hsSourceDirs, options)
50import Distribution.Types.CondTree (simplifyCondTree)
50import Distribution.Types.CondTree (simplifyCondTree)
51import Distribution.Types.GenericPackageDescription (ConfVar (Arch, Impl, OS), condLibrary)
51import Distribution.Types.GenericPackageDescription (ConfVar (Arch, Impl, OS), condLibrary)
52import Distribution.Types.Library (libBuildInfo)
52import Distribution.Types.Library (libBuildInfo)
@@ -94,8 +94,6 @@ data CabalPackageInfo = CabalPackageInfo
94 -- ^ List of globally set languages of the library component
94 -- ^ List of globally set languages of the library component
95 , _cabalPackageInfo_compilerOptions :: [(CompilerFlavor, [String])]
95 , _cabalPackageInfo_compilerOptions :: [(CompilerFlavor, [String])]
96 -- ^ List of compiler-specific options (e.g., the "ghc-options" field of the cabal file)
96 -- ^ List of compiler-specific options (e.g., the "ghc-options" field of the cabal file)
97− , _cabalPackageInfo_cppOptions :: [String]
98− -- ^ List of CPP (C Preprocessor) options (e.g. the "cpp-options" field of the cabal file)
99 }
97 }
100
98
101-- | 'Bool' with a better name for its purpose.
99-- | 'Bool' with a better name for its purpose.
@@ -304,16 +302,15 @@ parseCabalPackage
304 -> m (Maybe CabalPackageInfo)
302 -> m (Maybe CabalPackageInfo)
305parseCabalPackage dir = parseCabalPackage' dir >>= \case
303parseCabalPackage dir = parseCabalPackage' dir >>= \case
306 Left err -> Nothing <$ putLog Error err
304 Left err -> Nothing <$ putLog Error err
307− Right (Just (warnings, pkgInfo)) -> do
305+ Right (warnings, pkgInfo) -> do
308 for_ warnings $ putLog Warning . T.pack . show
306 for_ warnings $ putLog Warning . T.pack . show
309 pure $ Just pkgInfo
307 pure $ Just pkgInfo
310− Right Nothing -> pure Nothing
311
308
312-- | Like 'parseCabalPackage' but returns errors and warnings directly so as to avoid 'MonadObelisk'.
309-- | Like 'parseCabalPackage' but returns errors and warnings directly so as to avoid 'MonadObelisk'.
313parseCabalPackage'
310parseCabalPackage'
314 :: (MonadIO m)
311 :: (MonadIO m)
315 => FilePath -- ^ Package directory
312 => FilePath -- ^ Package directory
316− -> m (Either T.Text (Maybe ([Dist.PWarning], CabalPackageInfo)))
313+ -> m (Either T.Text ([Dist.PWarning], CabalPackageInfo))
317parseCabalPackage' pkg = runExceptT $ do
314parseCabalPackage' pkg = runExceptT $ do
318 (cabalContents, packageFile, packageName) <- guessCabalPackageFile pkg >>= \case
315 (cabalContents, packageFile, packageName) <- guessCabalPackageFile pkg >>= \case
319 Left GuessPackageFileError_NotFound -> throwError $ "No .cabal or package.yaml file found in " <> T.pack pkg
316 Left GuessPackageFileError_NotFound -> throwError $ "No .cabal or package.yaml file found in " <> T.pack pkg
@@ -341,7 +338,7 @@ parseCabalPackage' pkg = runExceptT $ do
341 case condLibrary <$> result of
338 case condLibrary <$> result of
342 Right (Just condLib) -> do
339 Right (Just condLib) -> do
343 let (_, lib) = simplifyCondTree evalConfVar condLib
340 let (_, lib) = simplifyCondTree evalConfVar condLib
344− pure $ Just $ (warnings,) $ CabalPackageInfo
341+ pure $ (warnings,) $ CabalPackageInfo
345 { _cabalPackageInfo_packageName = T.pack packageName
342 { _cabalPackageInfo_packageName = T.pack packageName
346 , _cabalPackageInfo_packageFile = packageFile
343 , _cabalPackageInfo_packageFile = packageFile
347 , _cabalPackageInfo_packageRoot = takeDirectory packageFile
344 , _cabalPackageInfo_packageRoot = takeDirectory packageFile
@@ -353,19 +350,18 @@ parseCabalPackage' pkg = runExceptT $ do
353 , _cabalPackageInfo_defaultLanguage =
350 , _cabalPackageInfo_defaultLanguage =
354 defaultLanguage $ libBuildInfo lib
351 defaultLanguage $ libBuildInfo lib
355 , _cabalPackageInfo_compilerOptions = options $ libBuildInfo lib
352 , _cabalPackageInfo_compilerOptions = options $ libBuildInfo lib
356− , _cabalPackageInfo_cppOptions = cppOptions $ libBuildInfo lib
357 }
353 }
358− Right Nothing -> pure Nothing
354+ Right Nothing -> throwError "Haskell package has no library component"
359 Left (_, errors) ->
355 Left (_, errors) ->
360 throwError $ T.pack $ "Failed to parse " <> packageFile <> ":\n" <> unlines (map show errors)
356 throwError $ T.pack $ "Failed to parse " <> packageFile <> ":\n" <> unlines (map show errors)
361
357
362parsePackagesOrFail :: (MonadObelisk m, Foldable f) => f FilePath -> m (NE.NonEmpty CabalPackageInfo)
358parsePackagesOrFail :: (MonadObelisk m, Foldable f) => f FilePath -> m (NE.NonEmpty CabalPackageInfo)
363parsePackagesOrFail dirs' = do
359parsePackagesOrFail dirs' = do
364− packageInfos' <- fmap catMaybes $ for dirs $ \dir -> do
360+ (pkgDirErrs, packageInfos') <- fmap partitionEithers $ for dirs $ \dir -> do
365 flip fmap (parseCabalPackage dir) $ \case
361 flip fmap (parseCabalPackage dir) $ \case
366 Just packageInfo
362 Just packageInfo
367− | _cabalPackageInfo_buildable packageInfo -> Just packageInfo
363+ | _cabalPackageInfo_buildable packageInfo -> Right packageInfo
368− _ -> Nothing
364+ _ -> Left dir
369
365
370 -- Sort duplicate packages such that we prefer shorter paths, but fall back to alphabetical ordering.
366 -- Sort duplicate packages such that we prefer shorter paths, but fall back to alphabetical ordering.
371 let packagesByName = Map.map (NE.sortBy $ comparing $ \p -> let n = _cabalPackageInfo_packageFile p in (length n, n))
367 let packagesByName = Map.map (NE.sortBy $ comparing $ \p -> let n = _cabalPackageInfo_packageFile p in (length n, n))
@@ -387,6 +383,9 @@ parsePackagesOrFail dirs' = do
387 "No valid, buildable packages found" <> (if null dirs then "" else " in " <> intercalate ", " dirs)
383 "No valid, buildable packages found" <> (if null dirs then "" else " in " <> intercalate ", " dirs)
388 Just xs -> pure xs
384 Just xs -> pure xs
389
385
386+ unless (null pkgDirErrs) $
387+ putLog Warning $ T.pack $ "Failed to find buildable packages in " <> intercalate ", " pkgDirErrs
388+
390 pure packageInfos
389 pure packageInfos
391 where
390 where
392 dirs = toList dirs'
391 dirs = toList dirs'
lib/command/src/Obelisk/Command/Utils.hs+2−28
@@ -60,32 +60,6 @@ nixPrefetchGitPath = $(staticWhich "nix-prefetch-git")
60nixPrefetchUrlPath :: FilePath
60nixPrefetchUrlPath :: FilePath
61nixPrefetchUrlPath = $(staticWhich "nix-prefetch-url")
61nixPrefetchUrlPath = $(staticWhich "nix-prefetch-url")
62
62
63−nixShellPath :: FilePath
64−nixShellPath = $(staticWhich "nix-shell")
65−
66−rsyncPath :: FilePath
67−rsyncPath = $(staticWhich "rsync")
68−
69−sshPath :: FilePath
70−sshPath = $(staticWhich "ssh")
71−
72−gitPath :: FilePath
73−gitPath = $(staticWhich "git")
74−
75−whichPath :: FilePath
76−whichPath = $(staticWhich "which")
77−
78−sshKeygenPath :: FilePath
79−sshKeygenPath = $(staticWhich "ssh-keygen")
80−
81−-- $(staticWhich "docker") was intentionally omitted, at least for now
82−-- One concern is that I don't know how particular docker is about having the
83−-- CLI exe match the version of the docker daemon, which is largely outside of
84−-- the control of obelisk-command.
85−-- TODO: Investigate the tradeoffs associated with this choice
86−dockerPath :: FilePath
87−dockerPath = "docker"
88−
89-- | Nix syntax requires relative paths to be prefixed by @./@ or
63-- | Nix syntax requires relative paths to be prefixed by @./@ or
90-- @../@. This will make a 'FilePath' that can be embedded in a Nix
64-- @../@. This will make a 'FilePath' that can be embedded in a Nix
91-- expression.
65-- expression.
@@ -123,7 +97,7 @@ initGit repo = do
123 git ["commit", "-m", "Initial commit."]
97 git ["commit", "-m", "Initial commit."]
124
98
125gitProcNoRepo :: [String] -> ProcessSpec
99gitProcNoRepo :: [String] -> ProcessSpec
126−gitProcNoRepo args = setEnvOverride (M.singleton "GIT_TERMINAL_PROMPT" "0" <>) $ proc gitPath args
100+gitProcNoRepo args = setEnvOverride (M.singleton "GIT_TERMINAL_PROMPT" "0" <>) $ proc "git" args
127
101
128gitProc :: FilePath -> [String] -> ProcessSpec
102gitProc :: FilePath -> [String] -> ProcessSpec
129gitProc repo = gitProcNoRepo . runGitInDir
103gitProc repo = gitProcNoRepo . runGitInDir
@@ -140,7 +114,7 @@ isolateGitProc = setEnvOverride (overrides <>)
140 , ("GIT_CONFIG_NOSYSTEM", "1")
114 , ("GIT_CONFIG_NOSYSTEM", "1")
141 , ("GIT_TERMINAL_PROMPT", "0") -- git 2.3+
115 , ("GIT_TERMINAL_PROMPT", "0") -- git 2.3+
142 , ("GIT_ASKPASS", "echo") -- pre git 2.3 to just use empty password
116 , ("GIT_ASKPASS", "echo") -- pre git 2.3 to just use empty password
143− , ("GIT_SSH_COMMAND", "ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no -o GSSAPIAuthentication=no")
117+ , ("GIT_SSH_COMMAND", "ssh -o PreferredAuthentications password -o PubkeyAuthentication no -o GSSAPIAuthentication no")
144 ]
118 ]
145
119
146-- | Recursively copy a directory using `cp -a` -- TODO: Should use -rT instead of -a
120-- | Recursively copy a directory using `cp -a` -- TODO: Should use -rT instead of -a
lib/command/src/Obelisk/Command/VmBuilder.hs+8−8
@@ -21,7 +21,7 @@ import qualified System.Info
21
21
22import Obelisk.App (MonadObelisk, getObeliskUserStateDir)
22import Obelisk.App (MonadObelisk, getObeliskUserStateDir)
23import Obelisk.CliApp
23import Obelisk.CliApp
24−import Obelisk.Command.Utils (rmPath, whichPath, sshKeygenPath, nixBuildExePath, dockerPath)
24+import Obelisk.Command.Utils (rmPath)
25
25
26-- | Generate the `--builders` argument string to enable the VM builder after ensuring it is available.
26-- | Generate the `--builders` argument string to enable the VM builder after ensuring it is available.
27getNixBuildersArg :: MonadObelisk m => m String
27getNixBuildersArg :: MonadObelisk m => m String
@@ -35,7 +35,7 @@ getNixBuildersArg = do
35
35
36checkForNixDarwin :: MonadObelisk m => String -> m ()
36checkForNixDarwin :: MonadObelisk m => String -> m ()
37checkForNixDarwin sshIdFile = do
37checkForNixDarwin sshIdFile = do
38− (exitCode, _, _) <- readCreateProcessWithExitCode $ proc whichPath ["darwin-rebuild"]
38+ (exitCode, _, _) <- readCreateProcessWithExitCode $ proc "which" ["darwin-rebuild"]
39 unless (exitCode == ExitSuccess) $ failWith $ T.intercalate "\n"
39 unless (exitCode == ExitSuccess) $ failWith $ T.intercalate "\n"
40 [ "Deployments from macOS require nix-darwin to be installed."
40 [ "Deployments from macOS require nix-darwin to be installed."
41 , "Follow the installation instructions here: https://github.com/LnL7/nix-darwin"
41 , "Follow the installation instructions here: https://github.com/LnL7/nix-darwin"
@@ -67,7 +67,7 @@ containerExists :: MonadObelisk m => FilePath -> m Bool
67containerExists stateDir = handle (\(_ :: IOError) -> failWith needDockerMsg) $ do
67containerExists stateDir = handle (\(_ :: IOError) -> failWith needDockerMsg) $ do
68 containerNames <- fmap (map T.strip . T.lines) $
68 containerNames <- fmap (map T.strip . T.lines) $
69 readProcessAndLogStderr Error $
69 readProcessAndLogStderr Error $
70− proc dockerPath ["container", "list", "--all", "--format", "{{.Names}}"]
70+ proc "docker" ["container", "list", "--all", "--format", "{{.Names}}"]
71 let exists = containerName `elem` containerNames
71 let exists = containerName `elem` containerNames
72 when exists $ testLinuxBuild stateDir
72 when exists $ testLinuxBuild stateDir
73 pure exists
73 pure exists
@@ -85,7 +85,7 @@ containerSshPort = 2222
85startContainer :: MonadObelisk m => m ()
85startContainer :: MonadObelisk m => m ()
86startContainer = withSpinner "Starting VM builder" $
86startContainer = withSpinner "Starting VM builder" $
87 callProcessAndLogOutput (Debug, Debug) $
87 callProcessAndLogOutput (Debug, Debug) $
88− proc dockerPath ["start", containerName]
88+ proc "docker" ["start", containerName]
89
89
90-- | Creates the Docker container; assumes it does not exist.
90-- | Creates the Docker container; assumes it does not exist.
91setupNixDocker :: MonadObelisk m => FilePath -> m ()
91setupNixDocker :: MonadObelisk m => FilePath -> m ()
@@ -98,12 +98,12 @@ setupNixDocker stateDir = withSpinner ("Creating Docker container named " <> con
98 callProcessAndLogOutput (Debug, Error) $
98 callProcessAndLogOutput (Debug, Error) $
99 proc rmPath ["-f", stateDir </> sshKeyFileName, stateDir </> sshKeyFileName <.> "pub"]
99 proc rmPath ["-f", stateDir </> sshKeyFileName, stateDir </> sshKeyFileName <.> "pub"]
100 callProcessAndLogOutput (Debug, Error) $
100 callProcessAndLogOutput (Debug, Error) $
101− proc sshKeygenPath ["-t", "ed25519", "-f", stateDir </> sshKeyFileName, "-P", ""]
101+ proc "ssh-keygen" ["-t", "ed25519", "-f", stateDir </> sshKeyFileName, "-P", ""]
102
102
103 -- Build the docker container (which uses the SSH keys in the 'ssh' folder)
103 -- Build the docker container (which uses the SSH keys in the 'ssh' folder)
104 containerId <- fmap T.strip $ readProcessAndLogStderr Error $
104 containerId <- fmap T.strip $ readProcessAndLogStderr Error $
105− proc dockerPath ["build", stateDir, "--quiet"]
105+ proc "docker" ["build", stateDir, "--quiet"]
106− callProcessAndLogOutput (Debug, Error) $ proc dockerPath
106+ callProcessAndLogOutput (Debug, Error) $ proc "docker"
107 [ "run"
107 [ "run"
108 , "--restart", "always"
108 , "--restart", "always"
109 , "--detach"
109 , "--detach"
@@ -155,7 +155,7 @@ testLinuxBuild :: MonadObelisk m => FilePath -> m ()
155testLinuxBuild stateDir
155testLinuxBuild stateDir
156 | System.Info.os == "linux" = failWith "Using the docker builder is not necessary on linux."
156 | System.Info.os == "linux" = failWith "Using the docker builder is not necessary on linux."
157 | otherwise = do
157 | otherwise = do
158− (exitCode, _stdout, stderr) <- readCreateProcessWithExitCode $ proc nixBuildExePath
158+ (exitCode, _stdout, stderr) <- readCreateProcessWithExitCode $ proc "nix-build"
159 [ "--no-out-link"
159 [ "--no-out-link"
160 , "-E", "(import <nixpkgs> { system = \"x86_64-linux\"; }).writeText \"test\" builtins.currentTime"
160 , "-E", "(import <nixpkgs> { system = \"x86_64-linux\"; }).writeText \"test\" builtins.currentTime"
161 , "--builders", nixBuildersArgString stateDir
161 , "--builders", nixBuildersArgString stateDir
lib/executable-config/default.nix+2−13
@@ -25,19 +25,8 @@ let
25in
25in
26
26
27{
27{
28− haskellOverlay = self: super:
28+ haskellOverlay = self: super: {
29− let
30− pkgs = self.callPackage ({pkgs}: pkgs) {};
31− in {
32− obelisk-executable-config-lookup = pkgs.haskell.lib.overrideCabal
33− (self.callCabal2nix "obelisk-executable-config-lookup" (obeliskCleanSource ./lookup) {})
29+ obelisk-executable-config-lookup = self.callCabal2nix "obelisk-executable-config-lookup" (obeliskCleanSource ./lookup) {};
34− (drv: {
35− # Hack until https://github.com/NixOS/cabal2nix/pull/432 lands
36− libraryHaskellDepends = (drv.libraryHaskellDepends or [])
37− ++ pkgs.stdenv.lib.optionals (with pkgs.stdenv.hostPlatform; isAndroid && is32bit) [
38− self.android-activity
39− ];
40− });
41 };
30 };
42
31
43 platforms = {
32 platforms = {
lib/executable-config/inject/obelisk-executable-config-inject.cabal+1−1
@@ -15,4 +15,4 @@ library
15 text
15 text
16
16
17 exposed-modules: Obelisk.ExecutableConfig.Inject
17 exposed-modules: Obelisk.ExecutableConfig.Inject
18− ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O
18+ ghc-options: -Wall
lib/executable-config/lookup/obelisk-executable-config-lookup.cabal+7−10
@@ -31,18 +31,15 @@ library
31 base64-bytestring,
31 base64-bytestring,
32 bytestring,
32 bytestring,
33 containers,
33 containers,
34− exceptions,
35 filepath,
34 filepath,
36− jsaddle,
37− mmorph,
38− monad-control,
39− mtl,
40− primitive,
41− ref-tf,
42− reflex-dom-core,
43− reflex,
44 text,
35 text,
36+ transformers,
45 transformers-base,
37 transformers-base,
46− transformers
38+ ref-tf,
39+ primitive,
40+ monad-control,
41+ reflex,
42+ reflex-dom,
43+ jsaddle
47
44
48 ghc-options: -Wall
45 ghc-options: -Wall
lib/executable-config/lookup/src/Obelisk/Configs.hs+12−31
@@ -18,38 +18,24 @@ module Obelisk.Configs
18 , getTextConfig
18 , getTextConfig
19 ) where
19 ) where
20
20
21−import Control.Applicative (Alternative)
21+import Control.Applicative
22−import Control.Monad (MonadPlus)
22+import Control.Monad
23−import Control.Monad.Base (MonadBase)
23+import Control.Monad.Base
24−import Control.Monad.Catch (MonadThrow)
25−import Control.Monad.Fail (MonadFail)
26−import Control.Monad.Fix (MonadFix)
24+import Control.Monad.Fix
27−import Control.Monad.IO.Class (MonadIO)
28−import Control.Monad.Morph (MFunctor)
29−import Control.Monad.Primitive (PrimMonad, PrimState, primitive)
25+import Control.Monad.Primitive
30−import Control.Monad.Ref (MonadRef)
26+import Control.Monad.Ref
27+import Control.Monad.IO.Class
31−import Control.Monad.Trans (MonadTrans, lift)
28+import Control.Monad.Trans.Class
32−import Control.Monad.Trans.Control (MonadBaseControl)
29+import Control.Monad.Trans.Control
33−import Control.Monad.Trans.Reader (ReaderT (..), ask, mapReaderT)
30+import Control.Monad.Trans.Reader
34−import Control.Monad.Trans.State (StateT)
35−import qualified Control.Monad.Trans.State.Strict as Strict
36import Data.ByteString (ByteString)
31import Data.ByteString (ByteString)
37import Data.Map (Map)
32import Data.Map (Map)
38import qualified Data.Map as Map
33import qualified Data.Map as Map
39import Data.Text (Text)
34import Data.Text (Text)
40import qualified Data.Text.Encoding as T
35import qualified Data.Text.Encoding as T
41import Reflex
36import Reflex
42−import Reflex.Host.Class (MonadReflexCreateTrigger)
37+import Reflex.Host.Class
43−import Reflex.Dom.Core
38+import Reflex.Dom
44− ( DomBuilder
45− , DomRenderHook
46− , HasDocument
47− , HasJS
48− , HasJSContext
49− , Prerender (Client)
50− , StaticDomBuilderT
51− , prerender
52− )
53#ifndef ghcjs_HOST_OS
39#ifndef ghcjs_HOST_OS
54import Language.Javascript.JSaddle (MonadJSM)
40import Language.Javascript.JSaddle (MonadJSM)
55#endif
41#endif
@@ -76,8 +62,6 @@ instance HasConfigs m => HasConfigs (PostBuildT t m)
76instance HasConfigs m => HasConfigs (QueryT t q m)
62instance HasConfigs m => HasConfigs (QueryT t q m)
77instance HasConfigs m => HasConfigs (ReaderT r m)
63instance HasConfigs m => HasConfigs (ReaderT r m)
78instance HasConfigs m => HasConfigs (RequesterT t request response m)
64instance HasConfigs m => HasConfigs (RequesterT t request response m)
79−instance HasConfigs m => HasConfigs (StateT w m)
80−instance HasConfigs m => HasConfigs (Strict.StateT w m)
81instance HasConfigs m => HasConfigs (StaticDomBuilderT t m)
65instance HasConfigs m => HasConfigs (StaticDomBuilderT t m)
82instance HasConfigs m => HasConfigs (TriggerEventT t m)
66instance HasConfigs m => HasConfigs (TriggerEventT t m)
83
67
@@ -88,15 +72,12 @@ newtype ConfigsT m a = ConfigsT { unConfigsT :: ReaderT (Map Text ByteString) m
88 , Monad
72 , Monad
89 , MonadPlus
73 , MonadPlus
90 , Alternative
74 , Alternative
91− , MonadFail
92 , MonadFix
75 , MonadFix
93− , MonadThrow
94 , MonadIO
76 , MonadIO
95 , MonadBase m'
77 , MonadBase m'
96 , MonadBaseControl m'
78 , MonadBaseControl m'
97 , MonadRef
79 , MonadRef
98 , MonadTrans
80 , MonadTrans
99− , MFunctor
100 , DomBuilder t
81 , DomBuilder t
101 , MonadHold t
82 , MonadHold t
102 , MonadReflexCreateTrigger t
83 , MonadReflexCreateTrigger t
lib/frontend/obelisk-frontend.cabal+1−1
@@ -26,4 +26,4 @@ library
26 exposed-modules:
26 exposed-modules:
27 Obelisk.Frontend
27 Obelisk.Frontend
28 Obelisk.Frontend.Cookie
28 Obelisk.Frontend.Cookie
29− ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O
29+ ghc-options: -Wall
lib/route/obelisk-route.cabal+1−2
@@ -20,7 +20,6 @@ library
20 http-types,
20 http-types,
21 jsaddle,
21 jsaddle,
22 lens,
22 lens,
23− mmorph,
24 monad-control,
23 monad-control,
25 mtl,
24 mtl,
26 network-uri,
25 network-uri,
@@ -39,4 +38,4 @@ library
39 exposed-modules: Obelisk.Route
38 exposed-modules: Obelisk.Route
40 Obelisk.Route.TH
39 Obelisk.Route.TH
41 Obelisk.Route.Frontend
40 Obelisk.Route.Frontend
42− ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O
41+ ghc-options: -Wall -fwarn-redundant-constraints
lib/route/src/Obelisk/Route.hs+22−23
@@ -6,6 +6,7 @@
6{-# LANGUAGE FlexibleContexts #-}
6{-# LANGUAGE FlexibleContexts #-}
7{-# LANGUAGE FlexibleInstances #-}
7{-# LANGUAGE FlexibleInstances #-}
8{-# LANGUAGE GADTs #-}
8{-# LANGUAGE GADTs #-}
9+{-# LANGUAGE KindSignatures #-}
9{-# LANGUAGE LambdaCase #-}
10{-# LANGUAGE LambdaCase #-}
10{-# LANGUAGE MultiParamTypeClasses #-}
11{-# LANGUAGE MultiParamTypeClasses #-}
11{-# LANGUAGE OverloadedStrings #-}
12{-# LANGUAGE OverloadedStrings #-}
@@ -140,19 +141,16 @@ import Control.Lens
140 , Wrapped (..)
141 , Wrapped (..)
141 )
142 )
142import Control.Monad.Except
143import Control.Monad.Except
144+import Control.Monad.Writer (execWriter, tell)
143import qualified Control.Monad.State.Strict as State
145import qualified Control.Monad.State.Strict as State
144import Control.Monad.Trans (lift)
146import Control.Monad.Trans (lift)
145−import Control.Monad.Writer (execWriter, tell)
146−import Data.Aeson (FromJSON, ToJSON)
147−import qualified Data.Aeson as Aeson
148import qualified Data.ByteString as BS
147import qualified Data.ByteString as BS
149import qualified Data.ByteString.Lazy as BSL
148import qualified Data.ByteString.Lazy as BSL
149+import Data.Dependent.Sum (DSum (..))
150import Data.Dependent.Map (DMap)
150import Data.Dependent.Map (DMap)
151import qualified Data.Dependent.Map as DMap
151import qualified Data.Dependent.Map as DMap
152−import Data.Dependent.Sum (DSum (..))
153import Data.Either.Validation (Validation (..))
152import Data.Either.Validation (Validation (..))
154import Data.Foldable
153import Data.Foldable
155−import Data.Functor (($>))
156import Data.Functor.Sum
154import Data.Functor.Sum
157import Data.GADT.Compare
155import Data.GADT.Compare
158import Data.GADT.Compare.TH
156import Data.GADT.Compare.TH
@@ -165,18 +163,19 @@ import Data.Monoid ((<>))
165import Data.Set (Set)
163import Data.Set (Set)
166import qualified Data.Set as Set
164import qualified Data.Set as Set
167import Data.Some (Some(Some))
165import Data.Some (Some(Some))
168−import Data.Tabulation
169import Data.Text (Text)
166import Data.Text (Text)
167+import Data.Text.Lens (IsText, packed, unpacked)
170import qualified Data.Text as T
168import qualified Data.Text as T
171import qualified Data.Text.Encoding as T
169import qualified Data.Text.Encoding as T
172−import Data.Text.Lens (IsText, packed, unpacked)
173−import Data.Type.Equality
174import Data.Universe
170import Data.Universe
175import Data.Universe.Some
171import Data.Universe.Some
176import Network.HTTP.Types.URI
172import Network.HTTP.Types.URI
177import qualified Numeric.Lens
173import qualified Numeric.Lens
178import Obelisk.Route.TH
174import Obelisk.Route.TH
179import Text.Read (readMaybe)
175import Text.Read (readMaybe)
176+import Data.Tabulation
177+import qualified Data.Aeson as Aeson
178+import Data.Aeson (FromJSON, ToJSON)
180
179
181-- Design goals:
180-- Design goals:
182-- No start-up time on the frontend (not yet met)
181-- No start-up time on the frontend (not yet met)
@@ -304,13 +303,13 @@ decode e x = runIdentity (tryDecode e x)
304-- | Once an 'Encoder' has been checked, so that its check monad has become 'Identity', even if the same is not true of the
303-- | Once an 'Encoder' has been checked, so that its check monad has become 'Identity', even if the same is not true of the
305-- parse monad, we may still attempt to decode with it in its parse monad.
304-- parse monad, we may still attempt to decode with it in its parse monad.
306tryDecode :: Encoder Identity parse decoded encoded -> encoded -> parse decoded
305tryDecode :: Encoder Identity parse decoded encoded -> encoded -> parse decoded
307−tryDecode (Encoder (Identity impl)) = _encoderImpl_decode impl
306+tryDecode (Encoder (Identity impl)) x = _encoderImpl_decode impl x
308
307
309-- | Similar to 'decode', once an encoder has been checked so that its check monad is Identity, it
308-- | Similar to 'decode', once an encoder has been checked so that its check monad is Identity, it
310-- can be used to actually encode by using this. Note that while there's no constraint on the parse monad here,
309-- can be used to actually encode by using this. Note that while there's no constraint on the parse monad here,
311-- one should usually be applying decode and encode to the same 'Encoder'
310-- one should usually be applying decode and encode to the same 'Encoder'
312encode :: Encoder Identity parse decoded encoded -> decoded -> encoded
311encode :: Encoder Identity parse decoded encoded -> decoded -> encoded
313−encode (Encoder (Identity impl)) = _encoderImpl_encode impl
312+encode (Encoder (Identity impl)) x = _encoderImpl_encode impl x
314
313
315-- | This is a primitive used to build encoders which can't fail to check. It should not be used unless one is
314-- | This is a primitive used to build encoders which can't fail to check. It should not be used unless one is
316-- reasonably certain that the law given for 'EncoderImpl' above holds.
315-- reasonably certain that the law given for 'EncoderImpl' above holds.
@@ -555,11 +554,11 @@ pathComponentEncoder f = Encoder $ do
555 unEncoder (pathComponentEncoderImpl (enum1Encoder (extractPathSegment . f)) f')
554 unEncoder (pathComponentEncoderImpl (enum1Encoder (extractPathSegment . f)) f')
556
555
557pathComponentEncoderImpl :: forall check parse p. (Monad check, Monad parse)
556pathComponentEncoderImpl :: forall check parse p. (Monad check, Monad parse)
558− => Encoder check parse (Some p) (Maybe Text)
557+ => (Encoder check parse (Some p) (Maybe Text))
559 -> (forall a. p a -> Encoder Identity parse a PageName)
558 -> (forall a. p a -> Encoder Identity parse a PageName)
560 -> Encoder check parse (R p) PageName
559 -> Encoder check parse (R p) PageName
561−pathComponentEncoderImpl =
560+pathComponentEncoderImpl this rest =
562− chainEncoder (lensEncoder (\(_, b) a -> (a, b)) Prelude.fst consEncoder)
561+ chainEncoder (lensEncoder (\(_, b) a -> (a, b)) Prelude.fst consEncoder) this rest
563
562
564--NOTE: Naming convention in this module is to always talk about things in the *encoding* direction, never in the *decoding* direction
563--NOTE: Naming convention in this module is to always talk about things in the *encoding* direction, never in the *decoding* direction
565
564
@@ -815,7 +814,7 @@ rPrism
815 :: forall f f'
814 :: forall f f'
816 . (forall a. Prism' (f a) (f' a))
815 . (forall a. Prism' (f a) (f' a))
817 -> Prism' (R f) (R f')
816 -> Prism' (R f) (R f')
818−rPrism = dSumPrism
817+rPrism p = dSumPrism p
819
818
820dSumPrism'
819dSumPrism'
821 :: forall f g a
820 :: forall f g a
@@ -827,7 +826,7 @@ dSumGEqPrism
827 :: GEq f
826 :: GEq f
828 => f a
827 => f a
829 -> Prism' (DSum f g) (g a)
828 -> Prism' (DSum f g) (g a)
830−dSumGEqPrism variant = dSumPrism' $ prism' (\Refl -> variant) (geq variant)
829+dSumGEqPrism variant = dSumPrism' $ prism' (\Refl -> variant) (\x -> geq variant x)
831
830
832-- | Given a 'tag :: f a', make a prism for 'R f'. This generalizes the usual
831-- | Given a 'tag :: f a', make a prism for 'R f'. This generalizes the usual
833-- prisms for a sum type (the ones that 'mkPrisms' would make), just as 'R'
832-- prisms for a sum type (the ones that 'mkPrisms' would make), just as 'R'
@@ -994,9 +993,9 @@ obeliskRouteSegment r appRouteSegment = case r of
994-- be combined with other such segment encoders before 'pathComponentEncoder' turns it into a proper 'Encoder'.
993-- be combined with other such segment encoders before 'pathComponentEncoder' turns it into a proper 'Encoder'.
995resourceRouteSegment :: (MonadError Text check, MonadError Text parse) => ResourceRoute a -> SegmentResult check parse a
994resourceRouteSegment :: (MonadError Text check, MonadError Text parse) => ResourceRoute a -> SegmentResult check parse a
996resourceRouteSegment = \case
995resourceRouteSegment = \case
997− ResourceRoute_Static -> PathSegment "static" pathOnlyEncoderIgnoringQuery
996+ ResourceRoute_Static -> PathSegment "static" $ pathOnlyEncoderIgnoringQuery
998− ResourceRoute_Ghcjs -> PathSegment "ghcjs" pathOnlyEncoder
997+ ResourceRoute_Ghcjs -> PathSegment "ghcjs" $ pathOnlyEncoder
999− ResourceRoute_JSaddleWarp -> PathSegment "jsaddle" jsaddleWarpRouteEncoder
998+ ResourceRoute_JSaddleWarp -> PathSegment "jsaddle" $ jsaddleWarpRouteEncoder
1000 ResourceRoute_Version -> PathSegment "version" $ unitEncoder mempty
999 ResourceRoute_Version -> PathSegment "version" $ unitEncoder mempty
1001
1000
1002data JSaddleWarpRoute :: * -> * where
1001data JSaddleWarpRoute :: * -> * where
@@ -1008,7 +1007,7 @@ jsaddleWarpRouteEncoder :: (MonadError Text check, MonadError Text parse) => Enc
1008jsaddleWarpRouteEncoder = pathComponentEncoder $ \case
1007jsaddleWarpRouteEncoder = pathComponentEncoder $ \case
1009 JSaddleWarpRoute_JavaScript -> PathSegment "jsaddle.js" $ unitEncoder mempty
1008 JSaddleWarpRoute_JavaScript -> PathSegment "jsaddle.js" $ unitEncoder mempty
1010 JSaddleWarpRoute_WebSocket -> PathEnd $ unitEncoder mempty
1009 JSaddleWarpRoute_WebSocket -> PathEnd $ unitEncoder mempty
1011− JSaddleWarpRoute_Sync -> PathSegment "sync" pathOnlyEncoder
1010+ JSaddleWarpRoute_Sync -> PathSegment "sync" $ pathOnlyEncoder
1012
1011
1013instance GShow appRoute => GShow (ObeliskRoute appRoute) where
1012instance GShow appRoute => GShow (ObeliskRoute appRoute) where
1014 gshowsPrec prec = \case
1013 gshowsPrec prec = \case
@@ -1039,8 +1038,8 @@ someSumEncoder = Encoder $ pure $ EncoderImpl
1039
1038
1040data Void1 :: * -> * where {}
1039data Void1 :: * -> * where {}
1041
1040
1042−instance UniverseSome Void1 where
1041+instance Universe (Some Void1) where
1043− universeSome = []
1042+ universe = []
1044
1043
1045void1Encoder :: (Applicative check, MonadError Text parse) => Encoder check parse (Some Void1) a
1044void1Encoder :: (Applicative check, MonadError Text parse) => Encoder check parse (Some Void1) a
1046void1Encoder = Encoder $ pure $ EncoderImpl
1045void1Encoder = Encoder $ pure $ EncoderImpl
@@ -1084,7 +1083,7 @@ readShowEncoder :: (MonadError Text parse, Read a, Show a, Applicative check) =>
1084readShowEncoder = singlePathSegmentEncoder . unsafeTshowEncoder
1083readShowEncoder = singlePathSegmentEncoder . unsafeTshowEncoder
1085
1084
1086integralEncoder :: (MonadError Text parse, Applicative check, Integral a) => Encoder check parse a Integer
1085integralEncoder :: (MonadError Text parse, Applicative check, Integral a) => Encoder check parse a Integer
1087−integralEncoder = reviewEncoder Numeric.Lens.integral
1086+integralEncoder = reviewEncoder (Numeric.Lens.integral)
1088
1087
1089pathSegmentEncoder :: (MonadError Text parse, Applicative check, Cons as as a a) =>
1088pathSegmentEncoder :: (MonadError Text parse, Applicative check, Cons as as a a) =>
1090 Encoder check parse (a, (as, b)) (as, b)
1089 Encoder check parse (a, (as, b)) (as, b)
@@ -1159,7 +1158,7 @@ pathFieldEncoder fieldEncoder = unsafeEncoder $ do
1159 fieldEncoderPure f = toEncoder (DMap.findWithDefault (error "bad") f fieldEncoderPureMap)
1158 fieldEncoderPure f = toEncoder (DMap.findWithDefault (error "bad") f fieldEncoderPureMap)
1160 pure $ EncoderImpl
1159 pure $ EncoderImpl
1161 { _encoderImpl_encode = \(x, rest) -> execWriter $ do
1160 { _encoderImpl_encode = \(x, rest) -> execWriter $ do
1162− _ <- traverseWithField (\f x_i -> tell (pure $ encode (fieldEncoderPure f) x_i) $> x_i) x
1161+ _ <- traverseWithField (\f x_i -> tell (pure $ encode (fieldEncoderPure f) x_i) *> pure x_i) x
1163 tell rest
1162 tell rest
1164 , _encoderImpl_decode = State.runStateT $ tabulateFieldsA $ \f -> State.get >>= \case
1163 , _encoderImpl_decode = State.runStateT $ tabulateFieldsA $ \f -> State.get >>= \case
1165 [] -> throwError $ T.pack "not enough path components"
1164 [] -> throwError $ T.pack "not enough path components"
lib/route/src/Obelisk/Route/Frontend.hs+28−41
@@ -1,24 +1,24 @@
1−{-# LANGUAGE CPP #-}
2{-# LANGUAGE ApplicativeDo #-}
1{-# LANGUAGE ApplicativeDo #-}
2+{-# LANGUAGE CPP #-}
3+{-# LANGUAGE RecursiveDo #-}
4+{-# LANGUAGE StandaloneDeriving #-}
3{-# LANGUAGE ConstraintKinds #-}
5{-# LANGUAGE ConstraintKinds #-}
4−{-# LANGUAGE DataKinds #-}
5{-# LANGUAGE DefaultSignatures #-}
6{-# LANGUAGE DefaultSignatures #-}
6{-# LANGUAGE FlexibleContexts #-}
7{-# LANGUAGE FlexibleContexts #-}
7{-# LANGUAGE FlexibleInstances #-}
8{-# LANGUAGE FlexibleInstances #-}
8−{-# LANGUAGE FunctionalDependencies #-}
9{-# LANGUAGE GADTs #-}
9{-# LANGUAGE GADTs #-}
10−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
11{-# LANGUAGE LambdaCase #-}
10{-# LANGUAGE LambdaCase #-}
12{-# LANGUAGE OverloadedStrings #-}
11{-# LANGUAGE OverloadedStrings #-}
13{-# LANGUAGE PatternSynonyms #-}
12{-# LANGUAGE PatternSynonyms #-}
14{-# LANGUAGE RankNTypes #-}
13{-# LANGUAGE RankNTypes #-}
15−{-# LANGUAGE RecursiveDo #-}
16{-# LANGUAGE ScopedTypeVariables #-}
14{-# LANGUAGE ScopedTypeVariables #-}
17−{-# LANGUAGE StandaloneDeriving #-}
18{-# LANGUAGE TypeFamilies #-}
15{-# LANGUAGE TypeFamilies #-}
19{-# LANGUAGE TypeOperators #-}
16{-# LANGUAGE TypeOperators #-}
20−{-# LANGUAGE UndecidableInstances #-}
21{-# LANGUAGE ViewPatterns #-}
17{-# LANGUAGE ViewPatterns #-}
18+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
19+{-# LANGUAGE UndecidableInstances #-}
20+{-# LANGUAGE DataKinds #-}
21+{-# LANGUAGE FunctionalDependencies #-}
22
22
23module Obelisk.Route.Frontend
23module Obelisk.Route.Frontend
24 ( module Obelisk.Route
24 ( module Obelisk.Route
@@ -57,42 +57,49 @@ module Obelisk.Route.Frontend
57
57
58import Prelude hiding ((.), id)
58import Prelude hiding ((.), id)
59
59
60+import Obelisk.Route
61+
60import Control.Category (Category (..), (.))
62import Control.Category (Category (..), (.))
61import Control.Category.Cartesian ((&&&))
63import Control.Category.Cartesian ((&&&))
62import Control.Lens hiding (Bifunctor, bimap, universe, element)
64import Control.Lens hiding (Bifunctor, bimap, universe, element)
63import Control.Monad ((<=<))
65import Control.Monad ((<=<))
64import Control.Monad.Fix
66import Control.Monad.Fix
65−import Control.Monad.Morph
66import Control.Monad.Primitive
67import Control.Monad.Primitive
67import Control.Monad.Reader
68import Control.Monad.Reader
68import Control.Monad.Ref
69import Control.Monad.Ref
69import Control.Monad.Trans.Control
70import Control.Monad.Trans.Control
70import Data.Coerce
71import Data.Coerce
71import Data.Dependent.Sum (DSum (..))
72import Data.Dependent.Sum (DSum (..))
72−import Data.Functor.Compose
73−import Data.Functor.Misc
74import Data.GADT.Compare
73import Data.GADT.Compare
75−import qualified Data.List as L
76import Data.Map (Map)
74import Data.Map (Map)
77−import Data.Maybe (fromMaybe)
78import Data.Monoid
75import Data.Monoid
79import Data.Proxy
76import Data.Proxy
80import Data.Text (Text)
77import Data.Text (Text)
81import qualified Data.Text as T
78import qualified Data.Text as T
79+import Data.Functor.Compose
80+import Data.Functor.Misc
81+import Reflex.Class
82+import Reflex.Host.Class
83+import Reflex.PostBuild.Class
84+import Reflex.TriggerEvent.Class
85+import Reflex.PerformEvent.Class
86+import Reflex.EventWriter.Class
87+import Reflex.EventWriter.Base
88+import Reflex.Dynamic
89+import Reflex.Dom.Builder.Class
82import Data.Type.Coercion
90import Data.Type.Coercion
91+import Language.Javascript.JSaddle --TODO: Get rid of this - other platforms can also be routed
92+import Reflex.Dom.Core
83import qualified GHCJS.DOM as DOM
93import qualified GHCJS.DOM as DOM
84import qualified GHCJS.DOM.Types as DOM
94import qualified GHCJS.DOM.Types as DOM
85import qualified GHCJS.DOM.Window as Window
95import qualified GHCJS.DOM.Window as Window
86−import Language.Javascript.JSaddle (MonadJSM, jsNull, liftJSM) --TODO: Get rid of this - other platforms can also be routed
87import Network.URI
96import Network.URI
88−import Reflex.Class
97+import Data.Maybe (fromMaybe)
89−import Reflex.Dom.Builder.Class
98+import qualified Data.List as L
90−import Reflex.Dom.Core
99+
91−import Reflex.Host.Class
92import Unsafe.Coerce
100import Unsafe.Coerce
93
101
94import Obelisk.Configs
102import Obelisk.Configs
95−import Obelisk.Route
96
103
97infixr 5 :~
104infixr 5 :~
98pattern (:~) :: Reflex t => f a -> Dynamic t a -> DSum f (Compose (Dynamic t) Identity)
105pattern (:~) :: Reflex t => f a -> Dynamic t a -> DSum f (Compose (Dynamic t) Identity)
@@ -109,23 +116,7 @@ instance Monad m => Routed t r (RoutedT t r m) where
109instance (Monad m, Routed t r m) => Routed t r (ReaderT r' m)
116instance (Monad m, Routed t r m) => Routed t r (ReaderT r' m)
110
117
111newtype RoutedT t r m a = RoutedT { unRoutedT :: ReaderT (Dynamic t r) m a }
118newtype RoutedT t r m a = RoutedT { unRoutedT :: ReaderT (Dynamic t r) m a }
112− deriving
119+ deriving (Functor, Applicative, Monad, MonadFix, MonadTrans, NotReady t, MonadHold t, MonadSample t, PostBuild t, TriggerEvent t, MonadIO, MonadReflexCreateTrigger t, HasDocument, DomRenderHook t)
113− ( Functor
114− , Applicative
115− , Monad
116− , MonadFix
117− , MonadTrans
118− , MFunctor
119− , NotReady t
120− , MonadHold t
121− , MonadSample t
122− , PostBuild t
123− , TriggerEvent t
124− , MonadIO
125− , MonadReflexCreateTrigger t
126− , HasDocument
127− , DomRenderHook t
128− )
129
120
130instance MonadReader r' m => MonadReader r' (RoutedT t r m) where
121instance MonadReader r' m => MonadReader r' (RoutedT t r m) where
131 ask = lift ask
122 ask = lift ask
@@ -201,10 +192,6 @@ instance (Monad m, RouteToUrl r m) => RouteToUrl r (EventWriterT t w m)
201
192
202instance (Monad m, SetRoute t r m) => SetRoute t r (EventWriterT t w m)
193instance (Monad m, SetRoute t r m) => SetRoute t r (EventWriterT t w m)
203
194
204−instance (Monad m, RouteToUrl r m) => RouteToUrl r (DynamicWriterT t w m)
205−
206−instance (Monad m, SetRoute t r m) => SetRoute t r (DynamicWriterT t w m)
207−
208runRoutedT :: RoutedT t r m a -> Dynamic t r -> m a
195runRoutedT :: RoutedT t r m a -> Dynamic t r -> m a
209runRoutedT = runReaderT . unRoutedT
196runRoutedT = runReaderT . unRoutedT
210
197
@@ -269,7 +256,7 @@ dynamicIdentityCoercion = unsafeCoerce (Coercion :: Coercion (Identity ()) ()) -
269factorRouted :: (Reflex t, MonadFix m, MonadHold t m, GEq f) => RoutedT t (DSum f (Dynamic t)) m a -> RoutedT t (DSum f Identity) m a
256factorRouted :: (Reflex t, MonadFix m, MonadHold t m, GEq f) => RoutedT t (DSum f (Dynamic t)) m a -> RoutedT t (DSum f Identity) m a
270factorRouted r = RoutedT $ ReaderT $ \d -> do
257factorRouted r = RoutedT $ ReaderT $ \d -> do
271 d' <- factorDyn d
258 d' <- factorDyn d
272− runRoutedT r $ coerceWith (dynamicCoercion $ dsumValueCoercion dynamicIdentityCoercion) d'
259+ runRoutedT r $ (coerceWith (dynamicCoercion $ dsumValueCoercion dynamicIdentityCoercion) d')
273
260
274maybeRouted :: (Reflex t, MonadFix m, MonadHold t m) => RoutedT t (Maybe (Dynamic t a)) m b -> RoutedT t (Maybe a) m b
261maybeRouted :: (Reflex t, MonadFix m, MonadHold t m) => RoutedT t (Maybe (Dynamic t a)) m b -> RoutedT t (Maybe a) m b
275maybeRouted r = RoutedT $ ReaderT $ \d -> do
262maybeRouted r = RoutedT $ ReaderT $ \d -> do
@@ -477,7 +464,7 @@ runRouteViewT
477 , MonadJSM (Performable m)
464 , MonadJSM (Performable m)
478 , MonadFix m
465 , MonadFix m
479 )
466 )
480− => Encoder Identity Identity r PageName
467+ => (Encoder Identity Identity r PageName)
481 --TODO: Get rid of the switchover and useHash arguments
468 --TODO: Get rid of the switchover and useHash arguments
482 -- useHash can probably be baked into the encoder
469 -- useHash can probably be baked into the encoder
483 -> Event t () -- ^ Switchover event, nothing is done until this event fires. Used to prevent incorrect DOM expectations at hydration switchover time
470 -> Event t () -- ^ Switchover event, nothing is done until this event fires. Used to prevent incorrect DOM expectations at hydration switchover time
lib/run/obelisk-run.cabal+2−2
@@ -33,7 +33,7 @@ library
33 , process
33 , process
34 , ref-tf
34 , ref-tf
35 , reflex
35 , reflex
36− , reflex-dom-core
36+ , reflex-dom
37 , snap-core
37 , snap-core
38 , streaming-commons
38 , streaming-commons
39 , text
39 , text
@@ -47,7 +47,7 @@ library
47 , websockets
47 , websockets
48 exposed-modules:
48 exposed-modules:
49 Obelisk.Run
49 Obelisk.Run
50− ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O
50+ ghc-options: -Wall -fwarn-redundant-constraints
51 if os(linux)
51 if os(linux)
52 cpp-options: -DIPROUTE_SUPPORTED
52 cpp-options: -DIPROUTE_SUPPORTED
53 build-depends: which
53 build-depends: which
lib/run/src/Obelisk/Run.hs+3−3
@@ -144,9 +144,9 @@ runWidget conf configs frontend validFullEncoder = do
144
144
145 cert <- X509.newX509 >>= X509Request.makeX509FromReq certRequest
145 cert <- X509.newX509 >>= X509Request.makeX509FromReq certRequest
146 _ <- X509.setPublicKey cert privateKey
146 _ <- X509.setPublicKey cert privateKey
147− timenow <- getCurrentTime
147+ now <- getCurrentTime
148− _ <- X509.setNotBefore cert $ addUTCTime (-1) timenow
148+ _ <- X509.setNotBefore cert $ addUTCTime (-1) now
149− _ <- X509.setNotAfter cert $ addUTCTime (365 * 24 * 60 * 60) timenow
149+ _ <- X509.setNotAfter cert $ addUTCTime (365 * 24 * 60 * 60) now
150 _ <- X509.signX509 cert privateKey Nothing
150 _ <- X509.signX509 cert privateKey Nothing
151
151
152 certByteString <- BSUTF8.fromString <$> PEM.writeX509 cert
152 certByteString <- BSUTF8.fromString <$> PEM.writeX509 cert
lib/snap-extras/obelisk-snap-extras.cabal+1−1
@@ -17,4 +17,4 @@ library
17 , text
17 , text
18 exposed-modules:
18 exposed-modules:
19 Obelisk.Snap.Extras
19 Obelisk.Snap.Extras
20− ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O
20+ ghc-options: -Wall
lib/snap-extras/src/Obelisk/Snap/Extras.hs+1−1
@@ -17,7 +17,7 @@ import System.Directory
17-- | Set response header for "permanent" caching
17-- | Set response header for "permanent" caching
18cachePermanently :: MonadSnap m => m ()
18cachePermanently :: MonadSnap m => m ()
19cachePermanently = do
19cachePermanently = do
20− modifyResponse $ setHeader "Cache-Control" "public, max-age=315360000, immutable"
20+ modifyResponse $ setHeader "Cache-Control" "public, max-age=315360000"
21 modifyResponse $ setHeader "Expires" "Tue, 01 Feb 2050 00:00:00 GMT" --TODO: This should be set to "approximately one year from the time the response is sent"
21 modifyResponse $ setHeader "Expires" "Tue, 01 Feb 2050 00:00:00 GMT" --TODO: This should be set to "approximately one year from the time the response is sent"
22
22
23-- | Set response header to not cache
23-- | Set response header to not cache
skeleton/.gitignore+6−12
@@ -1,15 +1,9 @@
1+dist-newstyle
2+result
3+result-*
4+result-android
5+result-ios
6+result-exe
1.attr-cache
7.attr-cache
2−.cabal-sandbox
3−*.hi
4−*.o
5−cabal.project.local
6−cabal.sandbox.config
7−ctags
8−dist-newstyle/
9−dist/
10ghcid-output.txt
8ghcid-output.txt
11profile/
9profile/
12−result
13−result-*
14−tags
15−TAGS
skeleton/backend/backend.cabal+1−2
@@ -14,12 +14,11 @@ library
14 , obelisk-route
14 , obelisk-route
15 exposed-modules:
15 exposed-modules:
16 Backend
16 Backend
17− ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -fno-show-valid-hole-fits
17+ ghc-options: -Wall
18
18
19executable backend
19executable backend
20 main-is: main.hs
20 main-is: main.hs
21 hs-source-dirs: src-bin
21 hs-source-dirs: src-bin
22− ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -threaded -fno-show-valid-hole-fits
23 if impl(ghcjs)
22 if impl(ghcjs)
24 buildable: False
23 buildable: False
25 build-depends: base
24 build-depends: base
skeleton/cabal.project−1
@@ -1,3 +1,2 @@
1optional-packages:
1optional-packages:
2 *
2 *
3−write-ghc-environment-files: never
skeleton/common/common.cabal+1−1
@@ -12,4 +12,4 @@ library
12 exposed-modules:
12 exposed-modules:
13 Common.Api
13 Common.Api
14 Common.Route
14 Common.Route
15− ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -fno-show-valid-hole-fits
15+ ghc-options: -Wall
skeleton/default.nix+3−10
@@ -1,17 +1,10 @@
1−{ system ? builtins.currentSystem
2−, obelisk ? import ./.obelisk/impl {
1+{ obelisk ? import ./.obelisk/impl {
3− inherit system;
2+ system = builtins.currentSystem;
4− iosSdkVersion = "13.2";
3+ iosSdkVersion = "10.2";
5−
6 # You must accept the Android Software Development Kit License Agreement at
4 # You must accept the Android Software Development Kit License Agreement at
7 # https://developer.android.com/studio/terms in order to build Android apps.
5 # https://developer.android.com/studio/terms in order to build Android apps.
8 # Uncomment and set this to `true` to indicate your acceptance:
6 # Uncomment and set this to `true` to indicate your acceptance:
9 # config.android_sdk.accept_license = false;
7 # config.android_sdk.accept_license = false;
10−
11− # In order to use Let's Encrypt for HTTPS deployments you must accept
12− # their terms of service at https://letsencrypt.org/repository/.
13− # Uncomment and set this to `true` to indicate your acceptance:
14− # terms.security.acme.acceptTerms = false;
15 }
8 }
16}:
9}:
17with obelisk;
10with obelisk;
skeleton/frontend/frontend.cabal+2−2
@@ -16,7 +16,7 @@ library
16 , text
16 , text
17 exposed-modules:
17 exposed-modules:
18 Frontend
18 Frontend
19− ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -O -fno-show-valid-hole-fits
19+ ghc-options: -Wall
20
20
21executable frontend
21executable frontend
22 main-is: main.hs
22 main-is: main.hs
@@ -28,7 +28,7 @@ executable frontend
28 , reflex-dom
28 , reflex-dom
29 , obelisk-generated-static
29 , obelisk-generated-static
30 , frontend
30 , frontend
31− ghc-options: -threaded -O -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -fno-show-valid-hole-fits
31+ ghc-options: -threaded
32 if impl(ghcjs)
32 if impl(ghcjs)
33 ghc-options: -dedupe
33 ghc-options: -dedupe
34 cpp-options: -DGHCJS_BROWSER
34 cpp-options: -DGHCJS_BROWSER
skeleton/shell.nixnew file+1
@@ -0,0 +1 @@
1+(import ./. {}).shells.ghc