Compare commits
6 Commits
antiquated
...
7c27cace9f
Author | SHA1 | Date | |
---|---|---|---|
|
7c27cace9f | ||
|
23c54ae186 | ||
|
015840ac38 | ||
|
b8487aa0d4 | ||
|
bac5761534 | ||
|
926631ba8f |
5
TODO.md
5
TODO.md
@ -1,6 +1,11 @@
|
||||
|
||||
# TODO Items
|
||||
|
||||
-make sure to include a :doc command at the REPL that can interface with a lang in a generic way
|
||||
|
||||
- a subtype is a situation where the compiler is entitled to add a type conversion in the type-checking process
|
||||
b/c that type conversion doesn't correspond to a computation
|
||||
-Sergei W.
|
||||
|
||||
*A neat idea for pattern matching optimization would be if you could match on one of several things in a list
|
||||
ex:
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![feature(trace_macros)]
|
||||
#![feature(slice_patterns, box_patterns, box_syntax)]
|
||||
#![feature(proc_macro)]
|
||||
extern crate itertools;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
@ -58,8 +58,8 @@ pub enum Expr {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Alternative {
|
||||
pub tag: Option<usize>,
|
||||
pub guard: Option<Expr>,
|
||||
pub bound_vars: Vec<Option<Rc<String>>>, //remember that order matters here
|
||||
pub guards: Vec<Expr>,
|
||||
pub bound_vars: Vec<Option<Rc<String>>>, //order here is iconic to order in a tuple-like type, None is equivalent to ignored
|
||||
pub item: Vec<Stmt>,
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody,
|
||||
pat.to_alternative(then_clause, symbol_table),
|
||||
Alternative {
|
||||
tag: None,
|
||||
guard: None,
|
||||
guards: vec![],
|
||||
bound_vars: vec![],
|
||||
item: else_clause,
|
||||
},
|
||||
@ -196,6 +196,15 @@ impl Pattern {
|
||||
SymbolSpec::DataConstructor { index, .. } => index.clone(),
|
||||
_ => panic!("Bad symbol"),
|
||||
};
|
||||
|
||||
/*
|
||||
let guards = patterns.iter().map(|p| match p {
|
||||
|
||||
|
||||
});
|
||||
*/
|
||||
let guards = unimplemented!();
|
||||
|
||||
let bound_vars = subpatterns.iter().map(|p| match p {
|
||||
Literal(PatternLiteral::VarPattern(var)) => Some(var.clone()),
|
||||
Ignored => None,
|
||||
@ -203,7 +212,7 @@ impl Pattern {
|
||||
}).collect();
|
||||
Alternative {
|
||||
tag: Some(tag),
|
||||
guard: None,
|
||||
guards,
|
||||
bound_vars,
|
||||
item,
|
||||
}
|
||||
@ -215,6 +224,9 @@ impl Pattern {
|
||||
unimplemented!()
|
||||
},
|
||||
Ignored => unimplemented!(),
|
||||
/* "a constant appearing in a pattern can easily be eliminated by replacing it with a variable
|
||||
* and adding a guard to the equation instead" - Implementation of Functional Programming
|
||||
* Languages Simon Peyton-Jones, p. 58 */
|
||||
Literal(lit) => match lit {
|
||||
PatternLiteral::NumPattern { neg, num } => unimplemented!(),
|
||||
PatternLiteral::StringPattern(_s) => unimplemented!(),
|
||||
|
Loading…
Reference in New Issue
Block a user