montylang / monty Goto Github PK
View Code? Open in Web Editor NEWLanguage from a parallel universe where Python is functional
Home Page: https://montylang.github.io/docs/
License: BSD 3-Clause "New" or "Revised" License
Language from a parallel universe where Python is functional
Home Page: https://montylang.github.io/docs/
License: BSD 3-Clause "New" or "Revised" License
We should be clever enough to support return from anywhere in a function (at parse time?). If there are branches that don't have return statements, that should be a parse error
It's not all that common in functional style, but it's common for Python programmers. Generally, using map
and bind
to create new lists is more FP-idiomatic
We should have a simple repl, that imports a file (not running the main IO), and you can evaluate any single-line expression - which gets automatically wrapped in a debug
To compile to LLVM or some other bytecode, we'll have to improve our inference.
For example:
def add(a, b):
return (x): str(x) + "," + str(a + b)
x = add(3, 7)
y = x("hi")
# Generate def add(a: int, b: int) -> (str -> str):
z = x(3.14)
# Generate def add(a: int, b: int) -> (float -> str):
In the case where a function type cannot be inferred, it's considered a no-op.
e.g.
x = add(3,7)
This expression alone doesn't do anything, because the function returned by add
and assigned to x
is never used.
It's very slow right now :( We probably need to have a simple preparser for lexing
Specifically, reassignments of classes, typecons, and pattern matched assignments slip through.
This works:
return apply(wrap(append("hi: ")), readInt())
But this doesn't:
return apply(wrap(append("Number is: ")), readInt())
E.g. (first, second) <- someTupleMonad
Here's an example
len(s) > 0 and s.foldl(True, (acc, it): acc and isDigit(it))
and
has higher priority than >
Monty lives in pure functional land right now. We need an IO monad entry point!
The __main__
thunk function should be the entry point to the "real world"
This should be handled in the semantic parser, really.
We should support case / match statements, supporting the same pattern matching that our functions do
IO should work more like StateT. Functions should return functions that are only evaluated inside of main.
It should be a very fundamental networking API - higher level functionality (e.g. HTTP) should be entirely implemented in Monty itself
We need to implement a pass
keyword, similar to undefined
in Haskell
Unwrap should support assignments, and allow non-binding non-terminal expressions.
The assignments should behave similar to how they work imperatively
We don't support -
and not
We can probably be clever with allocations for ADTs with few parameters. As in, pass them by value rather than allocate memory for all of them. A Maybe or Either type takes up a trivial amount more memory than whatever it contains, so it's probably worth just copying it instead of returning a reference or passing a reference to a function.
If all elements in an ADT only have 1 data slot, pass them by value instead of reference
In version 1 of the compiler we're just making everything a closure, which is a bit pointless for functions that only have root level references
The V1 allocator will be pretty dumb with lists, slotting them wherever possible. To utilize the cache better, we should try to store lists in contiguous memory.
Extending onto this, if you map
over a list, it can trivially be given a contiguous memory block
Instead of recompiling the entire stdlib for every program, cache the compiled libraries
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.