Coder Social home page Coder Social logo

purescript / purescript Goto Github PK

View Code? Open in Web Editor NEW
8.5K 155.0 562.0 13.46 MB

A strongly-typed language that compiles to JavaScript

Home Page: https://www.purescript.org

License: Other

Haskell 69.62% Shell 0.59% PureScript 26.16% JavaScript 0.85% CSS 0.69% Makefile 0.11% Yacc 1.18% Less 0.74% Dhall 0.06%
haskell purescript javascript typed-language alt-js

purescript's Issues

For Each

foreach x in xs
    ... many statements

In the loop body, x will not be assignable

Allowing for impurity

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.

Object/Array mutation can be witnessed outside block

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.

Modules

Implement a module system

Type Synonym Problem

Type synonyms don't get expanded when calling a function with a type synonym in its signature

Example does not compile

The data Person = Person { example in README give me a syntax error, unexpected '{' when I try to compile it with psc.

Prelude

Write wrapper functions for standard Javascript methods.

Type Synonyms

Need to implement type synonyms before TypeScript integration can be implemented nicely.

Lightweight syntax for while/if/for

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

Else If

Currently there is support for if then else, but not else if

Date Library

Wrap the pure functions on the Javascript Date type

Object Update Syntax

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

Add more tests

I started working on some tests using shelltestrunner. It would be nice to have some more.

Top level pattern matching

E.g.

test pattern1 = y
test pattern2 = z
...

would be desugared to

test = \x -> case x of { pattern1 -> y, pattern2 -> z ... }

Use a different file extension

.ps is widely recognised as PostScript.
I reccomend going for the whole thing and using .purescript, but others could be fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.