gleam-lang / gleam Goto Github PK
View Code? Open in Web Editor NEW⭐️ A friendly language for building type-safe, scalable systems!
Home Page: https://gleam.run
License: Apache License 2.0
⭐️ A friendly language for building type-safe, scalable systems!
Home Page: https://gleam.run
License: Apache License 2.0
It may be worth doing this to avoid confusion with Erlang records
import lib:SomeType
enum Thing =
| A(SomeType)
enum PrivateType = P;
pub fn go() {
P // Invalid, private type would be leaked out of module here
}
1 |> run
Parsing and typing is done, but the code generator is currently incorrect.
This name seems clearer and avoids any association with the language of xenophobia.
pub external fn new(a) -> Any = 'gleam_foreign' 'identity'
https://github.com/TeXitoi/structopt
Seems better than clap as it has a type safe API. Need to check that the user experience is as nice.
type IntMap = Map(Int, Int)
All are optional
fn id(x: Int) -> Int {
x
}
For use in Elixir projects
doc """
Say hello to a person
"""
fn greet(name) {
"Hello, " <> name <> "!"
}
http://erlang.org/eeps/eep-0048.html
https://github.com/elixir-lang/elixir/blob/master/lib/elixir/src/elixir_erl.erl
pub external type Name
Maybe https://github.com/efene/efene/blob/master/src/fn_repl.erl can serve as an example
Just a reminder issue to discuss using =>
for functions vs ->
, which is more Erlang-aligned.
To improve stacktraces.
Example from Alpaca: alpaca-lang/alpaca#258
Module for use by the compiler.
Expression for use by the repl.
enum Maybe =
| Just(Whatever) // What is this?
| Nothing
{ok, Pattern} = re:compile("abc\\s").
edit: See comments below for current status.
gleam format path/to/file.gleam
Reuse the pretty printing algebra used for Erlang code generation. Effectively it's a new compiler backend that skips type inference and compiles to Gleam.
Strip the comments out, parse the remaining AST, traverse the AST and use positions in the AST and the comments to determine where to annotate which nodes with which comments.
Custom lalrpop tokenizer:
Syntax error:
pub fn go() {
True |> run
1
}
OK:
pub fn go() {
let a = True |> run
1
}
This is not obvious or friendly.
My parser-fu isn't the best, so I would welcome advice from others on the best way to improve the grammar here.
Existing example in Alpaca: https://github.com/alpaca-lang/alpaca/blob/master/Tour.md#processes. A limited approach as it's not possible to implement something such as an OTP supervisor with it (without using FFI to cheat the type system)
Imitate the erlc
CLI http://erlang.org/doc/man/erlc.html
https://github.com/lpil/gleam/blob/17ed8014292e4b95f1fcaa503328dad6e72fef59/src/gleam_parser.yrl#L17
These should all be left-associative with precedence between that of comparisons and *
, /
. Elixir has them at precedence 210 (elixir_parser.yrl).
foo(_, 1)
Is equivalent to
fn(x) { foo(x, 1) }
my_mod:func()
Current syntax:
module Calculator
exposing add/2, sub/2, div/2, mult/2
fn add(a, b) {
a + b
}
fn sub(a, b) {
a - b
}
fn div(a, b) {
a / b
}
fn mult(a, b) {
a * b
}
Proposed syntax:
pub fn add(a, b) {
a + b
}
pub fn sub(a, b) {
a - b
}
pub fn div(a, b) {
a / b
}
pub fn mult(a, b) {
a * b
}
After reading about the OCaml implicit module PR I've had the idea for a system of implicit parameters bouncing round my head, giving Gleam a way of producing polymorphic functions such as enum:map
which could operate on more than 1 type of data structure with less boilerplate.
Now it seems Scala has a very similar system already! A good place to start research.
https://docs.scala-lang.org/tour/implicit-parameters.html
https://docs.scala-lang.org/tutorials/FAQ/finding-implicits.html
http://2ality.com/2018/01/polymorphic-variants-reasonml.html
I like the extendibility here, I could imagine extendable error unions to be very useful. Perhaps having an explicit extension syntax would be good alternative to fully polymorphic variants.
enum MyError extends LibraryError =
| ExtraError
| AnotherError
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.