aboutsummaryrefslogtreecommitdiff
path: root/primrose/src/types.rs
diff options
context:
space:
mode:
Diffstat (limited to 'primrose/src/types.rs')
-rw-r--r--primrose/src/types.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/primrose/src/types.rs b/primrose/src/types.rs
index 359edb5..608912b 100644
--- a/primrose/src/types.rs
+++ b/primrose/src/types.rs
@@ -21,17 +21,11 @@ pub enum Type {
impl Type {
pub fn is_var(&self) -> bool {
- match self {
- Type::Var(_) => true,
- _ => false,
- }
+ matches!(self, Type::Var(_))
}
pub fn is_bool(&self) -> bool {
- match self {
- Type::Bool() => true,
- _ => false,
- }
+ matches!(self, Type::Bool())
}
pub fn get_con_elem(&self) -> Option<(String, String)> {
@@ -166,7 +160,7 @@ impl TypeVarGen {
pub fn new() -> TypeVarGen {
TypeVarGen { supply: 0 }
}
- pub fn next(&mut self) -> TypeVar {
+ pub fn gen(&mut self) -> TypeVar {
let name = "#T".to_owned() + &self.supply.to_string();
let v = TypeVar::new(name);
self.supply += 1;
@@ -215,7 +209,7 @@ pub trait Types {
fn apply(&self, s: &Subst) -> Self;
}
-impl<'a, T> Types for Vec<T>
+impl<T> Types for Vec<T>
where
T: Types,
{
@@ -290,7 +284,7 @@ impl Types for TypeScheme {
impl TypeScheme {
/// Instantiates a typescheme into a type.
pub fn instantiate(&self, tvg: &mut TypeVarGen) -> Type {
- let newvars = self.vars.iter().map(|_| Type::Var(tvg.next()));
+ let newvars = self.vars.iter().map(|_| Type::Var(tvg.gen()));
self.ty
.apply(&Subst(self.vars.iter().cloned().zip(newvars).collect()))
}