2019-01-27 22:38:20 -08:00
#Typechecking Notes
2019-03-08 03:57:32 -08:00
IDEA: - if you have a pattern-match where one variant has a variable and the other lacks it
instead of treating this as a type error, promote the bound variable to an option type
2019-02-21 19:07:07 -08:00
IS BOX SYNTAX READY????
2019-01-27 22:38:20 -08:00
(cf. cardelli paper)
Given a length function def:
````
fn length(x) {
if x.is_null {
0
} else {
succ(length(x.tail))
}
}
````
Constraints:
.null: List a -> bool
.tail: List a -> List a
0: Nat
succ: Nat -> Nat
2017-12-13 00:52:54 -08:00
# TODO Items
2019-01-27 22:38:20 -08:00
-make the REPL more advanced!
2018-11-16 15:53:27 -08:00
-Plan of attack:
-write a visitor pattern for AST
-convert AST type to including SourceMap'd wrappers (w/ .into())
-at the same time, amke sure the visitor pattern "skips over" the SourceMap'd stuff
so it can just care about AST structure
- AST : maybe replace the Expression type with "Ascription(TypeName, Box< Expression > ) nodes??
- parser: add a "debug" field to the Parser struct for all debug-related things
-scala-style html"dfasfsadf${}" string interpolations!
2018-11-05 19:57:11 -08:00
-fuzz test schala
2018-07-18 23:00:11 -07:00
2019-01-07 01:59:12 -08:00
-look into Inkwell for LLVM
2018-11-16 15:53:27 -08:00
2018-08-19 21:11:43 -07:00
*A neat idea for pattern matching optimization would be if you could match on one of several things in a list
ex:
if x {
is (comp, LHSPat, RHSPat) if comp in ["==, "< "] -> ...
}
2018-07-31 01:59:49 -07:00
- https://nshipster.com/never/
2018-07-18 23:00:11 -07:00
-https://cranelift.readthedocs.io/en/latest/?badge=latest< Paste >
2018-07-01 00:42:50 -07:00
-consult http://gluon-lang.org/book/embedding-api.html
2018-06-14 00:49:11 -07:00
- if/match playground
simple if
`if x == 1.0 { "a" } else { "b" }`
one comparison multiple targets:
`if x == { 1.0 -> "a", 2.0 -> "b", else -> "c" }`
different comparison operators/ method calls:
`if x { == 1.0 -> "a", eq NaN -> "n", .hella() -> "h", else -> "z" }`
pattern matching/introducing bindings:
`if alice { .age < 18 -> "18", is Person("Alice", age) -> "${age}", else -> "none" }`
pattern matching w/ if-let:
`if person is Person("Alice", age) { "${age}" } else { "nope" }`
2018-06-14 05:42:12 -07:00
-https://soc.github.io/languages/unified-condition-syntax syntax:
`if <cond-expr>" then <then-expr> else <else-expr>`
`if <half-expr> \n <rest-expr1> then <result1-expr> \n <rest-expr2> then <result-expr2> else <result3-expr>`
-and rest-exprs (or "targets") can have 'is' for pattern-matching, actually so can a full cond-expr
2018-06-18 23:26:02 -07:00
UNIFIED IF EXPRESSIONS FINAL WORK:
basic syntax:
`if_expr := if discriminator '{' (guard_expr)* '}'`
`guard_expr := pattern 'then' block_or_expr'`
`pattern := rhs | is_pattern`
`is_pattern := 'is' ???`
`rhs := expression | ???`
if the only two guard patterns are true and false, then the abbreviated syntax:
`'if' discriminator 'then' block_or_expr 'else' block_or_expr`
can replace `'if' discriminator '{' 'true' 'then' block_or_expr; 'false' 'then' block_or_expr '}'`
2018-06-14 05:42:12 -07:00
2018-06-14 00:49:11 -07:00
2018-05-12 13:51:12 -07:00
- Next priorities: - get ADTs working, get matches working
2018-05-11 02:00:53 -07:00
- inclusive/exclusive range syntax like .. vs ..=
2018-04-27 02:19:09 -07:00
- sketch of an idea for the REPL:
-each compiler pass should be a (procedural?) macro like
compiler_pass!("parse", dataproducts: ["ast", "parse_tree"], {
match parsing::parse(INPUT) {
Ok(
PASS.add_artifact(
}
2018-04-24 20:31:00 -07:00
-should have an Idris-like `cast To From` function
2018-04-23 19:45:58 -07:00
- REPL:
- want to be able to do things like `:doc Identifier` , and have the language load up these definitions to the REPL
2018-04-23 19:35:25 -07:00
* change 'trait' to 'interface'
2018-04-23 21:33:15 -07:00
-think about idris-related ideas of multiple implementations of a type for an interface (+ vs * impl for monoids, for preorder/inorder/postorder for Foldable)
2018-04-23 19:35:25 -07:00
2017-12-13 00:52:54 -08:00
* Share state between programming languages
* idea for Schala - scoped types - be able to define a quick enum type scoped to a function ro something, that only is meant to be used as a quick bespoke interface between two other things
2018-02-21 03:39:40 -08:00
* another idea, allow:
type enum {
type enum MySubVariant {
SubVariant1, SubVariant2, etc.
}
Variant1(MySubVariant),
Variant2(...),
}
2017-12-13 00:52:54 -08:00
* idea for Schala: both currying *and* default arguments!
ex. fn a(b: Int, c:Int, d:Int = 1) -> Int
a(1,2) : Int
a(1,2,d=2): Int
a(_,1,3) : Int -> Int
a(1,2, c=_): Int -> Int
a(_,_,_) : Int -> Int -> Int -> Int
2018-02-10 15:10:06 -08:00
2018-02-20 17:56:13 -08:00
2018-02-21 02:09:40 -08:00
2019-03-11 20:05:45 -07:00
*Compiler passes architecture*
2018-02-21 02:09:40 -08:00
-ProgrammingLanguageInterface defines a evaluate_in_repl() and evaluate_no_repl() functions
-these take in a vec of CompilerPasses
struct CompilerPass {
name: String,
run: fn(PrevPass) -> NextPass
}
2018-02-21 04:32:17 -08:00
-change "Type...." names in parser.rs to "Anno..." for non-collision with names in typechecking.rs
2018-03-09 00:50:06 -08:00
-get rid of code pertaining to compilation specifically, have a more generation notion of "execution type"