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
|
# 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
|
*A neat idea for pattern matching optimization would be if you could match on one of several things in a list
|
||||||
ex:
|
ex:
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#![feature(trace_macros)]
|
#![feature(trace_macros)]
|
||||||
#![feature(slice_patterns, box_patterns, box_syntax)]
|
#![feature(slice_patterns, box_patterns, box_syntax)]
|
||||||
#![feature(proc_macro)]
|
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
@ -58,8 +58,8 @@ pub enum Expr {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Alternative {
|
pub struct Alternative {
|
||||||
pub tag: Option<usize>,
|
pub tag: Option<usize>,
|
||||||
pub guard: Option<Expr>,
|
pub guards: Vec<Expr>,
|
||||||
pub bound_vars: Vec<Option<Rc<String>>>, //remember that order matters here
|
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>,
|
pub item: Vec<Stmt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody,
|
|||||||
pat.to_alternative(then_clause, symbol_table),
|
pat.to_alternative(then_clause, symbol_table),
|
||||||
Alternative {
|
Alternative {
|
||||||
tag: None,
|
tag: None,
|
||||||
guard: None,
|
guards: vec![],
|
||||||
bound_vars: vec![],
|
bound_vars: vec![],
|
||||||
item: else_clause,
|
item: else_clause,
|
||||||
},
|
},
|
||||||
@ -196,6 +196,15 @@ impl Pattern {
|
|||||||
SymbolSpec::DataConstructor { index, .. } => index.clone(),
|
SymbolSpec::DataConstructor { index, .. } => index.clone(),
|
||||||
_ => panic!("Bad symbol"),
|
_ => panic!("Bad symbol"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
let guards = patterns.iter().map(|p| match p {
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
let guards = unimplemented!();
|
||||||
|
|
||||||
let bound_vars = subpatterns.iter().map(|p| match p {
|
let bound_vars = subpatterns.iter().map(|p| match p {
|
||||||
Literal(PatternLiteral::VarPattern(var)) => Some(var.clone()),
|
Literal(PatternLiteral::VarPattern(var)) => Some(var.clone()),
|
||||||
Ignored => None,
|
Ignored => None,
|
||||||
@ -203,7 +212,7 @@ impl Pattern {
|
|||||||
}).collect();
|
}).collect();
|
||||||
Alternative {
|
Alternative {
|
||||||
tag: Some(tag),
|
tag: Some(tag),
|
||||||
guard: None,
|
guards,
|
||||||
bound_vars,
|
bound_vars,
|
||||||
item,
|
item,
|
||||||
}
|
}
|
||||||
@ -215,6 +224,9 @@ impl Pattern {
|
|||||||
unimplemented!()
|
unimplemented!()
|
||||||
},
|
},
|
||||||
Ignored => 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 {
|
Literal(lit) => match lit {
|
||||||
PatternLiteral::NumPattern { neg, num } => unimplemented!(),
|
PatternLiteral::NumPattern { neg, num } => unimplemented!(),
|
||||||
PatternLiteral::StringPattern(_s) => unimplemented!(),
|
PatternLiteral::StringPattern(_s) => unimplemented!(),
|
||||||
|
Loading…
Reference in New Issue
Block a user