Repository: gluon-lang/gluon
Pull request #187 (2016-10-15 21:31:49)

Move kinds into separate module

Marwes: Just one nit, other wise 👍 

Patch:
diff --git a/base/src/kind.rs b/base/src/kind.rs
new file mode 100644
index 00000000..e4a1bcde
--- /dev/null
+++ b/base/src/kind.rs
@@ -0,0 +1,143 @@
+use std::fmt;
+use std::ops::Deref;
+use std::sync::Arc;
+
+use symbol::SymbolRef;
+use types::Walker;
+
+/// Trait for values which contains kinded values which can be refered by name
+pub trait KindEnv {
+    /// Returns the kind of the type `type_name`
+    fn find_kind(&self, type_name: &SymbolRef) -> Option<ArcKind>;
+}
+
+impl<'a, T: ?Sized + KindEnv> KindEnv for &'a T {
+    fn find_kind(&self, id: &SymbolRef) -> Option<ArcKind> {
+        (**self).find_kind(id)
+    }
+}
+
+/// Kind representation
+///
+/// All types in gluon has a kind. Most types encountered are of the `Type` kind which
+/// includes things like `Int`, `String` and `Option Int`. There are however other types
+/// which are said to be "higher kinded" and these use the `Function` (a -> b) variant.
+/// These types include `Option` and `(->)` which both have the kind `Type -> Type -> Type`
+/// as well as `Functor` which has the kind `Type -> Type -> Type`.
+#[derive(Clone, Debug, Eq, PartialEq, Hash)]
+pub enum Kind {
+    /// Representation for a kind which is yet to be inferred.
+    Variable(u32),
+    /// The simplest possible kind. All values in a program have this kind.
+    Type,
+    /// Kinds of rows (for polymorphic records).
+    Row,
+    /// Constructor which takes two kinds, taking the first as argument and returning the second.
+    Function(ArcKind, ArcKind),
+}
+
+impl Kind {
+    pub fn variable(v: u32) -> ArcKind {
+        ArcKind::new(Kind::Variable(v))
+    }
+
+    pub fn typ() -> ArcKind {
+        ArcKind::new(Kind::Type)
+    }
+
+    pub fn row() -> ArcKind {
+        ArcKind::new(Kind::Row)
+    }
+
+    pub fn function(l: ArcKind, r: ArcKind) -> ArcKind {
+        ArcKind::new(Kind::Function(l, r))
+    }
+}
+
+#[derive(PartialEq, Copy, Clone, PartialOrd)]
+enum Prec {
+    /// The kind exists in the top context, no parentheses needed.
+    Top,
+    /// The kind exists in a function argument `Kind -> a`, parentheses are
+    /// needed if the kind is a function `(b -> c) -> a`.
+    Function,
+}
+
+struct DisplayKind<'a>(Prec, &'a Kind);
+
+impl fmt::Display for Kind {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "{}", DisplayKind(Prec::Top, self))
+    }
+}
+
+impl<'a> fmt::Display for DisplayKind<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match *self.1 {
+            Kind::Variable(i) => i.fmt(f),
+            Kind::Type => "Type".fmt(f),
+            Kind::Row => "Row".fmt(f),
+            Kind::Function(ref arg, ref ret) => {
+                match self.0 {
+                    Prec::Function => {
+                        write!(f, "({} -> {})", DisplayKind(Prec::Function, arg), ret)
+                    }
+                    Prec::Top => write!(f, "{} -> {}", DisplayKind(Prec::Function, arg), ret),
+                }
+            }
+        }
+    }
+}
+
+/// Reference counted kind type.
+#[derive(Clone, Eq, PartialEq, Hash)]
+pub struct ArcKind(Arc<Kind>);
+
+impl Deref for ArcKind {
+    type Target = Kind;
+
+    fn deref(&self) -> &Kind {
+        &self.0
+    }
+}
+
+impl fmt::Debug for ArcKind {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        self.0.fmt(f)
+    }
+}
+
+impl fmt::Display for ArcKind {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        self.0.fmt(f)
+    }
+}
+
+impl ArcKind {
+    pub fn new(k: Kind) -> ArcKind {
+        ArcKind(Arc::new(k))
+    }
+}
+
+impl<F: ?Sized> Walker<ArcKind> for F
+    where F: FnMut(&ArcKind),
+{
+    fn walk(&mut self, typ: &ArcKind) {
+        self(typ);
+        walk_kind(typ, self)
+    }
+}
+
+pub fn walk_kind<F: ?Sized>(k: &ArcKind, f: &mut F)
+    where F: Walker<ArcKind>,
+{
+    match **k {
+        Kind::Function(ref a, ref r) => {
+            f.walk(a);
+            f.walk(r);
+        }
+        Kind::Variable(_) |
+        Kind::Type |
+        Kind::Row => (),
+    }
+}
diff --git a/base/src/lib.rs b/base/src/lib.rs
index 1cd44d9c..f9c9c696 100644
--- a/base/src/lib.rs
+++ b/base/src/lib.rs
@@ -12,6 +12,7 @@ pub mod error;
 pub mod fixed;
 pub mod fnv;
 pub mod instantiate;
+pub mod kind;
 pub mod metadata;
 pub mod pos;
 pub mod scoped_map;
diff --git a/base/src/types.rs b/base/src/types.rs
index 3ff6d784..700d5d97 100644
--- a/base/src/types.rs
+++ b/base/src/types.rs
@@ -1,4 +1,3 @@
-//! Module containing types representing `gluon`'s type system
 use std::borrow::ToOwned;
 use std::fmt;
 use std::ops::Deref;
@@ -8,87 +7,9 @@ use std::marker::PhantomData;
 use pretty::{DocAllocator, Arena, DocBuilder};
 
 use ast::{self, DisplayEnv};
+use kind::{ArcKind, Kind, KindEnv};
 use symbol::{Symbol, SymbolRef};
 
-/// Trait for values which contains kinded values which can be refered by name
-pub trait KindEnv {
-    /// Returns the kind of the type `type_name`
-    fn find_kind(&self, type_name: &SymbolRef) -> Option<ArcKind>;
-}
-
-impl<'a, T: ?Sized + KindEnv> KindEnv for &'a T {
-    fn find_kind(&self, id: &SymbolRef) -> Option<ArcKind> {
-        (**self).find_kind(id)
-    }
-}
-
-/// Kind representation
-///
-/// All types in gluon has a kind. Most types encountered are of the `Type` kind which
-/// includes things like `Int`, `String` and `Option Int`. There are however other types which
-/// are said to be "higher kinded" and these use the `Function` (a -> b) variant.
-/// These types include `Option` and `(->)` which both have the kind `Type -> Type` as well as
-/// `Functor` which has the kind `(Type -> Type) -> Type`.
-#[derive(Clone, Debug, Eq, PartialEq, Hash)]
-pub enum Kind {
-    /// Representation for a kind which is yet to be inferred.
-    Variable(u32),
-    /// The simplest possible kind. All values in a program have this kind.
-    Type,
-    /// Kinds of rows (for polymorphic records).
-    Row,
-    /// Constructor which takes two kinds, taking the first as argument and returning the second.
-    Function(ArcKind, ArcKind),
-}
-
-impl Kind {
-    pub fn variable(v: u32) -> ArcKind {
-        ArcKind::new(Kind::Variable(v))
-    }
-
-    pub fn typ() -> ArcKind {
-        ArcKind::new(Kind::Type)
-    }
-
-    pub fn row() -> ArcKind {
-        ArcKind::new(Kind::Row)
-    }
-
-    pub fn function(l: ArcKind, r: ArcKind) -> ArcKind {
-        ArcKind::new(Kind::Function(l, r))
-    }
-}
-
-/// Reference counted kind type.
-#[derive(Clone, Eq, PartialEq, Hash)]
-pub struct ArcKind(Arc<Kind>);
-
-impl Deref for ArcKind {
-    type Target = Kind;
-
-    fn deref(&self) -> &Kind {
-        &self.0
-    }
-}
-
-impl fmt::Debug for ArcKind {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        self.0.fmt(f)
-    }
-}
-
-impl fmt::Display for ArcKind {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        self.0.fmt(f)
-    }
-}
-
-impl ArcKind {
-    pub fn new(k: Kind) -> ArcKind {
-        ArcKind(Arc::new(k))
-    }
-}
-
 /// Trait for values which contains typed values which can be refered by name
 pub trait TypeEnv: KindEnv {
     /// Returns the type of the value bound at `id`
@@ -685,34 +606,6 @@ impl TypeVariable {
     }
 }
 
-struct DisplayKind<'a>(Prec, &'a Kind);
-
-impl fmt::Display for Kind {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", DisplayKind(Prec::Top, self))
-    }
-}
-
-impl<'a> fmt::Display for DisplayKind<'a> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match *self.1 {
-            Kind::Variable(i) => i.fmt(f),
-            Kind::Type => "Type".fmt(f),
-            Kind::Row => "Row".fmt(f),
-            Kind::Function(ref arg, ref ret) => {
-                match self.0 {
-                    Prec::Function => {
-                        write!(f, "({} -> {})", DisplayKind(Prec::Function, arg), ret)
-                    }
-                    Prec::Top | Prec::Constructor => {
-                        write!(f, "{} -> {}", DisplayKind(Prec::Function, arg), ret)
-                    }
-                }
-            }
-        }
-    }
-}
-
 impl fmt::Display for TypeVariable {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         self.id.fmt(f)
@@ -731,6 +624,19 @@ impl fmt::Display for BuiltinType {
     }
 }
 
+#[derive(PartialEq, Copy, Clone, PartialOrd)]
+enum Prec {
+    /// The type exists in the top context, no parentheses needed.
+    Top,
+    /// The type exists in a function argument `Type -> a`, parentheses are
+    /// needed if the type is a function `(b -> c) -> a`.
+    Function,
+    /// The type exists in a constructor argument `Option Type`, parentheses
+    /// are needed for functions or other constructors `Option (a -> b)`
+    /// `Option (Result a b)`.
+    Constructor,
+}
+
 fn dt<'a, I, T, E>(env: &'a E, prec: Prec, typ: &'a Type<I, T>) -> DisplayType<'a, I, T, E> {
     DisplayType {
         env: env,
@@ -957,19 +863,6 @@ impl<'a, I, T, E> DisplayType<'a, I, T, E>
     }
 }
 
-
-#[derive(PartialEq, Copy, Clone, PartialOrd)]
-enum Prec {
-    /// The type exists in the top context, no parentheses needed.
-    Top,
-    /// The type exists in a function argument `Type -> a`, parentheses are needed if the type is a
-    /// function `(b -> c) -> a`
-    Function,
-    /// The type exists in a constructor argument `Option Type`, parentheses are needed for
-    /// functions or other constructors `Option (a -> b)` `Option (Result a b)`
-    Constructor,
-}
-
 impl<I, T> fmt::Display for Type<I, T>
     where I: AsRef<str>,
           T: Deref<Target = Type<I, T>>,
@@ -1046,21 +939,6 @@ pub fn fold_type<I, T, F, A>(typ: &T, mut f: F, a: A) -> A
     a.expect("fold_type")
 }
 
-pub fn walk_kind<F: ?Sized>(k: &ArcKind, f: &mut F)
-    where F: Walker<ArcKind>,
-{
-    match **k {
-        Kind::Function(ref a, ref r) => {
-            f.walk(a);
-            f.walk(r);
-        }
-        Kind::Variable(_) |
-        Kind::Type |
-        Kind::Row => (),
-    }
-}
-
-
 pub trait TypeVisitor<I, T> {
     fn visit(&mut self, typ: &Type<I, T>) -> Option<T>
         where T: Deref<Target = Type<I, T>> + From<Type<I, T>> + Clone,
@@ -1089,6 +967,7 @@ impl<I, T, F: ?Sized> TypeVisitor<I, T> for F
 
 /// Wrapper type which allows functions to control how to traverse the members of the type
 pub struct ControlVisitation<F>(pub F);
+
 impl<F, I, T> TypeVisitor<I, T> for ControlVisitation<F>
     where F: FnMut(&Type<I, T>) -> Option<T>,
 {
@@ -1110,15 +989,6 @@ impl<I, T, F: ?Sized> Walker<T> for F
     }
 }
 
-impl<F: ?Sized> Walker<ArcKind> for F
-    where F: FnMut(&ArcKind),
-{
-    fn walk(&mut self, typ: &ArcKind) {
-        self(typ);
-        walk_kind(typ, self)
-    }
-}
-
 /// Walks through a type calling `f` on each inner type. If `f` return `Some` the type is replaced.
 pub fn walk_move_type<F: ?Sized, I, T>(typ: T, f: &mut F) -> T
     where F: FnMut(&Type<I, T>) -> Option<T>,
@@ -1204,6 +1074,7 @@ pub fn walk_move_types<'a, I, F, T>(types: I, mut f: F) -> Option<Vec<T>>
         Some(out)
     }
 }
+
 fn walk_move_types2<'a, I, F, T>(mut types: I, replaced: bool, output: &mut Vec<T>, f: &mut F)
     where I: Iterator<Item = &'a T>,
           F: FnMut(&'a T) -> Option<T>,
diff --git a/check/src/kindcheck.rs b/check/src/kindcheck.rs
index e1e17fa3..0cbc875a 100644
--- a/check/src/kindcheck.rs
+++ b/check/src/kindcheck.rs
@@ -1,9 +1,9 @@
 use std::fmt;
 
 use base::ast;
-use base::types::{self, BuiltinType, Generic, ArcKind, ArcType, Type, Kind, merge};
+use base::kind::{self, ArcKind, Kind, KindEnv};
 use base::symbol::Symbol;
-use base::types::{KindEnv, Walker};
+use base::types::{self, ArcType, BuiltinType, Generic, Type, Walker};
 
 use substitution::{Substitution, Substitutable};
 use unify;
@@ -51,7 +51,7 @@ fn walk_move_kind2<F>(kind: &ArcKind, f: &mut F) -> Option<ArcKind>
             Kind::Function(ref arg, ref ret) => {
                 let arg_new = walk_move_kind2(arg, f);
                 let ret_new = walk_move_kind2(ret, f);
-                merge(arg, arg_new, ret, ret_new, Kind::function)
+                types::merge(arg, arg_new, ret, ret_new, Kind::function)
             }
             Kind::Type |
             Kind::Variable(_) |
@@ -327,7 +327,7 @@ impl Substitutable for ArcKind {
     fn traverse<F>(&self, f: &mut F)
         where F: Walker<ArcKind>,
     {
-        types::walk_kind(self, f);
+        kind::walk_kind(self, f);
     }
 }
 
@@ -344,7 +344,7 @@ impl<S> unify::Unifiable<S> for ArcKind {
             (&Kind::Function(ref l1, ref l2), &Kind::Function(ref r1, ref r2)) => {
                 let a = unifier.try_match(l1, r1);
                 let r = unifier.try_match(l2, r2);
-                Ok(merge(l1, a, l2, r, Kind::function))
+                Ok(types::merge(l1, a, l2, r, Kind::function))
             }
             (l, r) => {
                 if l == r {
diff --git a/check/src/lib.rs b/check/src/lib.rs
index a55fb8db..e8eef764 100644
--- a/check/src/lib.rs
+++ b/check/src/lib.rs
@@ -26,8 +26,9 @@ mod tests {
     use std::cell::RefCell;
     use std::rc::Rc;
 
-    use base::types::{Alias, KindEnv, ArcKind, ArcType, TypeEnv};
+    use base::kind::{ArcKind, KindEnv};
     use base::symbol::{Symbol, Symbols, SymbolModule, SymbolRef};
+    use base::types::{Alias, ArcType, TypeEnv};
 
     pub struct MockEnv;
 
diff --git a/check/src/rename.rs b/check/src/rename.rs
index db63ff3d..4ddeac7f 100644
--- a/check/src/rename.rs
+++ b/check/src/rename.rs
@@ -1,12 +1,13 @@
 use std::fmt;
 
 use base::ast::{self, DisplayEnv, Expr, SpannedExpr, MutVisitor, Typed, TypedIdent};
-use base::pos::{self, BytePos, Span, Spanned};
 use base::error::Errors;
 use base::fnv::FnvMap;
+use base::kind::{ArcKind, KindEnv};
+use base::pos::{self, BytePos, Span, Spanned};
 use base::scoped_map::ScopedMap;
 use base::symbol::{Symbol, SymbolRef, SymbolModule};
-use base::types::{self, Alias, ArcType, Type, ArcKind, KindEnv, TypeEnv};
+use base::types::{self, Alias, ArcType, Type, TypeEnv};
 use unify_type::{TypeError, State};
 use unify::{Error as UnifyError, Unifier, Unifiable, UnifierState};
 
diff --git a/check/src/typecheck.rs b/check/src/typecheck.rs
index 225ca520..175a8910 100644
--- a/check/src/typecheck.rs
+++ b/check/src/typecheck.rs
@@ -10,10 +10,11 @@ use base::ast::{SpannedPattern, TypeBinding, Typed, TypedIdent, ValueBinding};
 use base::error::Errors;
 use base::fnv::FnvSet;
 use base::instantiate::{self, Instantiator};
+use base::kind::{Kind, KindEnv, ArcKind};
 use base::pos::{BytePos, Span, Spanned};
 use base::symbol::{Symbol, SymbolRef, SymbolModule, Symbols};
-use base::types::{self, ArcType, Field, ArcKind, Type, Generic, Kind, merge};
-use base::types::{KindEnv, TypeEnv, PrimitiveEnv, Alias, AliasData, TypeVariable};
+use base::types::{self, Alias, AliasData, ArcType, Field, Generic};
+use base::types::{PrimitiveEnv, Type, TypeEnv, TypeVariable};
 use kindcheck::{self, KindCheck};
 use substitution::Substitution;
 use unify::Error as UnifyError;
@@ -1124,11 +1125,11 @@ impl<'a> Typecheck<'a> {
                         })
                     });
                     let new_rest = self.finish_type(level, rest);
-                    merge(fields,
-                          new_fields,
-                          rest,
-                          new_rest,
-                          |fields, rest| Type::extend_row(types.clone(), fields, rest))
+                    types::merge(fields,
+                                 new_fields,
+                                 rest,
+                                 new_rest,
+                                 |fields, rest| Type::extend_row(types.clone(), fields, rest))
                         .or_else(|| replacement.clone())
                 }
                 _ => {
diff --git a/parser/src/lib.rs b/parser/src/lib.rs
index 3d27de07..8abdfea9 100644
--- a/parser/src/lib.rs
+++ b/parser/src/lib.rs
@@ -17,10 +17,11 @@ use std::marker::PhantomData;
 use std::rc::Rc;
 
 use base::ast::*;
+use base::kind::Kind;
 use base::error::Errors;
 use base::pos::{self, BytePos, Span, Spanned};
-use base::types::{Alias, ArcType, Generic, Field, Kind, Type};
 use base::symbol::{Name, Symbol};
+use base::types::{Alias, ArcType, Generic, Field, Type};
 
 use combine::primitives::{Consumed, Stream, StreamOnce, Error as CombineError, Info,
                           BufferedStream};
diff --git a/src/repl.rs b/src/repl.rs
index 47991f20..6e7e3c9a 100644
--- a/src/repl.rs
+++ b/src/repl.rs
@@ -7,7 +7,7 @@ use std::sync::Mutex;
 use self::rustyline::error::ReadlineError;
 
 use base::ast::Typed;
-use base::types::Kind;
+use base::kind::Kind;
 use vm::api::{IO, Function, WithVM, VmType, Userdata};
 use vm::gc::{Gc, Traverseable};
 use vm::thread::{Thread, RootStr};
diff --git a/vm/src/compiler.rs b/vm/src/compiler.rs
index b0b7b56f..48ffcb57 100644
--- a/vm/src/compiler.rs
+++ b/vm/src/compiler.rs
@@ -1,12 +1,11 @@
 use std::ops::{Deref, DerefMut};
 use interner::InternedStr;
-use base::ast::{Literal, Pattern, TypedIdent};
+use base::ast::{Literal, Pattern, TypedIdent, Typed, DisplayEnv, SpannedExpr, Expr};
 use base::instantiate;
-use base::symbol::{Symbol, SymbolRef, SymbolModule};
-use base::ast::{Typed, DisplayEnv, SpannedExpr, Expr};
-use base::types;
-use base::types::{Alias, KindEnv, ArcType, Type, TypeEnv};
+use base::kind::{ArcKind, KindEnv};
+use base::types::{self, Alias, ArcType, Type, TypeEnv};
 use base::scoped_map::ScopedMap;
+use base::symbol::{Symbol, SymbolRef, SymbolModule};
 use types::*;
 use vm::GlobalVmState;
 use self::Variable::*;
@@ -281,7 +280,7 @@ pub struct Compiler<'a> {
 }
 
 impl<'a> KindEnv for Compiler<'a> {
-    fn find_kind(&self, _type_name: &SymbolRef) -> Option<types::ArcKind> {
+    fn find_kind(&self, _type_name: &SymbolRef) -> Option<ArcKind> {
         None
     }
 }
diff --git a/vm/src/types.rs b/vm/src/types.rs
index db080cce..2beff072 100644
--- a/vm/src/types.rs
+++ b/vm/src/types.rs
@@ -1,7 +1,7 @@
-use base::symbol::{Symbol, SymbolRef};
-use base::types;
-use base::types::{Alias, KindEnv, TypeEnv, ArcType, Type};
 use base::fnv::FnvMap;
+use base::kind::{ArcKind, Kind, KindEnv};
+use base::symbol::{Symbol, SymbolRef};
+use base::types::{Alias, ArcType, TypeEnv, Type};
 
 pub use self::Instruction::*;
 
@@ -155,14 +155,13 @@ pub struct TypeInfos {
 }
 
 impl KindEnv for TypeInfos {
-    fn find_kind(&self, type_name: &SymbolRef) -> Option<types::ArcKind> {
+    fn find_kind(&self, type_name: &SymbolRef) -> Option<ArcKind> {
         let type_name = AsRef::<str>::as_ref(type_name);
         self.id_to_type
             .get(type_name)
             .map(|alias| {
-                alias.args.iter().rev().fold(types::Kind::typ(), |acc, arg| {
-                    types::Kind::function(arg.kind.clone(), acc)
-                })
+                alias.args.iter().rev().fold(Kind::typ(),
+                                             |acc, arg| Kind::function(arg.kind.clone(), acc))
             })
     }
 }
diff --git a/vm/src/vm.rs b/vm/src/vm.rs
index 5c11e104..1ab0ce3d 100644
--- a/vm/src/vm.rs
+++ b/vm/src/vm.rs
@@ -5,11 +5,11 @@ use std::result::Result as StdResult;
 use std::string::String as StdString;
 use std::usize;
 
+use base::fnv::FnvMap;
+use base::kind::{ArcKind, Kind, KindEnv};
 use base::metadata::{Metadata, MetadataEnv};
 use base::symbol::{Name, Symbol, SymbolRef};
-use base::types::{Alias, AliasData, ArcType, Generic, Type, Kind, KindEnv, TypeEnv, PrimitiveEnv,
-                  ArcKind};
-use base::fnv::FnvMap;
+use base::types::{Alias, AliasData, ArcType, Generic, PrimitiveEnv, Type, TypeEnv};
 
 use macros::MacroEnv;
 use {Error, Result};


Test patch:
diff --git a/base/tests/types.rs b/base/tests/types.rs
index 18913455..7599009c 100644
--- a/base/tests/types.rs
+++ b/base/tests/types.rs
@@ -2,6 +2,7 @@ extern crate gluon_base as base;
 
 use std::ops::Deref;
 
+use base::kind::{ArcKind, Kind};
 use base::types::*;
 
 fn type_con<I, T>(s: I, args: Vec<T>) -> Type<I, T>
diff --git a/check/tests/pass.rs b/check/tests/pass.rs
index 58a7ae01..cc4335df 100644
--- a/check/tests/pass.rs
+++ b/check/tests/pass.rs
@@ -5,8 +5,9 @@ extern crate gluon_parser as parser;
 extern crate gluon_check as check;
 
 use base::ast::{self, Expr, Pattern, Typed};
+use base::kind::Kind;
 use base::pos::{BytePos, Span};
-use base::types::{self, Field, Generic, Kind, Type};
+use base::types::{self, Field, Generic, Type};
 
 use support::{MockEnv, alias, intern, typ};
 
diff --git a/check/tests/row_polymorphism.rs b/check/tests/row_polymorphism.rs
index e7222ee9..b34dcc5c 100644
--- a/check/tests/row_polymorphism.rs
+++ b/check/tests/row_polymorphism.rs
@@ -4,7 +4,8 @@ extern crate gluon_base as base;
 extern crate gluon_parser as parser;
 extern crate gluon_check as check;
 
-use base::types::{Field, Type, Kind};
+use base::kind::Kind;
+use base::types::{Field, Type};
 use check::kindcheck::KindCheck;
 
 use support::{MockEnv, MockIdentEnv, intern, typ};
diff --git a/check/tests/support/mod.rs b/check/tests/support/mod.rs
index 44b8d9e4..8eb94473 100644
--- a/check/tests/support/mod.rs
+++ b/check/tests/support/mod.rs
@@ -1,7 +1,7 @@
 use base::ast::{DisplayEnv, IdentEnv, SpannedExpr};
+use base::kind::{ArcKind, Kind, KindEnv};
 use base::symbol::{Symbols, SymbolModule, Symbol, SymbolRef};
-use base::types::{Alias, Generic, Kind, Type, KindEnv};
-use base::types::{ArcType, TypeEnv, PrimitiveEnv, ArcKind, walk_move_type};
+use base::types::{self, Alias, ArcType, Generic, PrimitiveEnv, Type, TypeEnv};
 use check::typecheck::{self, Typecheck};
 use parser;
 
@@ -207,8 +207,8 @@ pub fn alias(s: &str, args: &[&str], typ: ArcType) -> ArcType {
 /// Replace the variable at the `rest` part of a record for easier equality checks
 #[allow(dead_code)]
 pub fn close_record(typ: ArcType) -> ArcType {
-    walk_move_type(typ,
-                   &mut |typ| {
+    types::walk_move_type(typ,
+                          &mut |typ| {
         match *typ {
             Type::ExtendRow { ref types, ref fields, ref rest } => {
                 match **rest {
diff --git a/parser/tests/basic.rs b/parser/tests/basic.rs
index e83ae733..cff669f3 100644
--- a/parser/tests/basic.rs
+++ b/parser/tests/basic.rs
@@ -7,8 +7,9 @@ extern crate log;
 mod support;
 
 use base::ast::*;
+use base::kind::Kind;
 use base::pos::{self, BytePos, Span, Spanned};
-use base::types::{Alias, ArcType, Field, Generic, Kind, Type};
+use base::types::{Alias, ArcType, Field, Generic, Type};
 use parser::{parse_string, Error};
 use support::MockEnv;