purescript / purescript Goto Github PK
View Code? Open in Web Editor NEWA strongly-typed language that compiles to JavaScript
Home Page: https://www.purescript.org
License: Other
A strongly-typed language that compiles to JavaScript
Home Page: https://www.purescript.org
License: Other
The only difference right now is ; vs ,
Seems useful to make them match, for tooling, familiarity, etc
foreach x in xs
... many statements
In the loop body, x will not be assignable
Currently the only mutation allowed is restricted to variables brought into existence with a block, and blocks are fully escaped at the end of the function they appear in.
This means that DOM manipulation / querying is basically not possible to use.
One proposal is to introduce an IO :: * -> *
type, and allow for expressions of type IO {}
to be used as "statements" within do
syntax (which would no longer allow that do
block to be fully pure at the edge, and so it would have to have a type of IO returnType
. The var
syntax could be extended to allow for: var x <- something
where something :: IO a
and x :: a
This would compile to the same code you can currently get by lying to the type system and saying the items are pure.
\x y z ->
instead of \x -> \y -> \z ->
Object accessors should be higher precedence than function application
E.g.
foo = \x -> do
var copy = x
copy.bar = 1
return copy
mutates the argument x
. Need to deep copy non-primitive values when mutation happens, or at the least, when an assignment happens at a non-primitive type.
E.g.
[ 1, 2, 3 ; xs ]
where xs
is a [Number]
, as in the case of pattern matching
Implement a module system
E.g. var null = ...
gives an error in Node after compilation.
Thoughts? Do they add more problems than they solve?
Type synonyms don't get expanded when calling a function with a type synonym in its signature
a -> b
should be a shorthand for (a) -> b
foo = foo
compiles but gives a runtime error foo
is not defined
See TODO in TypeChecker/Types.hs
Named patterns with @
The data Person = Person {
example in README give me a syntax error, unexpected '{' when I try to compile it with psc.
See libraries/jquery
for a starting point.
Implement type classes or implicits
Guards in patterns
For things like IO
Write wrapper functions for standard Javascript methods.
Support obj { label_1 = value_1, ..., label_n = value_n }
syntax
Especially the use of : which makes it look like matching inside a single element array when the pattern is just [x:xs]
Need to implement type synonyms before TypeScript integration can be implemented nicely.
With whitespace sensitive syntax, we can ditch unnecessary braces and employ lightweight syntax for control flow, such as
while x > 1
x = x / 2
x = x - 1
if x % 2 == 0
return x
else
return y
Currently there is support for if then else
, but not else if
Instead of using show
in type errors, pretty print the values and types involved.
Functions cannot forward reference other functions
Optional exhaustivity checking / warnings
Use indents package to implement white space sensitive syntax.
Wrap the pure functions on the Javascript Date
type
As opposed to full-system tests
o { key = value}
Need to address a problem in the typechecker where things like
\o -> case o of
{ foo = "Bar" } -> o { foo = "Foo" }
gets an inferred type
forall r. { foo :: String; foo :: String | r } -> { foo :: String; foo :: String | r }
When the row gets subtituted into the solution set, we need to be more careful about avoiding duplicate properties.
For now the workaround is
\o -> case o of
{ foo = "Bar" } -> do
var copy = o
o.foo = "Foo"
return copy
To expose a PureScript library to TypeScript, we can generate .d.ts
files from an externs file.
I started working on some tests using shelltestrunner
. It would be nice to have some more.
extern DOM :: *
fails to compile -- am I getting the syntax wrong?
The two type systems are quite similar. It should be possible to translate type definitions into Typescript declaration source files easily
E.g.
test pattern1 = y
test pattern2 = z
...
would be desugared to
test = \x -> case x of { pattern1 -> y, pattern2 -> z ... }
{ foo: 0 } { foo = 1 }
currently gets the (technically fine, but bothersome) type { foo: Number, foo: Number }
.ps
is widely recognised as PostScript.
I reccomend going for the whole thing and using .purescript
, but others could be fine.
It would be nice for interop with libraries like JQuery if we could use undefined in a type safe way. It is common to pass an options object with some of its fields being undefined.
s = \x -> \y -> \z -> x z (y z)
gives a stack overflow when pretty printing externs with -e
To allow for optimizations on the generated JS later.
Support if-then-else at the expression level as well as at the statement level
Support infix operators
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.