mirror of
https://github.com/kanaka/mal.git
synced 2024-10-05 18:08:55 +03:00
feat: purscript step0
This commit is contained in:
parent
ba5d23b342
commit
fc59ff9e49
1
.psc-ide-port
Normal file
1
.psc-ide-port
Normal file
@ -0,0 +1 @@
|
||||
15273
|
@ -38,7 +38,7 @@ IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lis
|
||||
elisp elixir elm erlang es6 factor fantom fennel forth fsharp go groovy gnu-smalltalk \
|
||||
guile haskell haxe hy io janet java java-truffle js jq julia kotlin livescript logo lua make mal \
|
||||
matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp pike plpgsql \
|
||||
plsql powershell prolog ps python python.2 r racket rexx rpython ruby ruby.2 rust scala scheme skew sml \
|
||||
plsql powershell prolog ps purs python python.2 r racket rexx rpython ruby ruby.2 rust scala scheme skew sml \
|
||||
swift swift3 swift4 swift5 tcl ts vala vb vhdl vimscript wasm wren yorick xslt zig
|
||||
|
||||
step5_EXCLUDES += bash # never completes at 10,000
|
||||
@ -168,6 +168,7 @@ plsql_STEP_TO_PROG = impls/plsql/$($(1)).sql
|
||||
powershell_STEP_TO_PROG = impls/powershell/$($(1)).ps1
|
||||
prolog_STEP_TO_PROG = impls/prolog/$($(1)).pl
|
||||
ps_STEP_TO_PROG = impls/ps/$($(1)).ps
|
||||
purs_STEP_TO_PROG = impls/purs/$($(1)).js
|
||||
python_STEP_TO_PROG = impls/python/$($(1)).py
|
||||
python.2_STEP_TO_PROG = impls/python.2/$($(1)).py
|
||||
r_STEP_TO_PROG = impls/r/$($(1)).r
|
||||
|
12
impls/purs/.gitignore
vendored
Normal file
12
impls/purs/.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/bower_components/
|
||||
/node_modules/
|
||||
/.pulp-cache/
|
||||
/output/
|
||||
/generated-docs/
|
||||
/.psc-package/
|
||||
/.psc*
|
||||
/.purs*
|
||||
/.psa*
|
||||
/.spago
|
||||
|
||||
/step*.js
|
7
impls/purs/Makefile
Normal file
7
impls/purs/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
src/step%:
|
||||
spago bundle-app --main ${${@F}} --to $(@F:%.purs=%.js)
|
||||
|
||||
|
||||
#####################
|
||||
|
||||
step0_repl.purs = Mal.Step0
|
5
impls/purs/package.json
Normal file
5
impls/purs/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"readline-sync": "^1.4.10"
|
||||
}
|
||||
}
|
104
impls/purs/packages.dhall
Normal file
104
impls/purs/packages.dhall
Normal file
@ -0,0 +1,104 @@
|
||||
{-
|
||||
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.
|
||||
|
||||
## 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:
|
||||
where `entityName` is one of the following:
|
||||
- dependencies
|
||||
- repo
|
||||
- version
|
||||
-------------------------------
|
||||
let upstream = --
|
||||
in upstream
|
||||
with packageName.entityName = "new value"
|
||||
-------------------------------
|
||||
|
||||
Example:
|
||||
-------------------------------
|
||||
let upstream = --
|
||||
in upstream
|
||||
with halogen.version = "master"
|
||||
with halogen.repo = "https://example.com/path/to/git/repo.git"
|
||||
|
||||
with halogen-vdom.version = "v4.0.0"
|
||||
with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies
|
||||
-------------------------------
|
||||
|
||||
### Additions
|
||||
|
||||
Purpose:
|
||||
- Add packages that aren't already included in the default package set
|
||||
|
||||
Syntax:
|
||||
where `<version>` is:
|
||||
- a tag (i.e. "v4.0.0")
|
||||
- a branch (i.e. "master")
|
||||
- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977")
|
||||
-------------------------------
|
||||
let upstream = --
|
||||
in upstream
|
||||
with new-package-name =
|
||||
{ dependencies =
|
||||
[ "dependency1"
|
||||
, "dependency2"
|
||||
]
|
||||
, repo =
|
||||
"https://example.com/path/to/git/repo.git"
|
||||
, version =
|
||||
"<version>"
|
||||
}
|
||||
-------------------------------
|
||||
|
||||
Example:
|
||||
-------------------------------
|
||||
let upstream = --
|
||||
in upstream
|
||||
with 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.14.2-20210713/packages.dhall sha256:654c3148cb995f642c73b4508d987d9896e2ad3ea1d325a1e826c034c0d3cd7b
|
||||
|
||||
in upstream
|
2
impls/purs/run
Executable file
2
impls/purs/run
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}"
|
17
impls/purs/spago.dhall
Normal file
17
impls/purs/spago.dhall
Normal file
@ -0,0 +1,17 @@
|
||||
{-
|
||||
Welcome to a Spago project!
|
||||
You can edit this file as you like.
|
||||
|
||||
Need help? See the following resources:
|
||||
- Spago documentation: https://github.com/purescript/spago
|
||||
- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html
|
||||
|
||||
When creating a new Spago project, you can use
|
||||
`spago init --no-comments` or `spago init -C`
|
||||
to generate this file without the comments in this block.
|
||||
-}
|
||||
{ name = "mal-purescript"
|
||||
, dependencies = [ "console", "effect", "prelude", "psci-support" ]
|
||||
, packages = ./packages.dhall
|
||||
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
|
||||
}
|
12
impls/purs/src/Readline.js
Normal file
12
impls/purs/src/Readline.js
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var readlineSync = require('readline-sync')
|
||||
|
||||
exports.readLine = function (x) {
|
||||
return function () {
|
||||
return readlineSync.question(x)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
exports.argv = process.argv;
|
9
impls/purs/src/Readline.purs
Normal file
9
impls/purs/src/Readline.purs
Normal file
@ -0,0 +1,9 @@
|
||||
module Readline where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Effect (Effect)
|
||||
|
||||
|
||||
|
||||
foreign import readLine :: String -> Effect String
|
38
impls/purs/src/step0_repl.purs
Normal file
38
impls/purs/src/step0_repl.purs
Normal file
@ -0,0 +1,38 @@
|
||||
module Mal.Step0 where
|
||||
|
||||
import Prelude
|
||||
import Effect (Effect)
|
||||
import Effect.Console (log)
|
||||
import Readline (readLine)
|
||||
|
||||
|
||||
|
||||
main :: Effect Unit
|
||||
main = loop
|
||||
|
||||
|
||||
loop :: Effect Unit
|
||||
loop = do
|
||||
line <- readLine "user> "
|
||||
case line of
|
||||
":q" -> pure unit
|
||||
":Q" -> pure unit
|
||||
_ -> do
|
||||
log line
|
||||
loop
|
||||
|
||||
|
||||
read :: String -> String
|
||||
read s = s
|
||||
|
||||
|
||||
eval :: String -> String
|
||||
eval s = s
|
||||
|
||||
|
||||
print :: String -> String
|
||||
print s = s
|
||||
|
||||
|
||||
rep :: String -> String
|
||||
rep = read >>> eval >>> print
|
Loading…
Reference in New Issue
Block a user