Server works
42
.gitignore
vendored
@ -1,10 +1,32 @@
|
||||
/bower_components/
|
||||
/node_modules/
|
||||
/.pulp-cache/
|
||||
/output/
|
||||
/generated-docs/
|
||||
/.psc-package/
|
||||
/.psc*
|
||||
/.purs*
|
||||
/.psa*
|
||||
/.spago
|
||||
client/bower_components/
|
||||
client/node_modules/
|
||||
client/.pulp-cache/
|
||||
client/output/
|
||||
client/generated-docs/
|
||||
client/.psc-package/
|
||||
client/.psc*
|
||||
client/.purs*
|
||||
client/.psa*
|
||||
client/.spago
|
||||
|
||||
server/bower_components/
|
||||
server/node_modules/
|
||||
server/.pulp-cache/
|
||||
server/output/
|
||||
server/generated-docs/
|
||||
server/.psc-package/
|
||||
server/.psc*
|
||||
server/.purs*
|
||||
server/.psa*
|
||||
server/.spago
|
||||
|
||||
playground/bower_components/
|
||||
playground/node_modules/
|
||||
playground/.pulp-cache/
|
||||
playground/output/
|
||||
playground/generated-docs/
|
||||
playground/.psc-package/
|
||||
playground/.psc*
|
||||
playground/.purs*
|
||||
playground/.psa*
|
||||
playground/.spago
|
||||
|
@ -1,15 +0,0 @@
|
||||
<link href="https://fonts.googleapis.com/css?family=Overpass|Playfair+Display|Montserrat:300,400,500,600,700,800,900&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
html, body, #app {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "PragmataPro";
|
||||
src: url('./fonts/PragmataProLiga-Regular.woff2') format('woff2'),
|
||||
url('./fonts/PragmataProLiga-Regular.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
</style>
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 775 B After Width: | Height: | Size: 775 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 508 B |
Before Width: | Height: | Size: 907 B After Width: | Height: | Size: 907 B |
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
0
dist/bundle.js → client/dist/bundle.js
vendored
1
client/packages.dhall
Symbolic link
@ -0,0 +1 @@
|
||||
../packages.dhall
|
1023
client/src/Monaco/Editor.js
Normal file
@ -1,6 +1,7 @@
|
||||
module Editor where
|
||||
|
||||
import Prelude
|
||||
|
||||
import CSS.Safer (cssSafer)
|
||||
import Control.Promise (Promise)
|
||||
import Control.Promise as Promise
|
||||
@ -20,7 +21,8 @@ import React.Basic.Hooks (component, readRefMaybe, useRef, writeRef)
|
||||
import React.Basic.Hooks as React
|
||||
import React.Basic.Hooks.Aff (useAff)
|
||||
import React.Helpers (wrapperDiv)
|
||||
import Theme.Styles (makeStyles_)
|
||||
import Theme.Styles (makeStyles, useTheme)
|
||||
import Theme.Types (CSSTheme)
|
||||
import Web.DOM (Node)
|
||||
|
||||
type EditorProps
|
||||
@ -45,6 +47,8 @@ foreign import setThemeImpl ∷ Monaco -> String -> Effect Unit
|
||||
|
||||
foreign import nightOwlTheme ∷ MonacoTheme
|
||||
|
||||
foreign import vsCodeTheme ∷ MonacoTheme
|
||||
|
||||
foreign import getValue ∷ Editor -> Effect String
|
||||
|
||||
foreign import data Monaco ∷ Type
|
||||
@ -53,15 +57,17 @@ foreign import data Editor ∷ Type
|
||||
|
||||
foreign import data MonacoTheme ∷ Type
|
||||
|
||||
editor ∷
|
||||
∀ attrs attrs_. Union attrs attrs_ EditorProps => ReactComponent { | attrs }
|
||||
editor ∷ ∀ attrs attrs_. Union attrs attrs_ EditorProps => ReactComponent { | attrs }
|
||||
editor = editorImpl
|
||||
|
||||
initMonaco ∷ Aff Monaco
|
||||
initMonaco = liftEffect initMonacoImpl >>= Promise.toAff
|
||||
|
||||
themeName ∷ String
|
||||
themeName = "NightOwl"
|
||||
darkThemeName ∷ String
|
||||
darkThemeName = "NightOwl"
|
||||
|
||||
lightThemeName ∷ String
|
||||
lightThemeName = "VSCode"
|
||||
|
||||
foreign import data MonarchLanguage ∷ Type
|
||||
|
||||
@ -71,10 +77,18 @@ foreign import registerLanguageImpl ∷ Monaco -> String -> Effect Unit
|
||||
|
||||
foreign import setMonarchTokensProviderImpl ∷ Monaco -> String -> MonarchLanguage -> Effect Unit
|
||||
|
||||
initEditor ∷ Aff Unit
|
||||
initEditor = do
|
||||
monaco <- initMonaco
|
||||
defineThemeImpl monaco darkThemeName nightOwlTheme # liftEffect
|
||||
defineThemeImpl monaco lightThemeName vsCodeTheme # liftEffect
|
||||
registerLanguageImpl monaco "purescript" # liftEffect
|
||||
setMonarchTokensProviderImpl monaco "purescript" purescriptSyntax # liftEffect
|
||||
|
||||
mkEditor ∷ Effect (ReactComponent {})
|
||||
mkEditor = do
|
||||
useStyles <-
|
||||
makeStyles_
|
||||
makeStyles \(theme ∷ CSSTheme) ->
|
||||
{ wrapper:
|
||||
cssSafer
|
||||
{ margin: "0"
|
||||
@ -83,19 +97,15 @@ mkEditor = do
|
||||
, width: "100%"
|
||||
, height: "100%"
|
||||
, borderRadius: "32px"
|
||||
, backgroundColor: "#011627"
|
||||
, backgroundColor: theme.backgroundColour
|
||||
}
|
||||
}
|
||||
component "Editor" \{} -> React.do
|
||||
classes <- useStyles
|
||||
ref <- useRef null
|
||||
useAff unit
|
||||
$ do
|
||||
monaco <- initMonaco
|
||||
defineThemeImpl monaco themeName nightOwlTheme # liftEffect
|
||||
setThemeImpl monaco themeName # liftEffect
|
||||
registerLanguageImpl monaco "purescript" # liftEffect
|
||||
setMonarchTokensProviderImpl monaco "purescript" purescriptSyntax # liftEffect
|
||||
useAff unit initEditor
|
||||
theme <- useTheme
|
||||
let themeName = if theme.isLight then lightThemeName else darkThemeName
|
||||
pure
|
||||
$ fragment
|
||||
[ R.button
|
1
client/src/Shared
Symbolic link
@ -0,0 +1 @@
|
||||
../../shared/Shared
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
10
playground/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/bower_components/
|
||||
/node_modules/
|
||||
/.pulp-cache/
|
||||
/output/
|
||||
/generated-docs/
|
||||
/.psc-package/
|
||||
/.psc*
|
||||
/.purs*
|
||||
/.psa*
|
||||
/.spago
|
128
playground/packages.dhall
Normal file
@ -0,0 +1,128 @@
|
||||
{-
|
||||
Welcome to your new Dhall package-set!
|
||||
|
||||
Below are instructions for how to edit this file for most use
|
||||
cases, so that you don't need to know Dhall to use it.
|
||||
|
||||
## Warning: Don't Move This Top-Level Comment!
|
||||
|
||||
Due to how `dhall format` currently works, this comment's
|
||||
instructions cannot appear near corresponding sections below
|
||||
because `dhall format` will delete the comment. However,
|
||||
it will not delete a top-level comment like this one.
|
||||
|
||||
## Use Cases
|
||||
|
||||
Most will want to do one or both of these options:
|
||||
1. Override/Patch a package's dependency
|
||||
2. Add a package not already in the default package set
|
||||
|
||||
This file will continue to work whether you use one or both options.
|
||||
Instructions for each option are explained below.
|
||||
|
||||
### Overriding/Patching a package
|
||||
|
||||
Purpose:
|
||||
- Change a package's dependency to a newer/older release than the
|
||||
default package set's release
|
||||
- Use your own modified version of some dependency that may
|
||||
include new API, changed API, removed API by
|
||||
using your custom git repo of the library rather than
|
||||
the package set's repo
|
||||
|
||||
Syntax:
|
||||
Replace the overrides' "{=}" (an empty record) with the following idea
|
||||
The "//" or "⫽" means "merge these two records and
|
||||
when they have the same value, use the one on the right:"
|
||||
-------------------------------
|
||||
let override =
|
||||
{ packageName =
|
||||
upstream.packageName // { updateEntity1 = "new value", updateEntity2 = "new value" }
|
||||
, packageName =
|
||||
upstream.packageName // { version = "v4.0.0" }
|
||||
, packageName =
|
||||
upstream.packageName // { repo = "https://www.example.com/path/to/new/repo.git" }
|
||||
}
|
||||
-------------------------------
|
||||
|
||||
Example:
|
||||
-------------------------------
|
||||
let overrides =
|
||||
{ halogen =
|
||||
upstream.halogen // { version = "master" }
|
||||
, halogen-vdom =
|
||||
upstream.halogen-vdom // { version = "v4.0.0" }
|
||||
}
|
||||
-------------------------------
|
||||
|
||||
### Additions
|
||||
|
||||
Purpose:
|
||||
- Add packages that aren't already included in the default package set
|
||||
|
||||
Syntax:
|
||||
Replace the additions' "{=}" (an empty record) with the following idea:
|
||||
-------------------------------
|
||||
let additions =
|
||||
{ "package-name" =
|
||||
{ dependencies =
|
||||
[ "dependency1"
|
||||
, "dependency2"
|
||||
]
|
||||
, repo =
|
||||
"https://example.com/path/to/git/repo.git"
|
||||
, version =
|
||||
"tag ('v4.0.0') or branch ('master')"
|
||||
}
|
||||
, "package-name" =
|
||||
{ dependencies =
|
||||
[ "dependency1"
|
||||
, "dependency2"
|
||||
]
|
||||
, repo =
|
||||
"https://example.com/path/to/git/repo.git"
|
||||
, version =
|
||||
"tag ('v4.0.0') or branch ('master')"
|
||||
}
|
||||
, etc.
|
||||
}
|
||||
-------------------------------
|
||||
|
||||
Example:
|
||||
-------------------------------
|
||||
let additions =
|
||||
{ benchotron =
|
||||
{ dependencies =
|
||||
[ "arrays"
|
||||
, "exists"
|
||||
, "profunctor"
|
||||
, "strings"
|
||||
, "quickcheck"
|
||||
, "lcg"
|
||||
, "transformers"
|
||||
, "foldable-traversable"
|
||||
, "exceptions"
|
||||
, "node-fs"
|
||||
, "node-buffer"
|
||||
, "node-readline"
|
||||
, "datetime"
|
||||
, "now"
|
||||
],
|
||||
, repo =
|
||||
"https://github.com/hdgarrood/purescript-benchotron.git"
|
||||
, version =
|
||||
"v7.0.0"
|
||||
}
|
||||
}
|
||||
-------------------------------
|
||||
-}
|
||||
|
||||
|
||||
let upstream =
|
||||
https://github.com/purescript/package-sets/releases/download/psc-0.13.3-20190920/packages.dhall sha256:53873cf2fc4a343a41f335ee47c1706ecf755ac7c5a336e8eb03ad23165dfd28
|
||||
|
||||
let overrides = {=}
|
||||
|
||||
let additions = {=}
|
||||
|
||||
in upstream // overrides // additions
|
1
playground/run.js
Normal file
@ -0,0 +1 @@
|
||||
require ("./output/Main").main()
|
13
playground/spago.dhall
Normal file
@ -0,0 +1,13 @@
|
||||
{-
|
||||
Welcome to a Spago project!
|
||||
You can edit this file as you like.
|
||||
-}
|
||||
{ name =
|
||||
"my-project"
|
||||
, dependencies =
|
||||
[ "effect", "console", "psci-support" ]
|
||||
, packages =
|
||||
./packages.dhall
|
||||
, sources =
|
||||
[ "src/**/*.purs", "test/**/*.purs" ]
|
||||
}
|
4
playground/src/Main.purs
Normal file
@ -0,0 +1,4 @@
|
||||
module Main where
|
||||
import Prelude
|
||||
import Effect.Console (log)
|
||||
main = log "Freddy"
|
11
playground/test/Main.purs
Normal file
@ -0,0 +1,11 @@
|
||||
module Test.Main where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Effect (Effect)
|
||||
import Effect.Class.Console (log)
|
||||
|
||||
main :: Effect Unit
|
||||
main = do
|
||||
log "🍝"
|
||||
log "You should add some tests."
|
20
server/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"editor.formatOnSave": false,
|
||||
"regreplace.commands": [
|
||||
{
|
||||
"name": "replace double colon with unicode version",
|
||||
"match": "\\.purs?$",
|
||||
"regexp": " ::(\\s)",
|
||||
"global": true,
|
||||
"replace": " ∷$1"
|
||||
},
|
||||
{
|
||||
"name": "replace forall with unicode version",
|
||||
"match": "\\.purs?$",
|
||||
"regexp": "forall(\\s)",
|
||||
"global": true,
|
||||
"replace": "∀$1"
|
||||
},
|
||||
],
|
||||
"purescript.buildCommand": "spago build --purs-args '--json-errors'",
|
||||
}
|
374
server/package-lock.json
generated
Normal file
@ -0,0 +1,374 @@
|
||||
{
|
||||
"name": "server",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"accepts": {
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
|
||||
"integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
|
||||
"requires": {
|
||||
"mime-types": "~2.1.24",
|
||||
"negotiator": "0.6.2"
|
||||
}
|
||||
},
|
||||
"array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
|
||||
},
|
||||
"body-parser": {
|
||||
"version": "1.19.0",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
|
||||
"integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
|
||||
"requires": {
|
||||
"bytes": "3.1.0",
|
||||
"content-type": "~1.0.4",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~1.1.2",
|
||||
"http-errors": "1.7.2",
|
||||
"iconv-lite": "0.4.24",
|
||||
"on-finished": "~2.3.0",
|
||||
"qs": "6.7.0",
|
||||
"raw-body": "2.4.0",
|
||||
"type-is": "~1.6.17"
|
||||
}
|
||||
},
|
||||
"bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
|
||||
},
|
||||
"content-disposition": {
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
|
||||
"integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
|
||||
"requires": {
|
||||
"safe-buffer": "5.1.2"
|
||||
}
|
||||
},
|
||||
"content-type": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
|
||||
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
|
||||
},
|
||||
"cookie": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
|
||||
"integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
|
||||
},
|
||||
"cookie-signature": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
|
||||
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"depd": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
|
||||
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
|
||||
},
|
||||
"destroy": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
|
||||
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
|
||||
},
|
||||
"ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
|
||||
},
|
||||
"encodeurl": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
||||
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
|
||||
},
|
||||
"escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
|
||||
},
|
||||
"etag": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
|
||||
},
|
||||
"express": {
|
||||
"version": "4.17.1",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
|
||||
"integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
|
||||
"requires": {
|
||||
"accepts": "~1.3.7",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.19.0",
|
||||
"content-disposition": "0.5.3",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.4.0",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~1.1.2",
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "~1.1.2",
|
||||
"fresh": "0.5.2",
|
||||
"merge-descriptors": "1.0.1",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.3.0",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "0.1.7",
|
||||
"proxy-addr": "~2.0.5",
|
||||
"qs": "6.7.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.1.2",
|
||||
"send": "0.17.1",
|
||||
"serve-static": "1.14.1",
|
||||
"setprototypeof": "1.1.1",
|
||||
"statuses": "~1.5.0",
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
}
|
||||
},
|
||||
"finalhandler": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
|
||||
"integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
|
||||
"requires": {
|
||||
"debug": "2.6.9",
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"on-finished": "~2.3.0",
|
||||
"parseurl": "~1.3.3",
|
||||
"statuses": "~1.5.0",
|
||||
"unpipe": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"forwarded": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
|
||||
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
|
||||
},
|
||||
"fresh": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
||||
},
|
||||
"http-errors": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
|
||||
"integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
|
||||
"requires": {
|
||||
"depd": "~1.1.2",
|
||||
"inherits": "2.0.3",
|
||||
"setprototypeof": "1.1.1",
|
||||
"statuses": ">= 1.5.0 < 2",
|
||||
"toidentifier": "1.0.0"
|
||||
}
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
||||
"requires": {
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
},
|
||||
"ipaddr.js": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
|
||||
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
|
||||
},
|
||||
"media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
|
||||
},
|
||||
"merge-descriptors": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
|
||||
"integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
|
||||
},
|
||||
"methods": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
|
||||
},
|
||||
"mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.40.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz",
|
||||
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.24",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz",
|
||||
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
|
||||
"requires": {
|
||||
"mime-db": "1.40.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"negotiator": {
|
||||
"version": "0.6.2",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
|
||||
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
|
||||
},
|
||||
"on-finished": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
|
||||
"integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
|
||||
"requires": {
|
||||
"ee-first": "1.1.1"
|
||||
}
|
||||
},
|
||||
"parseurl": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
|
||||
},
|
||||
"path-to-regexp": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
|
||||
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
|
||||
},
|
||||
"proxy-addr": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
|
||||
"integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==",
|
||||
"requires": {
|
||||
"forwarded": "~0.1.2",
|
||||
"ipaddr.js": "1.9.0"
|
||||
}
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.7.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
|
||||
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
|
||||
},
|
||||
"range-parser": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
|
||||
},
|
||||
"raw-body": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
|
||||
"integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
|
||||
"requires": {
|
||||
"bytes": "3.1.0",
|
||||
"http-errors": "1.7.2",
|
||||
"iconv-lite": "0.4.24",
|
||||
"unpipe": "1.0.0"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"send": {
|
||||
"version": "0.17.1",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
|
||||
"integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
|
||||
"requires": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "~1.1.2",
|
||||
"destroy": "~1.0.4",
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"fresh": "0.5.2",
|
||||
"http-errors": "~1.7.2",
|
||||
"mime": "1.6.0",
|
||||
"ms": "2.1.1",
|
||||
"on-finished": "~2.3.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"statuses": "~1.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ms": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
|
||||
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve-static": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
|
||||
"integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
|
||||
"requires": {
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"parseurl": "~1.3.3",
|
||||
"send": "0.17.1"
|
||||
}
|
||||
},
|
||||
"setprototypeof": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
|
||||
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
|
||||
},
|
||||
"statuses": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
|
||||
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
|
||||
},
|
||||
"toidentifier": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
|
||||
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
|
||||
},
|
||||
"type-is": {
|
||||
"version": "1.6.18",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
|
||||
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
|
||||
"requires": {
|
||||
"media-typer": "0.3.0",
|
||||
"mime-types": "~2.1.24"
|
||||
}
|
||||
},
|
||||
"unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
|
||||
},
|
||||
"utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
|
||||
},
|
||||
"vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
||||
}
|
||||
}
|
||||
}
|
19
server/package.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "server",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "spago run",
|
||||
"test": "spago test"
|
||||
},
|
||||
"author": "mark.eibes@gmail.com",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1"
|
||||
}
|
||||
}
|
@ -9,9 +9,13 @@ You can edit this file as you like.
|
||||
, "effect"
|
||||
, "express"
|
||||
, "maybe"
|
||||
, "node-child-process"
|
||||
, "node-fs"
|
||||
, "node-fs-aff"
|
||||
, "node-process"
|
||||
, "psci-support"
|
||||
, "simple-json"
|
||||
, "stringutils"
|
||||
]
|
||||
, packages =
|
||||
./packages.dhall
|
||||
|
@ -2,48 +2,141 @@ module Main where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Data.Array (unsafeIndex)
|
||||
import Data.Either (Either(..))
|
||||
import Data.Int (fromString)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Maybe (Maybe(..), fromMaybe)
|
||||
import Data.Posix.Signal (Signal(..))
|
||||
import Data.String.Utils (lines)
|
||||
import Effect (Effect)
|
||||
import Effect.Aff (Aff, effectCanceler, launchAff_, makeAff)
|
||||
import Effect.Aff.Class (liftAff)
|
||||
import Effect.Class (class MonadEffect, liftEffect)
|
||||
import Effect.Class.Console (info)
|
||||
import Foreign (unsafeToForeign)
|
||||
import Middleware.JsonBodyParser (jsonBodyParser)
|
||||
import Node.Buffer (Buffer)
|
||||
import Node.Buffer as Buffer
|
||||
import Node.ChildProcess (ExecResult, defaultExecOptions, exec, kill)
|
||||
import Node.Encoding (Encoding(..))
|
||||
import Node.Express.App (App, listenHttp, listenHttps, use)
|
||||
|
||||
import Node.Express.App (App, listenHttp, listenHttps, use, useExternal)
|
||||
import Node.Express.App as E
|
||||
import Node.Express.Handler (HandlerM)
|
||||
import Node.Express.Middleware.Static (static)
|
||||
import Node.FS.Sync (readTextFile)
|
||||
import Node.Express.Request (getBody')
|
||||
import Node.Express.Response as Response
|
||||
import Node.FS.Aff (readTextFile, writeTextFile)
|
||||
import Node.HTTP (Server)
|
||||
import Node.Process (lookupEnv)
|
||||
import Partial.Unsafe (unsafePartial)
|
||||
import Shared.Json (readAff)
|
||||
import Shared.Models.Body (RunResult)
|
||||
import Shared.Models.Body as Body
|
||||
import Simple.JSON (read_, write)
|
||||
|
||||
main ∷ Effect Server
|
||||
main = do
|
||||
toBody ∷ ∀ r m. MonadEffect m => { stdout ∷ Buffer, stderr ∷ Buffer | r } -> m RunResult
|
||||
toBody result = liftEffect $ ado
|
||||
stdout <- Buffer.toString UTF8 result.stdout
|
||||
stderr <- Buffer.toString UTF8 result.stderr
|
||||
let (code ∷ Maybe Int) = asErrorWithCode result >>= _.code
|
||||
in { code, stdout, stderr } ∷ RunResult
|
||||
|
||||
type ErrorWithCode = { code ∷ Maybe Int }
|
||||
|
||||
asErrorWithCode ∷ ∀ a. a -> Maybe ErrorWithCode
|
||||
asErrorWithCode = read_ <<< unsafeToForeign
|
||||
|
||||
compileCode ∷ String -> Aff String
|
||||
compileCode code = do
|
||||
saveMainFile code
|
||||
{ stderr } <- execCommand "spago build -- --json-errors"
|
||||
errorString <- liftEffect $ Buffer.toString UTF8 stderr
|
||||
pure $ unsafePartial (unsafeIndex (lines errorString) 0)
|
||||
|
||||
runCode ∷ Aff ExecResult
|
||||
runCode = execCommand "node run.js"
|
||||
|
||||
playground ∷ String
|
||||
playground = "../playground"
|
||||
|
||||
saveMainFile ∷ String -> Aff Unit
|
||||
saveMainFile code =
|
||||
writeTextFile UTF8 (playground <> "/src/Main.purs") code
|
||||
|
||||
execCommand ∷ String -> Aff ExecResult
|
||||
execCommand command =
|
||||
makeAff \callback -> do
|
||||
let options = defaultExecOptions { cwd = Just playground }
|
||||
childProcess <- exec command options (callback <<< Right)
|
||||
pure $ effectCanceler (kill SIGKILL childProcess)
|
||||
|
||||
compileHandler ∷ HandlerM Unit
|
||||
compileHandler = do
|
||||
body <- getBody'
|
||||
json <- readAff body # liftAff
|
||||
result <- compileCode (json ∷ Body.CompileRequest).code # liftAff
|
||||
Response.send $ write ({ result } ∷ Body.CompileResult)
|
||||
|
||||
runHandler ∷ HandlerM Unit
|
||||
runHandler = do
|
||||
result <- liftAff do
|
||||
result <- runCode
|
||||
toBody result
|
||||
Response.send $ write (result ∷ Body.RunResult)
|
||||
|
||||
main ∷ Effect Unit
|
||||
main = launchAff_ do
|
||||
serverSetup makeApp
|
||||
|
||||
makeApp ∷ App
|
||||
makeApp = do
|
||||
use $ static "assets"
|
||||
useExternal jsonBodyParser
|
||||
E.post "/compile" compileHandler
|
||||
E.post "/run" runHandler
|
||||
-- useOnError (errorHandler log)
|
||||
-- { method: HTTPure.Post, path: ["_compile"], body } -> do
|
||||
-- result <- compileCode body
|
||||
-- HTTPure.ok' (HTTPure.header "Content-Type" "application/json") result
|
||||
|
||||
-- { method: HTTPure.Post, path: ["_run"] } -> do
|
||||
-- result <- runCode
|
||||
-- response <- toBody result
|
||||
-- okJson response
|
||||
|
||||
-- { method: HTTPure.Get, path } | elem path [[], [""], ["/"]] -> do
|
||||
-- content <- readTextFile UTF8 "index.html"
|
||||
-- HTTPure.ok' (HTTPure.header "Content-Type" "text/html") content
|
||||
|
||||
-- { method: HTTPure.Get, path } -> do
|
||||
-- let filePath = intercalate "/" path
|
||||
-- let mimeType = guessMimeType filePath
|
||||
-- content <- readTextFile UTF8 filePath
|
||||
-- HTTPure.ok' (HTTPure.header "Content-Type" mimeType) content
|
||||
|
||||
-- _ -> HTTPure.notFound
|
||||
|
||||
data CertificatesToUse
|
||||
= UseLocalCertificates
|
||||
| DoNotUseLocalCertificates
|
||||
|
||||
parseCertificatesToUse :: String -> CertificatesToUse
|
||||
parseCertificatesToUse ∷ String -> CertificatesToUse
|
||||
parseCertificatesToUse = case _ of
|
||||
"LOCAL" -> UseLocalCertificates
|
||||
_ -> DoNotUseLocalCertificates
|
||||
|
||||
serverSetup ∷ App -> Effect Server
|
||||
serverSetup ∷ App -> Aff Server
|
||||
serverSetup app = do
|
||||
maybePortString <- lookupEnv "PORT"
|
||||
maybePortString <- lookupEnv "PORT" # liftEffect
|
||||
let port = maybePortString >>= fromString # fromMaybe 14188
|
||||
useLocalCertificates <- fromMaybe DoNotUseLocalCertificates <<< map parseCertificatesToUse <$> lookupEnv "CERTS"
|
||||
useLocalCertificates <- fromMaybe DoNotUseLocalCertificates <<< map parseCertificatesToUse <$> lookupEnv "CERTS" # liftEffect
|
||||
listen <- case useLocalCertificates of
|
||||
UseLocalCertificates -> do
|
||||
httpsOptions <- makeHttpsOptions
|
||||
pure $ listenHttps app (port ∷ Int) httpsOptions
|
||||
DoNotUseLocalCertificates ->
|
||||
pure $ listenHttp app port
|
||||
listen \_ -> info $ "psfp server started on port " <> show port
|
||||
liftEffect $ listen \_ -> info $ "psfp server started on port " <> show port
|
||||
where
|
||||
makeHttpsOptions = do
|
||||
key <- readTextFile UTF8 "server.key"
|
||||
|
3
server/src/Middleware/JsonBodyParser.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
exports.jsonBodyParser = require('body-parser').json()
|
9
server/src/Middleware/JsonBodyParser.purs
Normal file
@ -0,0 +1,9 @@
|
||||
module Middleware.JsonBodyParser where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Data.Function.Uncurried (Fn3)
|
||||
import Effect (Effect)
|
||||
import Node.Express.Types (Request, Response)
|
||||
|
||||
foreign import jsonBodyParser :: Fn3 Request Response (Effect Unit) (Effect Unit)
|
@ -1 +1 @@
|
||||
../../Shared/
|
||||
../../shared/Shared
|
2
server/test.json
Normal file
@ -0,0 +1,2 @@
|
||||
{ "code":"module Main where\nimport Prelude\nimport Effect.Console (log)\nmain = log \"Freddy\""
|
||||
}
|
19
shared/Shared/Json.purs
Normal file
@ -0,0 +1,19 @@
|
||||
module Shared.Json (readJsonAff, readAff) where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Data.Either (Either, either)
|
||||
import Effect.Aff (Aff)
|
||||
import Effect.Class (liftEffect)
|
||||
import Effect.Exception (throw)
|
||||
import Foreign (Foreign)
|
||||
import Simple.JSON (class ReadForeign, read, readJSON)
|
||||
|
||||
readJsonAff ∷ ∀ a. ReadForeign a => String -> Aff a
|
||||
readJsonAff = readJSON >>> orThrow
|
||||
|
||||
readAff ∷ ∀ a. ReadForeign a => Foreign -> Aff a
|
||||
readAff = read >>> orThrow
|
||||
|
||||
orThrow ∷ ∀ a s. Show s => Either s a -> Aff a
|
||||
orThrow = either (show >>> throw >>> liftEffect) pure
|
9
shared/Shared/Models/Body.purs
Normal file
@ -0,0 +1,9 @@
|
||||
module Shared.Models.Body where
|
||||
|
||||
import Data.Maybe (Maybe)
|
||||
|
||||
type CompileRequest = { code ∷ String }
|
||||
|
||||
type CompileResult = { result ∷ String }
|
||||
|
||||
type RunResult = { code ∷ Maybe Int, stdout ∷ String, stderr ∷ String }
|
@ -1,892 +0,0 @@
|
||||
'use strict'
|
||||
var monacoEditor = require('@monaco-editor/react');
|
||||
|
||||
exports.editorImpl = monacoEditor.default;
|
||||
|
||||
exports.initMonacoImpl = function() {
|
||||
return monacoEditor.monaco.init();
|
||||
}
|
||||
|
||||
exports.getValue = function(editor) {
|
||||
return function() {
|
||||
return editor.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
exports.defineThemeImpl = function(monacoInstance) {
|
||||
return function(name) {
|
||||
return function(theme) {
|
||||
return function() {
|
||||
return monacoInstance.editor.defineTheme(name, theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.setThemeImpl = function(monacoInstance) {
|
||||
return function(theme) {
|
||||
return function() {
|
||||
return monacoInstance.editor.setTheme(theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.registerLanguageImpl = function(monacoInstance) {
|
||||
return function(languageId) {
|
||||
return function() {
|
||||
monacoInstance.languages.register({ id: languageId})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.setMonarchTokensProviderImpl = function(monacoInstance) {
|
||||
return function(name) {
|
||||
return function(monarchLanguage) {
|
||||
return function() {
|
||||
return monacoInstance.languages.setMonarchTokensProvider(name, monarchLanguage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.nightOwlTheme = {
|
||||
"base": "vs-dark",
|
||||
"inherit": true,
|
||||
"rules": [
|
||||
{
|
||||
"foreground": "637777",
|
||||
"token": "comment"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "string"
|
||||
},
|
||||
{
|
||||
"foreground": "ecc48d",
|
||||
"token": "vstring.quoted"
|
||||
},
|
||||
{
|
||||
"foreground": "ecc48d",
|
||||
"token": "variable.other.readwrite.js"
|
||||
},
|
||||
{
|
||||
"foreground": "5ca7e4",
|
||||
"token": "string.regexp"
|
||||
},
|
||||
{
|
||||
"foreground": "5ca7e4",
|
||||
"token": "string.regexp keyword.other"
|
||||
},
|
||||
{
|
||||
"foreground": "5f7e97",
|
||||
"token": "meta.function punctuation.separator.comma"
|
||||
},
|
||||
{
|
||||
"foreground": "f78c6c",
|
||||
"token": "constant.numeric"
|
||||
},
|
||||
{
|
||||
"foreground": "f78c6c",
|
||||
"token": "constant.character.numeric"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "variable"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "punctuation.accessor"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "storage"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "meta.var.expr"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "meta.class meta.method.declaration meta.var.expr storage.type.jsm"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "storage.type.property.js"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "storage.type.property.ts"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "storage.type.property.tsx"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "storage.type"
|
||||
},
|
||||
{
|
||||
"foreground": "ffcb8b",
|
||||
"token": "entity.name.class"
|
||||
},
|
||||
{
|
||||
"foreground": "ffcb8b",
|
||||
"token": "meta.class entity.name.type.class"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "entity.other.inherited-class"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "entity.name.function"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "punctuation.definition.variable"
|
||||
},
|
||||
{
|
||||
"foreground": "d3423e",
|
||||
"token": "punctuation.section.embedded"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "punctuation.terminator.expression"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "punctuation.definition.arguments"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "punctuation.definition.array"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "punctuation.section.array"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "meta.array"
|
||||
},
|
||||
{
|
||||
"foreground": "d9f5dd",
|
||||
"token": "punctuation.definition.list.begin"
|
||||
},
|
||||
{
|
||||
"foreground": "d9f5dd",
|
||||
"token": "punctuation.definition.list.end"
|
||||
},
|
||||
{
|
||||
"foreground": "d9f5dd",
|
||||
"token": "punctuation.separator.arguments"
|
||||
},
|
||||
{
|
||||
"foreground": "d9f5dd",
|
||||
"token": "punctuation.definition.list"
|
||||
},
|
||||
{
|
||||
"foreground": "d3423e",
|
||||
"token": "string.template meta.template.expression"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "string.template punctuation.definition.string"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"fontStyle": "italic",
|
||||
"token": "italic"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"fontStyle": "bold",
|
||||
"token": "bold"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "constant.language"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "punctuation.definition.constant"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "variable.other.constant"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "support.function.construct"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "keyword.other.new"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "constant.character"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "constant.other"
|
||||
},
|
||||
{
|
||||
"foreground": "f78c6c",
|
||||
"token": "constant.character.escape"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "entity.other.inherited-class"
|
||||
},
|
||||
{
|
||||
"foreground": "d7dbe0",
|
||||
"token": "variable.parameter"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "entity.name.tag"
|
||||
},
|
||||
{
|
||||
"foreground": "cc2996",
|
||||
"token": "punctuation.definition.tag.html"
|
||||
},
|
||||
{
|
||||
"foreground": "cc2996",
|
||||
"token": "punctuation.definition.tag.begin"
|
||||
},
|
||||
{
|
||||
"foreground": "cc2996",
|
||||
"token": "punctuation.definition.tag.end"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "entity.other.attribute-name"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "entity.name.tag.custom"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "support.function"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "support.constant"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "upport.constant.meta.property-value"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "support.type"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "support.class"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "support.variable.dom"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "support.constant"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "keyword.other.special-method"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "keyword.other.new"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "keyword.other.debugger"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "keyword.control"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.operator.comparison"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.flow.js"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.flow.ts"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.flow.tsx"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.module.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.class.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.def.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.loop.js"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.loop.ts"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.import.js"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.import.ts"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.import.tsx"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.from.js"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.from.ts"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.control.from.tsx"
|
||||
},
|
||||
{
|
||||
"foreground": "ffffff",
|
||||
"background": "ff2c83",
|
||||
"token": "invalid"
|
||||
},
|
||||
{
|
||||
"foreground": "ffffff",
|
||||
"background": "d3423e",
|
||||
"token": "invalid.deprecated"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "keyword.operator"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.operator.relational"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.operator.assignement"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.operator.arithmetic"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.operator.bitwise"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.operator.increment"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "keyword.operator.ternary"
|
||||
},
|
||||
{
|
||||
"foreground": "637777",
|
||||
"token": "comment.line.double-slash"
|
||||
},
|
||||
{
|
||||
"foreground": "cdebf7",
|
||||
"token": "object"
|
||||
},
|
||||
{
|
||||
"foreground": "ff5874",
|
||||
"token": "constant.language.null"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "meta.brace"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "meta.delimiter.period"
|
||||
},
|
||||
{
|
||||
"foreground": "d9f5dd",
|
||||
"token": "punctuation.definition.string"
|
||||
},
|
||||
{
|
||||
"foreground": "ff5874",
|
||||
"token": "constant.language.boolean"
|
||||
},
|
||||
{
|
||||
"foreground": "ffffff",
|
||||
"token": "object.comma"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "variable.parameter.function"
|
||||
},
|
||||
{
|
||||
"foreground": "80cbc4",
|
||||
"token": "support.type.vendor.property-name"
|
||||
},
|
||||
{
|
||||
"foreground": "80cbc4",
|
||||
"token": "support.constant.vendor.property-value"
|
||||
},
|
||||
{
|
||||
"foreground": "80cbc4",
|
||||
"token": "support.type.property-name"
|
||||
},
|
||||
{
|
||||
"foreground": "80cbc4",
|
||||
"token": "meta.property-list entity.name.tag"
|
||||
},
|
||||
{
|
||||
"foreground": "57eaf1",
|
||||
"token": "meta.property-list entity.name.tag.reference"
|
||||
},
|
||||
{
|
||||
"foreground": "f78c6c",
|
||||
"token": "constant.other.color.rgb-value punctuation.definition.constant"
|
||||
},
|
||||
{
|
||||
"foreground": "ffeb95",
|
||||
"token": "constant.other.color"
|
||||
},
|
||||
{
|
||||
"foreground": "ffeb95",
|
||||
"token": "keyword.other.unit"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "meta.selector"
|
||||
},
|
||||
{
|
||||
"foreground": "fad430",
|
||||
"token": "entity.other.attribute-name.id"
|
||||
},
|
||||
{
|
||||
"foreground": "80cbc4",
|
||||
"token": "meta.property-name"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "entity.name.tag.doctype"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"token": "meta.tag.sgml.doctype"
|
||||
},
|
||||
{
|
||||
"foreground": "d9f5dd",
|
||||
"token": "punctuation.definition.parameters"
|
||||
},
|
||||
{
|
||||
"foreground": "ecc48d",
|
||||
"token": "string.quoted"
|
||||
},
|
||||
{
|
||||
"foreground": "ecc48d",
|
||||
"token": "string.quoted.double"
|
||||
},
|
||||
{
|
||||
"foreground": "ecc48d",
|
||||
"token": "string.quoted.single"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "support.constant.math"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "support.type.property-name.json"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "support.constant.json"
|
||||
},
|
||||
{
|
||||
"foreground": "c789d6",
|
||||
"token": "meta.structure.dictionary.value.json string.quoted.double"
|
||||
},
|
||||
{
|
||||
"foreground": "80cbc4",
|
||||
"token": "string.quoted.double.json punctuation.definition.string.json"
|
||||
},
|
||||
{
|
||||
"foreground": "ff5874",
|
||||
"token": "meta.structure.dictionary.json meta.structure.dictionary.value constant.language"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "variable.other.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "ecc48d",
|
||||
"token": "entity.name.type.class.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "ecc48d",
|
||||
"token": "keyword.control.class.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "ecc48d",
|
||||
"token": "meta.class.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "constant.language.symbol.hashkey.ruby"
|
||||
},
|
||||
{
|
||||
"foreground": "e0eddd",
|
||||
"background": "a57706",
|
||||
"fontStyle": "italic",
|
||||
"token": "meta.diff"
|
||||
},
|
||||
{
|
||||
"foreground": "e0eddd",
|
||||
"background": "a57706",
|
||||
"fontStyle": "italic",
|
||||
"token": "meta.diff.header"
|
||||
},
|
||||
{
|
||||
"foreground": "ef535090",
|
||||
"fontStyle": "italic",
|
||||
"token": "markup.deleted"
|
||||
},
|
||||
{
|
||||
"foreground": "a2bffc",
|
||||
"fontStyle": "italic",
|
||||
"token": "markup.changed"
|
||||
},
|
||||
{
|
||||
"foreground": "a2bffc",
|
||||
"fontStyle": "italic",
|
||||
"token": "meta.diff.header.git"
|
||||
},
|
||||
{
|
||||
"foreground": "a2bffc",
|
||||
"fontStyle": "italic",
|
||||
"token": "meta.diff.header.from-file"
|
||||
},
|
||||
{
|
||||
"foreground": "a2bffc",
|
||||
"fontStyle": "italic",
|
||||
"token": "meta.diff.header.to-file"
|
||||
},
|
||||
{
|
||||
"foreground": "219186",
|
||||
"background": "eae3ca",
|
||||
"token": "markup.inserted"
|
||||
},
|
||||
{
|
||||
"foreground": "d3201f",
|
||||
"token": "other.package.exclude"
|
||||
},
|
||||
{
|
||||
"foreground": "d3201f",
|
||||
"token": "other.remove"
|
||||
},
|
||||
{
|
||||
"foreground": "269186",
|
||||
"token": "other.add"
|
||||
},
|
||||
{
|
||||
"foreground": "ff5874",
|
||||
"token": "constant.language.python"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "variable.parameter.function.python"
|
||||
},
|
||||
{
|
||||
"foreground": "82aaff",
|
||||
"token": "meta.function-call.arguments.python"
|
||||
},
|
||||
{
|
||||
"foreground": "b2ccd6",
|
||||
"token": "meta.function-call.python"
|
||||
},
|
||||
{
|
||||
"foreground": "b2ccd6",
|
||||
"token": "meta.function-call.generic.python"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "punctuation.python"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"token": "entity.name.function.decorator.python"
|
||||
},
|
||||
{
|
||||
"foreground": "8eace3",
|
||||
"token": "source.python variable.language.special"
|
||||
},
|
||||
{
|
||||
"foreground": "82b1ff",
|
||||
"token": "markup.heading.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "c792ea",
|
||||
"fontStyle": "italic",
|
||||
"token": "markup.italic.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "addb67",
|
||||
"fontStyle": "bold",
|
||||
"token": "markup.bold.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "697098",
|
||||
"token": "markup.quote.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "80cbc4",
|
||||
"token": "markup.inline.raw.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "ff869a",
|
||||
"token": "markup.underline.link.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "ff869a",
|
||||
"token": "markup.underline.link.image.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "string.other.link.title.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "d6deeb",
|
||||
"token": "string.other.link.description.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "82b1ff",
|
||||
"token": "punctuation.definition.string.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "82b1ff",
|
||||
"token": "punctuation.definition.string.begin.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "82b1ff",
|
||||
"token": "punctuation.definition.string.end.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "82b1ff",
|
||||
"token": "meta.link.inline.markdown punctuation.definition.string"
|
||||
},
|
||||
{
|
||||
"foreground": "7fdbca",
|
||||
"token": "punctuation.definition.metadata.markdown"
|
||||
},
|
||||
{
|
||||
"foreground": "82b1ff",
|
||||
"token": "beginning.punctuation.definition.list.markdown"
|
||||
}
|
||||
],
|
||||
"colors": {
|
||||
"editor.foreground": "#d6deeb",
|
||||
"editor.background": "#011627",
|
||||
"editor.selectionBackground": "#5f7e9779",
|
||||
"editor.lineHighlightBackground": "#010E17",
|
||||
"editorCursor.foreground": "#80a4c2",
|
||||
"editorWhitespace.foreground": "#2e2040",
|
||||
"editorIndentGuide.background": "#5e81ce52",
|
||||
"editor.selectionHighlightBorder": "#122d42"
|
||||
}
|
||||
}
|
||||
|
||||
exports.purescriptSyntax = {
|
||||
"displayName": "Purescript",
|
||||
"name": "purescrript",
|
||||
"mimeTypes": ["text/purescript"],
|
||||
"fileExtensions": ["purs"],
|
||||
|
||||
"editorOptions": { "tabSize": 2, "insertSpaces": true },
|
||||
|
||||
"lineComment": "--",
|
||||
"blockCommentStart": "{-",
|
||||
"blockCommentEnd": "-}",
|
||||
|
||||
"keywords": [
|
||||
"case", "class", "data", "derive", "do", "else",
|
||||
"if", "import", "in", "infix", "infixl", "infixr", "instance",
|
||||
"let", "module", "newtype", "of", "then", "type", "where",
|
||||
"->", "|", "=>", "::", "\\", "=", "|", "foreign", "forall", "∷"
|
||||
],
|
||||
|
||||
"extraKeywords": [
|
||||
],
|
||||
|
||||
"typeKeywords": [
|
||||
],
|
||||
|
||||
"dataStart": [
|
||||
"^data"
|
||||
],
|
||||
|
||||
"typeStart": [
|
||||
"class","instance","type", "derive"
|
||||
],
|
||||
|
||||
|
||||
"escapes" : "\\\\(?:[nrt\\\\\"'\\?]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{6})",
|
||||
"symbols0": "[\\$%&\\*\\+@!\\/\\\\\\^~=\\.:\\-\\?]",
|
||||
"symbols" : "(?:@symbols0|[\\|<>])+",
|
||||
"idchars" : "(?:[\\w'])*",
|
||||
|
||||
"tokenizer": {
|
||||
"root": [
|
||||
|
||||
["((?:[A-Z]@idchars\\.)+)([a-z]@idchars)", ["identifier.namespace","identifier"]],
|
||||
["((?:[A-Z]@idchars\\.)+)([A-Z]@idchars)", ["identifier.namespace","constructor"]],
|
||||
|
||||
["[a-z]@idchars(?!\\.)",
|
||||
{ "cases":{ "@dataStart": { "token": "keyword", "next" : "@type_data" },
|
||||
"@typeStart": { "token": "keyword", "next" : "@type_type" },
|
||||
"@keywords": "keyword",
|
||||
"@extraKeywords": "keyword",
|
||||
"@default" : "identifier" }
|
||||
}
|
||||
],
|
||||
|
||||
["[A-Z]@idchars", "type.identifier" ],
|
||||
|
||||
["_@idchars", "identifier.wildcard"],
|
||||
|
||||
|
||||
["([a-z]@idchars\\.)+", "identifier.namespace" ],
|
||||
|
||||
|
||||
{ "include": "@whitespace" },
|
||||
|
||||
["[{}()\\[\\]]", "@brackets"],
|
||||
["[,`]", "delimiter"],
|
||||
|
||||
|
||||
["::(?!@symbols0)", "type.operator", "@type_line"],
|
||||
["@symbols", { "cases": { "@keywords": "keyword.operator",
|
||||
"@extraKeywords": "keyword.operator",
|
||||
"@default": "operator" }}
|
||||
],
|
||||
|
||||
|
||||
["[0-9]+\\.[0-9]+([eE][\\-+]?[0-9]+)?", "number.float"],
|
||||
["0[xX][0-9a-fA-F]+", "number.hex"],
|
||||
["[0-9]+", "number"],
|
||||
|
||||
|
||||
["\"([^\"\\\\]|\\\\.)*$", "string.invalid" ],
|
||||
["\"", { "token": "string.quote", "bracket": "@open", "next": "@string" } ],
|
||||
|
||||
|
||||
["'[^\\\\']'", "string"],
|
||||
["(')(@escapes)(')", ["string","string.escape","string"]],
|
||||
["'", "string.invalid"],
|
||||
|
||||
|
||||
["^[ ]*#.*", "namespace"]
|
||||
],
|
||||
|
||||
"whitespace": [
|
||||
["[ \\r\\n]+", ""],
|
||||
["{-", "comment", "@comment" ],
|
||||
["--.*$", "comment"]
|
||||
],
|
||||
|
||||
"comment": [
|
||||
["[^\\{\\-]+", "comment" ],
|
||||
["{-", "comment", "@push" ],
|
||||
["-}", "comment", "@pop" ],
|
||||
["[\\{\\-]", "comment"]
|
||||
],
|
||||
|
||||
"string": [
|
||||
["[^\\\\\"]+", "string"],
|
||||
["@escapes", "string.escape"],
|
||||
["\\\\.", "string.escape.invalid"],
|
||||
["\"", { "token": "string.quote", "bracket": "@close", "next": "@pop" } ]
|
||||
],
|
||||
|
||||
"type_type": [
|
||||
[ "\\=", "keyword"],
|
||||
["^\\s*(?!\\-\\-|\\{\\-)[^\\s]", { "token": "@rematch", "next": "@pop" } ],
|
||||
{ "include": "@type" }
|
||||
],
|
||||
|
||||
"type_data": [
|
||||
[ "([=|])(\\s*)([A-Z]@idchars)", ["keyword.operator","","constructor"]],
|
||||
["^\\s*$", { "token": "", "next": "@pop" } ],
|
||||
{ "include": "@type" }
|
||||
],
|
||||
|
||||
"type_line": [
|
||||
["^\\s*(?!\\-\\-|\\{\\-)[_a-z]", { "token": "@rematch", "next": "@pop" } ],
|
||||
["[^=]*=", { "token": "@rematch", "next": "@pop" } ],
|
||||
{ "include": "@type" }
|
||||
],
|
||||
|
||||
"type": [
|
||||
[ "[(\\[]", { "token": "@brackets.type" }, "@type_nested"],
|
||||
{ "include": "@type_content" }
|
||||
],
|
||||
|
||||
"type_nested": [
|
||||
["[)\\]]", { "token": "@brackets.type" }, "@pop" ],
|
||||
["[(\\[]", { "token": "@brackets.type" }, "@push"],
|
||||
[",", "delimiter.type"],
|
||||
{ "include": "@type_content" }
|
||||
],
|
||||
|
||||
"type_content": [
|
||||
{ "include": "@whitespace" },
|
||||
|
||||
|
||||
["[a-z]\\d*\\b", "type.identifier.typevar"],
|
||||
["_@idchars", "type.identifier.typevar"],
|
||||
|
||||
["((?:[A-Z]@idchars\\.)*)([A-Z]@idchars)",
|
||||
["type.identifier.namespace","type.identifier"]
|
||||
],
|
||||
["((?:[A-Z]@idchars\\.)*)([a-z]@idchars)",
|
||||
{ "cases": { "@typeKeywords": ["type.identifier.namespace","type.keyword"],
|
||||
"@keywords": { "token": "@rematch", "next": "@pop" },
|
||||
"@default": ["type.identifier.namespace","type.identifier"]
|
||||
}}
|
||||
],
|
||||
|
||||
["::|->|[\\.:|]", "type.operator"],
|
||||
["[\\s\\S]","@rematch","@pop"]
|
||||
]
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
../Shared
|