Coder Social home page Coder Social logo

broom-lang / broom Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 2.29 MB

A programming language with first-class modules and algebraic effects.

Home Page: https://broom.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

OCaml 91.58% Makefile 0.44% TeX 5.23% Rust 2.40% Shell 0.13% Vim Script 0.21%
modules algebraic-effects row-polymorphism compiler broom programming-language type-inference generalized-algebraic-data-type implicit type-class

broom's Introduction

Broom

Broom logo

A programming language with first-class modules and algebraic effects. Still very much a work in progress (i.e. not yet usable).

(Planned) Features

  • Functional-first, with strict evaluation
  • ML-style module system with higher-order, recursive and first-class modules
    • Records and modules are the same, à la 1ML
    • First-class ML-modules also provide higher-ranked and higher kinded types
      • with impredicative instantiation
    • Modular implicits support ad-hoc polymorphism and type level programming
  • Algebraic effects and effect handlers
  • Row typed modules, records, polymorphic variants and effects
  • Conventional and simplified syntax
    • extensible with procedural hygienic macros
  • Optimizing whole-program compilation to Javascript or (later) native code

(Abstract) Syntax

program ::= defs
repl_input ::= stmts

stmt ::= def | expr
stmts ::= (stmt (";" stmt)*)? ";"?
alts ::= (stmt ("|" stmt)*)? "|"?

def ::= pat "=" expr
defs ::= (def (";" def)*)? ";"?

exprs ::= types ::= (expr ("," expr)*)? ","?

expr ::=
pat ::=
type ::= 
    | type ("-!" type)? "->" type
    | type "=>" type

    | expr ":" type
    | expr "||" expr
    | expr "&&" expr
    | expr ("==" | "<" | "<=" | ">" | ">=") expr
    | expr ("+" | "-") expr
    | expr ("*" | "/") expr
    | expr OTHER_INFIX expr
    | expr expr+
    | PREFIX expr
    | expr POSTFIX
    | expr "." ID

    | "{" ("|" pat ("," pat)* "->" expr)+ "}" (* function literal *)
    | "{" "|" "->" stmts "}" (* thunk *)
    | "{" "|" "}" (* empty function (uncallable) *)
    | "{" ("|" pat ("," pat)* "=>" expr)+ "}" (* implicit function literal *)
    | "{" stmts "}"
    | "[" exprs "]"
    | "(" exprs ")"
    | "(" ( "||" | "&&"
          | "==" | "<" | "<=" | ">" | ">="
          | "+" | "-"
          | "*" | "/" | "%" ) ")"
    | "{" ":" stmts ")"
    | "[" "|" alts "]"
    | "(" "|" alts ")"
    | "(" ":" types ")"

    | ID
    | "_"
    | CONST

See the intro for a slightly more detailed exposition.

broom's People

Contributors

nilern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dorstm

broom's Issues

Build on sml/nj

NJ uses its own CM format instead of MLB files. For extra points, generate the CM and MLB from the same source with cm2mlb or similar.

"Marketing" documentation

Add some exposition of goals/features/syntax so that people can decide whether they want to contribute to or (eventually) use this.

Complect lambdas

Fn and TFn should be fused as in 1ML so that type lambdas have no runtime component that the compiler needs to reason about (closures, passing continuation to calls etc.).

Effect rows and handlers

ATM we just have the pure/impure distinction of 1ML. I would like something like Koka or Multicore OCaml. There will be nontrivial interactions with 'large' (higher-rank etc.) types and functor generativity.

Polymorphic intrinsics

(Parametrically) polymorphic intrinsics for e.g. arrays.

  • Higher-kinded primitive array type
  • Array ops (new, length, index, initialize)
  • Array type op
  • Evaluation

Convenient variable representation for FAst

Some sort of use-def/def-use pointers and stuff like in the imperative version of "Shrinking Lambda Expressions in Linear Time" and "Shrinking Reductions in SML.NET" would be convenient for optimization. Alphatization is not as convenient and mangles the names, which is bad for debugging and especially error messages.

E.g. ATM the well-foundedness analysis must construct scope trees to deal properly with scoping without mangling the names (to keep error messages intelligible).

`do` vs. `begin`/`module` distinction

  • begin and module (and toplevel) contain recursive, unique definitions. Runtime effects are forbidden because of the continuation capturing variable initialization trainwreck, but it also makes sense on a higher level to demand purity. The 'dynamically determined implementation of static type' effect should be allowed though. Could even ban expression-statements here is since they are useless anyway.
  • do contains sequential statements that can have side effects and shadow names.
  • Change do -> begin
  • Add sequential do
  • Ban effects in recursive contexts

Clarify (and extend) record (type) constructs' syntax and implementations

Empty, extension (with), update (where), restriction (without) for records, modules, record types, interfaces. Also field access and patterns for records and modules.

  • Spec
  • with and where for records
  • with and where for record types
  • extends and override syntax for modules and interfaces
  • without for records and record types, exclude for modules and interfaces

Trivial contification

Obviously local functions should not cause closure allocation. With a bit more effort this can also subsume conversion of (self) tail recursion to loops.

Modular implicits

The 'anti-modularity' of type classes is even more awkward with first-class modules than regular ones. Plus we don't have generalization so type class parameters can't be inferred any more than implicit parameters. Obviously the challenge with implicits is that implicit search must be exhaustive, which is potentially very slow.

  • Enable backtracking wrt. unification variables
  • Match implicit fn codomains before domains in subtyping and unification
  • Schedule resolutions for when unification variables go out of scope
  • Ensure termination of resolution

Vim mode

We do have some rudimentary highlighting support in /vim.

'Zero-cost' functor fixpointing support

I.e. the box trickery from "A Type System for Well-Founded Recursion", except that we would only use it for functor parameters (and not local recursion as that paper does also).

Custom infix operators

Much as in Haskell, except we need to deal with more advanced modules which I've heard can get tedious.

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.