Skip to content

Commit

Permalink
Significant surface language redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
fmease committed May 7, 2023
1 parent 4066ed8 commit 3e18045
Show file tree
Hide file tree
Showing 144 changed files with 6,371 additions and 5,297 deletions.
1 change: 0 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ rustflags = [
"-Aclippy::missing_panics_doc", # @Temporary, a churn to fix, not a priority right now
"-Aclippy::module_name_repetitions", # false positives, too opinionated
"-Aclippy::must_use_candidate", # @Temporary, a churn to fix, not a priority right now
"-Aclippy::needless_pass_by_value", # @Temporary, a churn to fix, not a priority right now
"-Aclippy::result_unit_err", # ‘Result<_, ()>’ has its uses, in some cases an alt. to ‘Option<_>’
"-Aclippy::return_self_not_must_use", # @Temporary, a churn to fix, not a priority right now
"-Aclippy::similar_names", # too strict
Expand Down
42 changes: 20 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 53 additions & 8 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,67 @@ It's planned to support
* abstract definitions by default (bindings in types that don't reduce / aren't normalized outside of their defining module / defined reach)
* the option to compile with LLVM or Cranelift

=== Example
=== Examples

```lushui

@public @transparent
data Option (A: Type): Type of
none 'A: Option A
some 'A: A -> Option A
data Option A of
none
some (_: A)

use Option.(none, some)

@public
map 'A 'B (o: Option A) (f: A -> B): B =
case o of
Option.none => Option.none
Option.some \x => Option.some (f x)
none => none
some (let x) => some (f x)

use extern.core.(type.Type, nat.(Nat, +, *))

process (o: Option Nat): Option Nat =
map o for x => + x 1


@public @transparent
data Vector A: For (n: Nat) -> Type of
empty: Vector 0 A
prepend '(n: Nat)
(head: A)
(tail: Vector n A):
Vector (+ n 1) A


trait Monoid A of
empty: A
append: A -> A -> A

@given
sum: Monoid Nat = trait of
empty = 0
append = +

@given
product: Monoid Nat = trait of
empty = 1
append = *

duplicate 'A [Monoid A] (a: A): A =
Monoid.append a a


use extern.core.text.Text

record Person of
name: Text
age: Nat

jane: Person = {name = "Jane", age = 38}
name: Text = jane::name
```

For more, check out the source files found in `./test/ui/tests`.
For more, check out the source files found in `test/ui`.

== Contributing

Expand Down Expand Up @@ -120,7 +165,7 @@ Use the following command (Unix-like systems only) to run all test suites:
./test/run
----

If you want to restrict yourself to UI tests, execute `./test/ui/run`.
If you want to restrict yourself to UI tests, execute `./test/run ui`.

== Tooling

Expand Down
42 changes: 42 additions & 0 deletions compiler/ast/src/attribute.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use crate::{Identifier, Path};
use span::Spanned;
use utilities::{Atom, SmallVec};

pub type Attributes = Vec<Attribute>;
pub type Attribute = Spanned<BareAttribute>;

#[derive(Clone, PartialEq, Eq)]
pub enum BareAttribute {
Regular {
binder: Identifier,
arguments: SmallVec<AttributeArgument, 1>,
},
Documentation,
}

pub type AttributeArgument = Spanned<BareAttributeArgument>;

#[derive(Clone, PartialEq, Eq)]
pub enum BareAttributeArgument {
NumberLiteral(Atom),
TextLiteral(Atom),
Path(Box<Path>),
Named(Box<NamedAttributeArgument>),
}

impl BareAttributeArgument {
pub const fn name(&self) -> &'static str {
match self {
Self::NumberLiteral(_) => "number literal",
Self::TextLiteral(_) => "text literal",
Self::Path(_) => "path",
Self::Named(_) => "named argument",
}
}
}

#[derive(Clone, PartialEq, Eq)]
pub struct NamedAttributeArgument {
pub binder: Identifier,
pub value: AttributeArgument,
}
Loading

0 comments on commit 3e18045

Please sign in to comment.