Build the purescript bundle:
spago init
spago install aff console effect web-file web-xhr
spago build && spago bundle-module -m Upload -t index.cjs && browserify index.cjs -s Upload -o index.js
Spin up a dumb server to accept the POST request
library(shiny) | |
# The browser will send files inserted into the editor here | |
upload_path <- "/upload-image" | |
# Only accept PNGs for now | |
supported_file_types <- c("png") | |
shiny_editor_options <- paste( | |
"plugins: 'image'", |
#!/usr/bin/env bash | |
# Enable bash "strict mode" | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -euo pipefail | |
IFS=$'\n\t' | |
# Some nice colour functions, you might want to add more... | |
# https://gist.github.com/daytonn/8677243 |
let | |
pkgs = import <nixpkgs> { }; | |
reasonml = import ../reasonml.nix { inherit pkgs; }; | |
libs = p: with p; [ gtk3-x11.dev pango.dev glib.dev cairo.dev gdk-pixbuf.dev atk.dev ]; | |
pkg-config = p: p.stdenv.mkDerivation { | |
# revery looks for gtk headers via... | |
# pkg-config --cflags gtk+-x11-3.0 | |
name = "pkg-config-wrapped"; | |
buildInputs = [ p.makeWrapper ] ++ libs p; |
Build the purescript bundle:
spago init
spago install aff console effect web-file web-xhr
spago build && spago bundle-module -m Upload -t index.cjs && browserify index.cjs -s Upload -o index.js
Spin up a dumb server to accept the POST request
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
module Dope (main) where | |
import Prelude |
#!/usr/bin/env stack | |
-- stack --resolver lts-12.12 script --package aeson --package mtl | |
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE ScopedTypeVariables #-} |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Data.Aeson ((.:)) | |
import qualified Data.Aeson as Aeson | |
import qualified Data.ByteString.Lazy.Char8 as ByteString | |
import qualified Network.HTTP as HTTP | |
import qualified System.IO as IO |
:set -fwarn-unused-binds -fwarn-unused-imports | |
:load Server.hs |
:set -fwarn-unused-binds -fwarn-unused-imports | |
:set -i. | |
:load Request |
Rebuild all the things (worse case scenario):
[ReallyBigProject](master)$ find client/elm -type f -exec touch {} +
[ReallyBigProject](master)$ elm-make +RTS -N4 -s -RTS client/elm/Main.elm --output $(mktemp --suffix .js)
Here's the output (with some overhead from profiling stuff in the build):