mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
Use crate:: prefix a bunch.
This commit is contained in:
parent
d8d8aa292a
commit
be1e83dd6d
44 changed files with 237 additions and 236 deletions
|
@ -1,11 +1,11 @@
|
||||||
use can::expr::Expr;
|
use crate::can::expr::Expr;
|
||||||
use can::pattern::Pattern;
|
use crate::can::pattern::Pattern;
|
||||||
use can::problem::Problem;
|
use crate::can::problem::Problem;
|
||||||
use can::procedure::{Procedure, References};
|
use crate::can::procedure::{Procedure, References};
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use collections::{ImMap, MutMap};
|
use crate::collections::{ImMap, MutMap};
|
||||||
use region::{Located, Region};
|
use crate::region::{Located, Region};
|
||||||
use subs::Variable;
|
use crate::subs::Variable;
|
||||||
|
|
||||||
/// The canonicalization environment for a particular module.
|
/// The canonicalization environment for a particular module.
|
||||||
pub struct Env {
|
pub struct Env {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use can::pattern::Pattern;
|
use crate::can::pattern::Pattern;
|
||||||
use can::problem::RuntimeError;
|
use crate::can::problem::RuntimeError;
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use operator::CalledVia;
|
use crate::operator::CalledVia;
|
||||||
use region::Located;
|
use crate::region::Located;
|
||||||
|
use crate::subs::Variable;
|
||||||
use std::i64;
|
use std::i64;
|
||||||
use subs::Variable;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum Expr {
|
pub enum Expr {
|
||||||
|
|
|
@ -12,20 +12,20 @@ use self::problem::RuntimeError::*;
|
||||||
use self::procedure::{Procedure, References};
|
use self::procedure::{Procedure, References};
|
||||||
use self::scope::Scope;
|
use self::scope::Scope;
|
||||||
use self::symbol::Symbol;
|
use self::symbol::Symbol;
|
||||||
|
use crate::collections::{ImMap, ImSet, MutMap, MutSet};
|
||||||
|
use crate::constrain::{self, exists};
|
||||||
|
use crate::graph::{strongly_connected_component, topological_sort};
|
||||||
|
use crate::ident::Ident;
|
||||||
|
use crate::parse::ast::{self, Def};
|
||||||
|
use crate::region::{Located, Region};
|
||||||
|
use crate::subs::{Subs, Variable};
|
||||||
|
use crate::types::AnnotationSource::*;
|
||||||
|
use crate::types::Constraint::{self, *};
|
||||||
|
use crate::types::Expected::{self, *};
|
||||||
|
use crate::types::Type::{self, *};
|
||||||
|
use crate::types::{LetConstraint, PExpected, PReason, Reason};
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use collections::{ImMap, ImSet, MutMap, MutSet};
|
|
||||||
use constrain::{self, exists};
|
|
||||||
use graph::{strongly_connected_component, topological_sort};
|
|
||||||
use ident::Ident;
|
|
||||||
use parse::ast::{self, Def};
|
|
||||||
use region::{Located, Region};
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use subs::{Subs, Variable};
|
|
||||||
use types::AnnotationSource::*;
|
|
||||||
use types::Constraint::{self, *};
|
|
||||||
use types::Expected::{self, *};
|
|
||||||
use types::Type::{self, *};
|
|
||||||
use types::{LetConstraint, PExpected, PReason, Reason};
|
|
||||||
|
|
||||||
pub mod env;
|
pub mod env;
|
||||||
pub mod expr;
|
pub mod expr;
|
||||||
|
@ -1117,7 +1117,7 @@ fn add_idents_from_pattern<'a>(
|
||||||
scope: &'a Scope,
|
scope: &'a Scope,
|
||||||
answer: &'a mut Vec<(Ident, (Symbol, Region))>,
|
answer: &'a mut Vec<(Ident, (Symbol, Region))>,
|
||||||
) {
|
) {
|
||||||
use parse::ast::Pattern::*;
|
use crate::parse::ast::Pattern::*;
|
||||||
|
|
||||||
match pattern {
|
match pattern {
|
||||||
Identifier(name) => {
|
Identifier(name) => {
|
||||||
|
@ -1165,7 +1165,7 @@ fn add_idents_from_pattern<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_idents(pattern: &ast::Pattern, idents: &mut ImMap<Ident, (Symbol, Region)>) {
|
fn remove_idents(pattern: &ast::Pattern, idents: &mut ImMap<Ident, (Symbol, Region)>) {
|
||||||
use parse::ast::Pattern::*;
|
use crate::parse::ast::Pattern::*;
|
||||||
|
|
||||||
match &pattern {
|
match &pattern {
|
||||||
Identifier(name) => {
|
Identifier(name) => {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use can::env::Env;
|
use crate::can::env::Env;
|
||||||
use can::expr::Expr;
|
use crate::can::expr::Expr;
|
||||||
use can::problem::Problem;
|
use crate::can::problem::Problem;
|
||||||
use can::problem::RuntimeError::*;
|
use crate::can::problem::RuntimeError::*;
|
||||||
use constrain;
|
use crate::constrain;
|
||||||
use region::Region;
|
use crate::region::Region;
|
||||||
|
use crate::subs::Subs;
|
||||||
|
use crate::types::Constraint::{self, *};
|
||||||
|
use crate::types::Expected;
|
||||||
|
use crate::types::Type;
|
||||||
use std::i64;
|
use std::i64;
|
||||||
use subs::Subs;
|
|
||||||
use types::Constraint::{self, *};
|
|
||||||
use types::Expected;
|
|
||||||
use types::Type;
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn int_expr_from_result(
|
pub fn int_expr_from_result(
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
|
use crate::operator::BinOp::Pizza;
|
||||||
|
use crate::operator::{BinOp, CalledVia};
|
||||||
|
use crate::parse::ast::Expr::{self, *};
|
||||||
|
use crate::parse::ast::{AssignedField, Def, Pattern};
|
||||||
|
use crate::region::{Located, Region};
|
||||||
|
use crate::types;
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use operator::BinOp::Pizza;
|
|
||||||
use operator::{BinOp, CalledVia};
|
|
||||||
use parse::ast::Expr::{self, *};
|
|
||||||
use parse::ast::{AssignedField, Def, Pattern};
|
|
||||||
use region::{Located, Region};
|
|
||||||
use types;
|
|
||||||
|
|
||||||
// BinOp precedence logic adapted from Gluon by Markus Westerlind, MIT licensed
|
// BinOp precedence logic adapted from Gluon by Markus Westerlind, MIT licensed
|
||||||
// https://github.com/gluon-lang/gluon
|
// https://github.com/gluon-lang/gluon
|
||||||
|
@ -34,7 +34,7 @@ fn new_op_expr<'a>(
|
||||||
/// Reorder the expression tree based on operator precedence and associativity rules,
|
/// Reorder the expression tree based on operator precedence and associativity rules,
|
||||||
/// then replace the BinOp nodes with Apply nodes. Also drop SpaceBefore and SpaceAfter nodes.
|
/// then replace the BinOp nodes with Apply nodes. Also drop SpaceBefore and SpaceAfter nodes.
|
||||||
pub fn desugar<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a Located<Expr<'a>> {
|
pub fn desugar<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a Located<Expr<'a>> {
|
||||||
use operator::Associativity::*;
|
use crate::operator::Associativity::*;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
match &loc_expr.value {
|
match &loc_expr.value {
|
||||||
|
@ -295,7 +295,7 @@ pub fn desugar<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a Loca
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
UnaryOp(loc_arg, loc_op) => {
|
UnaryOp(loc_arg, loc_op) => {
|
||||||
use operator::UnaryOp::*;
|
use crate::operator::UnaryOp::*;
|
||||||
|
|
||||||
let region = loc_op.region;
|
let region = loc_op.region;
|
||||||
let op = loc_op.value;
|
let op = loc_op.value;
|
||||||
|
@ -414,7 +414,8 @@ fn desugar_field<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
field: &'a AssignedField<'a, Expr<'a>>,
|
field: &'a AssignedField<'a, Expr<'a>>,
|
||||||
) -> AssignedField<'a, Expr<'a>> {
|
) -> AssignedField<'a, Expr<'a>> {
|
||||||
use parse::ast::AssignedField::*;
|
use crate::parse::ast::AssignedField::*;
|
||||||
|
|
||||||
match field {
|
match field {
|
||||||
LabeledValue(ref loc_str, spaces, loc_expr) => {
|
LabeledValue(ref loc_str, spaces, loc_expr) => {
|
||||||
AssignedField::LabeledValue(loc_str.clone(), spaces, desugar(arena, loc_expr))
|
AssignedField::LabeledValue(loc_str.clone(), spaces, desugar(arena, loc_expr))
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
use can::env::Env;
|
use crate::can::env::Env;
|
||||||
use can::num::{
|
use crate::can::num::{
|
||||||
finish_parsing_bin, finish_parsing_float, finish_parsing_hex, finish_parsing_int,
|
finish_parsing_bin, finish_parsing_float, finish_parsing_hex, finish_parsing_int,
|
||||||
finish_parsing_oct,
|
finish_parsing_oct,
|
||||||
};
|
};
|
||||||
use can::problem::Problem;
|
use crate::can::problem::Problem;
|
||||||
use can::scope::Scope;
|
use crate::can::scope::Scope;
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use collections::ImMap;
|
use crate::collections::ImMap;
|
||||||
use ident::{Ident, VariantName};
|
use crate::ident::{Ident, VariantName};
|
||||||
use parse::ast;
|
use crate::parse::ast;
|
||||||
use region::{Located, Region};
|
use crate::region::{Located, Region};
|
||||||
use subs::Subs;
|
use crate::subs::Subs;
|
||||||
use subs::Variable;
|
use crate::subs::Variable;
|
||||||
use types::{Constraint, PExpected, PatternCategory, Type};
|
use crate::types::{Constraint, PExpected, PatternCategory, Type};
|
||||||
|
|
||||||
/// A pattern, including possible problems (e.g. shadowing) so that
|
/// A pattern, including possible problems (e.g. shadowing) so that
|
||||||
/// codegen can generate a runtime error if this pattern is reached.
|
/// codegen can generate a runtime error if this pattern is reached.
|
||||||
|
@ -59,7 +59,7 @@ pub fn canonicalize_pattern<'a>(
|
||||||
expected: PExpected<Type>,
|
expected: PExpected<Type>,
|
||||||
) -> Located<Pattern> {
|
) -> Located<Pattern> {
|
||||||
use self::PatternType::*;
|
use self::PatternType::*;
|
||||||
use can::ast::Pattern::*;
|
use crate::can::ast::Pattern::*;
|
||||||
|
|
||||||
let can_pattern = match &pattern {
|
let can_pattern = match &pattern {
|
||||||
&Identifier(ref name) => {
|
&Identifier(ref name) => {
|
||||||
|
@ -292,7 +292,7 @@ fn add_constraints<'a>(
|
||||||
expected: PExpected<Type>,
|
expected: PExpected<Type>,
|
||||||
state: &'a mut PatternState,
|
state: &'a mut PatternState,
|
||||||
) {
|
) {
|
||||||
use parse::ast::Pattern::*;
|
use crate::parse::ast::Pattern::*;
|
||||||
|
|
||||||
match pattern {
|
match pattern {
|
||||||
Underscore | Malformed(_) | QualifiedIdentifier(_) => {
|
Underscore | Malformed(_) | QualifiedIdentifier(_) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use can::pattern::PatternType;
|
use crate::can::pattern::PatternType;
|
||||||
use ident::{Ident, VariantName};
|
use crate::ident::{Ident, VariantName};
|
||||||
use operator::BinOp;
|
use crate::operator::BinOp;
|
||||||
use region::{Located, Region};
|
use crate::region::{Located, Region};
|
||||||
|
|
||||||
/// Problems that can occur in the course of canonicalization.
|
/// Problems that can occur in the course of canonicalization.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use can::expr::Expr;
|
use crate::can::expr::Expr;
|
||||||
use can::pattern::Pattern;
|
use crate::can::pattern::Pattern;
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use collections::ImSet;
|
use crate::collections::ImSet;
|
||||||
use region::{Located, Region};
|
use crate::region::{Located, Region};
|
||||||
use subs::Variable;
|
use crate::subs::Variable;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct Procedure {
|
pub struct Procedure {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use collections::ImMap;
|
use crate::collections::ImMap;
|
||||||
use ident::Ident;
|
use crate::ident::Ident;
|
||||||
use region::Region;
|
use crate::region::Region;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct Scope {
|
pub struct Scope {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
// use bumpalo::collections::string::String;
|
// use bumpalo::collections::string::String;
|
||||||
// use bumpalo::collections::vec::Vec;
|
// use bumpalo::collections::vec::Vec;
|
||||||
|
use crate::parse::ast::Expr;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use parse::ast::Expr;
|
// use crate::parse::ast::{Attempting, Expr};
|
||||||
// use parse::ast::{Attempting, Expr};
|
// use crate::parse::ident;
|
||||||
// use parse::ident;
|
// use crate::parse::parser::{unexpected, unexpected_eof, Fail, Parser, State};
|
||||||
// use parse::parser::{unexpected, unexpected_eof, Fail, Parser, State};
|
// use crate::parse::problems::{Problem, Problems};
|
||||||
// use parse::problems::{Problem, Problems};
|
// use crate::region::{Loc, Region};
|
||||||
// use region::{Loc, Region};
|
use crate::region::Region;
|
||||||
use region::Region;
|
|
||||||
// use std::char;
|
// use std::char;
|
||||||
// use std::iter::Peekable;
|
// use std::iter::Peekable;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ident::{UnqualifiedIdent, VariantName};
|
use crate::ident::{UnqualifiedIdent, VariantName};
|
||||||
use module::ModuleName;
|
use crate::module::ModuleName;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
/// A globally unique identifier, used for both vars and variants.
|
/// A globally unique identifier, used for both vars and variants.
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use collections::ImMap;
|
use crate::collections::ImMap;
|
||||||
use region::Region;
|
use crate::region::Region;
|
||||||
use subs::{Subs, Variable};
|
use crate::subs::{Subs, Variable};
|
||||||
use types::Constraint::{self, *};
|
use crate::types::Constraint::{self, *};
|
||||||
use types::Expected::{self, *};
|
use crate::types::Expected::{self, *};
|
||||||
use types::Type::{self, *};
|
use crate::types::Type::{self, *};
|
||||||
use types::{self, LetConstraint, Reason};
|
use crate::types::{self, LetConstraint, Reason};
|
||||||
|
|
||||||
pub fn exists(flex_vars: Vec<Variable>, constraint: Constraint) -> Constraint {
|
pub fn exists(flex_vars: Vec<Variable>, constraint: Constraint) -> Constraint {
|
||||||
Constraint::Let(Box::new(LetConstraint {
|
Constraint::Let(Box::new(LetConstraint {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use ena::snapshot_vec as sv;
|
use crate::ena::snapshot_vec as sv;
|
||||||
#[cfg(feature = "persistent")]
|
#[cfg(feature = "persistent")]
|
||||||
use im::Vector;
|
use im::Vector;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use fmt::expr::fmt_expr;
|
use crate::fmt::expr::fmt_expr;
|
||||||
use fmt::pattern::fmt_pattern;
|
use crate::fmt::pattern::fmt_pattern;
|
||||||
use fmt::spaces::fmt_spaces;
|
use crate::fmt::spaces::fmt_spaces;
|
||||||
|
use crate::parse::ast::Def;
|
||||||
use bumpalo::collections::String;
|
use bumpalo::collections::String;
|
||||||
use parse::ast::Def;
|
|
||||||
|
|
||||||
pub fn fmt_def<'a>(buf: &mut String<'a>, def: &'a Def<'a>, indent: u16) {
|
pub fn fmt_def<'a>(buf: &mut String<'a>, def: &'a Def<'a>, indent: u16) {
|
||||||
match def {
|
match def {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
use crate::fmt::def::fmt_def;
|
||||||
|
use crate::fmt::pattern::fmt_pattern;
|
||||||
|
use crate::fmt::spaces::{add_spaces, fmt_comments_only, fmt_spaces, newline, INDENT};
|
||||||
|
use crate::parse::ast::{AssignedField, Expr, Pattern};
|
||||||
|
use crate::region::Located;
|
||||||
use bumpalo::collections::{String, Vec};
|
use bumpalo::collections::{String, Vec};
|
||||||
use fmt::def::fmt_def;
|
|
||||||
use fmt::pattern::fmt_pattern;
|
|
||||||
use fmt::spaces::{add_spaces, fmt_comments_only, fmt_spaces, newline, INDENT};
|
|
||||||
use parse::ast::{AssignedField, Expr, Pattern};
|
|
||||||
use region::Located;
|
|
||||||
|
|
||||||
pub fn fmt_expr<'a>(
|
pub fn fmt_expr<'a>(
|
||||||
buf: &mut String<'a>,
|
buf: &mut String<'a>,
|
||||||
|
@ -234,7 +234,7 @@ pub fn fmt_field<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_multiline_expr<'a>(expr: &'a Expr<'a>) -> bool {
|
pub fn is_multiline_expr<'a>(expr: &'a Expr<'a>) -> bool {
|
||||||
use parse::ast::Expr::*;
|
use crate::parse::ast::Expr::*;
|
||||||
// TODO cache these answers using a Map<Pointer, bool>, so
|
// TODO cache these answers using a Map<Pointer, bool>, so
|
||||||
// we don't have to traverse subexpressions repeatedly
|
// we don't have to traverse subexpressions repeatedly
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
use crate::fmt::spaces::{fmt_spaces, INDENT};
|
||||||
|
use crate::parse::ast::{AppHeader, ExposesEntry, ImportsEntry, InterfaceHeader, Module};
|
||||||
|
use crate::region::Located;
|
||||||
use bumpalo::collections::{String, Vec};
|
use bumpalo::collections::{String, Vec};
|
||||||
use fmt::spaces::{fmt_spaces, INDENT};
|
|
||||||
use parse::ast::{AppHeader, ExposesEntry, ImportsEntry, InterfaceHeader, Module};
|
|
||||||
use region::Located;
|
|
||||||
|
|
||||||
pub fn fmt_module<'a>(buf: &mut String<'a>, module: &'a Module<'a>) {
|
pub fn fmt_module<'a>(buf: &mut String<'a>, module: &'a Module<'a>) {
|
||||||
match module {
|
match module {
|
||||||
|
@ -127,7 +127,7 @@ fn fmt_exposes<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_exposes_entry<'a>(buf: &mut String<'a>, entry: &'a ExposesEntry<'a>, indent: u16) {
|
fn fmt_exposes_entry<'a>(buf: &mut String<'a>, entry: &'a ExposesEntry<'a>, indent: u16) {
|
||||||
use parse::ast::ExposesEntry::*;
|
use crate::parse::ast::ExposesEntry::*;
|
||||||
|
|
||||||
match entry {
|
match entry {
|
||||||
Ident(ident) => buf.push_str(ident.as_str()),
|
Ident(ident) => buf.push_str(ident.as_str()),
|
||||||
|
@ -144,7 +144,7 @@ fn fmt_exposes_entry<'a>(buf: &mut String<'a>, entry: &'a ExposesEntry<'a>, inde
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_imports_entry<'a>(buf: &mut String<'a>, entry: &'a ImportsEntry<'a>, indent: u16) {
|
fn fmt_imports_entry<'a>(buf: &mut String<'a>, entry: &'a ImportsEntry<'a>, indent: u16) {
|
||||||
use parse::ast::ImportsEntry::*;
|
use crate::parse::ast::ImportsEntry::*;
|
||||||
|
|
||||||
match entry {
|
match entry {
|
||||||
Module(module, loc_exposes_entries) => {
|
Module(module, loc_exposes_entries) => {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use fmt::spaces::fmt_spaces;
|
use crate::fmt::spaces::fmt_spaces;
|
||||||
|
use crate::parse::ast::Pattern;
|
||||||
use bumpalo::collections::String;
|
use bumpalo::collections::String;
|
||||||
use parse::ast::Pattern;
|
|
||||||
|
|
||||||
pub fn fmt_pattern<'a>(
|
pub fn fmt_pattern<'a>(
|
||||||
buf: &mut String<'a>,
|
buf: &mut String<'a>,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
use crate::parse::ast::CommentOrNewline;
|
||||||
use bumpalo::collections::String;
|
use bumpalo::collections::String;
|
||||||
use parse::ast::CommentOrNewline;
|
|
||||||
|
|
||||||
/// The number of spaces to indent.
|
/// The number of spaces to indent.
|
||||||
pub const INDENT: u16 = 4;
|
pub const INDENT: u16 = 4;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
extern crate inkwell;
|
|
||||||
|
|
||||||
use inkwell::basic_block::BasicBlock;
|
use inkwell::basic_block::BasicBlock;
|
||||||
use inkwell::builder::Builder;
|
use inkwell::builder::Builder;
|
||||||
use inkwell::context::Context;
|
use inkwell::context::Context;
|
||||||
|
@ -8,15 +6,15 @@ use inkwell::types::BasicTypeEnum;
|
||||||
use inkwell::values::{BasicValueEnum, FloatValue, FunctionValue, IntValue, PointerValue};
|
use inkwell::values::{BasicValueEnum, FloatValue, FunctionValue, IntValue, PointerValue};
|
||||||
use inkwell::{FloatPredicate, IntPredicate};
|
use inkwell::{FloatPredicate, IntPredicate};
|
||||||
|
|
||||||
use can::expr::Expr;
|
use crate::can::expr::Expr;
|
||||||
use can::pattern::Pattern::{self, *};
|
use crate::can::pattern::Pattern::{self, *};
|
||||||
use can::procedure::Procedure;
|
use crate::can::procedure::Procedure;
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use collections::ImMap;
|
use crate::collections::ImMap;
|
||||||
use collections::MutMap;
|
use crate::collections::MutMap;
|
||||||
use subs::FlatType::*;
|
use crate::subs::FlatType::*;
|
||||||
use subs::{Content, Subs, Variable};
|
use crate::subs::{Content, Subs, Variable};
|
||||||
use types;
|
use crate::types;
|
||||||
|
|
||||||
enum TypedVal<'ctx> {
|
enum TypedVal<'ctx> {
|
||||||
FloatConst(FloatValue<'ctx>),
|
FloatConst(FloatValue<'ctx>),
|
||||||
|
@ -109,7 +107,7 @@ fn compile_expr<'ctx, 'env>(
|
||||||
vars: &mut ImMap<Symbol, PointerValue<'ctx>>,
|
vars: &mut ImMap<Symbol, PointerValue<'ctx>>,
|
||||||
) -> TypedVal<'ctx> {
|
) -> TypedVal<'ctx> {
|
||||||
use self::TypedVal::*;
|
use self::TypedVal::*;
|
||||||
use can::expr::Expr::*;
|
use crate::can::expr::Expr::*;
|
||||||
|
|
||||||
match *expr {
|
match *expr {
|
||||||
Int(num) => IntConst(env.context.i64_type().const_int(num as u64, false)),
|
Int(num) => IntConst(env.context.i64_type().const_int(num as u64, false)),
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
// Secondarily, SipHash isn't the fastest hashing algorithm out there, so we can get
|
// Secondarily, SipHash isn't the fastest hashing algorithm out there, so we can get
|
||||||
// slightly better performance by using a faster hasher.
|
// slightly better performance by using a faster hasher.
|
||||||
|
|
||||||
use collections::{default_hasher, BuildHasher, MutSet};
|
use crate::collections::{default_hasher, BuildHasher, MutSet};
|
||||||
use std::collections::{HashMap, HashSet, VecDeque};
|
use std::collections::{HashMap, HashSet, VecDeque};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
12
src/infer.rs
12
src/infer.rs
|
@ -1,9 +1,9 @@
|
||||||
use can::procedure::Procedure;
|
use crate::can::procedure::Procedure;
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use collections::{ImMap, MutMap};
|
use crate::collections::{ImMap, MutMap};
|
||||||
use solve::solve;
|
use crate::solve::solve;
|
||||||
use subs::{Content, Subs, Variable};
|
use crate::subs::{Content, Subs, Variable};
|
||||||
use types::Constraint;
|
use crate::types::Constraint;
|
||||||
|
|
||||||
pub fn infer_expr(
|
pub fn infer_expr(
|
||||||
subs: &mut Subs,
|
subs: &mut Subs,
|
||||||
|
|
|
@ -21,10 +21,5 @@ pub mod subs;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
pub mod unify;
|
pub mod unify;
|
||||||
|
|
||||||
extern crate bumpalo;
|
|
||||||
extern crate im_rc;
|
|
||||||
extern crate inkwell;
|
|
||||||
extern crate wyhash;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
use crate::can::symbol::Symbol;
|
||||||
|
use crate::collections::{ImMap, MutMap};
|
||||||
|
use crate::ident::UnqualifiedIdent;
|
||||||
|
use crate::module::ModuleName;
|
||||||
|
use crate::parse::ast::{Attempting, Def, ExposesEntry, ImportsEntry, Module};
|
||||||
|
use crate::parse::module;
|
||||||
|
use crate::parse::parser::{Fail, Parser, State};
|
||||||
|
use crate::region::{Located, Region};
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use can::symbol::Symbol;
|
|
||||||
use collections::{ImMap, MutMap};
|
|
||||||
use ident::UnqualifiedIdent;
|
|
||||||
use module::ModuleName;
|
|
||||||
use parse::ast::{Attempting, Def, ExposesEntry, ImportsEntry, Module};
|
|
||||||
use parse::module;
|
|
||||||
use parse::parser::{Fail, Parser, State};
|
|
||||||
use region::{Located, Region};
|
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -191,7 +191,7 @@ fn load_import<'a, 'p>(
|
||||||
entry: &ImportsEntry<'a>,
|
entry: &ImportsEntry<'a>,
|
||||||
scope: &mut ImMap<UnqualifiedIdent<'a>, (Symbol, Region)>,
|
scope: &mut ImMap<UnqualifiedIdent<'a>, (Symbol, Region)>,
|
||||||
) {
|
) {
|
||||||
use parse::ast::ImportsEntry::*;
|
use crate::parse::ast::ImportsEntry::*;
|
||||||
|
|
||||||
match entry {
|
match entry {
|
||||||
Module(module_name, exposes) => {
|
Module(module_name, exposes) => {
|
||||||
|
@ -220,7 +220,7 @@ fn expose<'a>(
|
||||||
region: Region,
|
region: Region,
|
||||||
scope: &mut ImMap<UnqualifiedIdent<'a>, (Symbol, Region)>,
|
scope: &mut ImMap<UnqualifiedIdent<'a>, (Symbol, Region)>,
|
||||||
) {
|
) {
|
||||||
use parse::ast::ExposesEntry::*;
|
use crate::parse::ast::ExposesEntry::*;
|
||||||
|
|
||||||
match entry {
|
match entry {
|
||||||
Ident(ident) => {
|
Ident(ident) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
use crate::ident::UnqualifiedIdent;
|
||||||
|
use crate::parse::ast::CommentOrNewline;
|
||||||
|
use crate::region::Loc;
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use ident::UnqualifiedIdent;
|
|
||||||
use parse::ast::CommentOrNewline;
|
|
||||||
use region::Loc;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
|
||||||
pub struct ModuleName<'a>(&'a str);
|
pub struct ModuleName<'a>(&'a str);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
use crate::ident::UnqualifiedIdent;
|
||||||
|
use crate::module::ModuleName;
|
||||||
|
use crate::operator::CalledVia;
|
||||||
|
use crate::operator::{BinOp, UnaryOp};
|
||||||
|
use crate::parse::ident::Ident;
|
||||||
|
use crate::region::{Loc, Region};
|
||||||
use bumpalo::collections::String;
|
use bumpalo::collections::String;
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use ident::UnqualifiedIdent;
|
|
||||||
use module::ModuleName;
|
|
||||||
use operator::CalledVia;
|
|
||||||
use operator::{BinOp, UnaryOp};
|
|
||||||
use parse::ident::Ident;
|
|
||||||
use region::{Loc, Region};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum Module<'a> {
|
pub enum Module<'a> {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
use crate::parse::ast::CommentOrNewline::{self, *};
|
||||||
|
use crate::parse::ast::Spaceable;
|
||||||
|
use crate::parse::parser::{self, and, unexpected, unexpected_eof, Parser, State};
|
||||||
|
use crate::region::Located;
|
||||||
use bumpalo::collections::string::String;
|
use bumpalo::collections::string::String;
|
||||||
use bumpalo::collections::vec::Vec;
|
use bumpalo::collections::vec::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use parse::ast::CommentOrNewline::{self, *};
|
|
||||||
use parse::ast::Spaceable;
|
|
||||||
use parse::parser::{self, and, unexpected, unexpected_eof, Parser, State};
|
|
||||||
use region::Located;
|
|
||||||
|
|
||||||
/// Parses the given expression with 0 or more (spaces/comments/newlines) before and/or after it.
|
/// Parses the given expression with 0 or more (spaces/comments/newlines) before and/or after it.
|
||||||
/// Returns a Located<Expr> where the location is around the Expr, ignoring the spaces.
|
/// Returns a Located<Expr> where the location is around the Expr, ignoring the spaces.
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
use crate::collections::arena_join;
|
||||||
|
use crate::ident::UnqualifiedIdent;
|
||||||
|
use crate::parse::ast::{Attempting, MaybeQualified};
|
||||||
|
use crate::parse::parser::{unexpected, unexpected_eof, ParseResult, Parser, State};
|
||||||
use bumpalo::collections::string::String;
|
use bumpalo::collections::string::String;
|
||||||
use bumpalo::collections::vec::Vec;
|
use bumpalo::collections::vec::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use collections::arena_join;
|
|
||||||
use ident::UnqualifiedIdent;
|
|
||||||
use parse::ast::{Attempting, MaybeQualified};
|
|
||||||
use parse::parser::{unexpected, unexpected_eof, ParseResult, Parser, State};
|
|
||||||
|
|
||||||
/// The parser accepts all of these in any position where any one of them could
|
/// The parser accepts all of these in any position where any one of them could
|
||||||
/// appear. This way, canonicalization can give more helpful error messages like
|
/// appear. This way, canonicalization can give more helpful error messages like
|
||||||
|
|
|
@ -10,22 +10,21 @@ pub mod problems;
|
||||||
pub mod string_literal;
|
pub mod string_literal;
|
||||||
pub mod type_annotation;
|
pub mod type_annotation;
|
||||||
|
|
||||||
use bumpalo::collections::Vec;
|
use crate::operator::{BinOp, CalledVia, UnaryOp};
|
||||||
use bumpalo::Bump;
|
use crate::parse::ast::{AssignedField, Attempting, Def, Expr, MaybeQualified, Pattern, Spaceable};
|
||||||
use operator::{BinOp, CalledVia, UnaryOp};
|
use crate::parse::blankspace::{
|
||||||
use parse;
|
|
||||||
use parse::ast::{AssignedField, Attempting, Def, Expr, MaybeQualified, Pattern, Spaceable};
|
|
||||||
use parse::blankspace::{
|
|
||||||
space0, space0_after, space0_around, space0_before, space1, space1_after, space1_around,
|
space0, space0_after, space0_around, space0_before, space1, space1_after, space1_around,
|
||||||
space1_before,
|
space1_before,
|
||||||
};
|
};
|
||||||
use parse::ident::{ident, lowercase_ident, variant_or_ident, Ident};
|
use crate::parse::ident::{ident, lowercase_ident, variant_or_ident, Ident};
|
||||||
use parse::number_literal::number_literal;
|
use crate::parse::number_literal::number_literal;
|
||||||
use parse::parser::{
|
use crate::parse::parser::{
|
||||||
allocated, char, not, not_followed_by, optional, string, then, unexpected, unexpected_eof,
|
allocated, char, not, not_followed_by, optional, string, then, unexpected, unexpected_eof,
|
||||||
Either, Fail, FailReason, ParseResult, Parser, State,
|
Either, Fail, FailReason, ParseResult, Parser, State,
|
||||||
};
|
};
|
||||||
use region::{Located, Region};
|
use crate::region::{Located, Region};
|
||||||
|
use bumpalo::collections::Vec;
|
||||||
|
use bumpalo::Bump;
|
||||||
|
|
||||||
pub fn expr<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>> {
|
pub fn expr<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>> {
|
||||||
// Recursive parsers must not directly invoke functions which return (impl Parser),
|
// Recursive parsers must not directly invoke functions which return (impl Parser),
|
||||||
|
@ -81,7 +80,7 @@ pub fn unary_op<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_expr<'a>(min_indent: u16, arena: &'a Bump, state: State<'a>) -> ParseResult<'a, Expr<'a>> {
|
fn parse_expr<'a>(min_indent: u16, arena: &'a Bump, state: State<'a>) -> ParseResult<'a, Expr<'a>> {
|
||||||
let expr_parser = parse::parser::map_with_arena(
|
let expr_parser = crate::parse::parser::map_with_arena(
|
||||||
and!(
|
and!(
|
||||||
// First parse the body without operators, then try to parse possible operators after.
|
// First parse the body without operators, then try to parse possible operators after.
|
||||||
move |arena, state| loc_parse_expr_body_without_operators(min_indent, arena, state),
|
move |arena, state| loc_parse_expr_body_without_operators(min_indent, arena, state),
|
||||||
|
@ -681,10 +680,15 @@ fn int_pattern<'a>() -> impl Parser<'a, Pattern<'a>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn string_pattern<'a>() -> impl Parser<'a, Pattern<'a>> {
|
fn string_pattern<'a>() -> impl Parser<'a, Pattern<'a>> {
|
||||||
map!(parse::string_literal::parse(), |result| match result {
|
map!(
|
||||||
parse::string_literal::StringLiteral::Line(string) => Pattern::StrLiteral(string),
|
crate::parse::string_literal::parse(),
|
||||||
parse::string_literal::StringLiteral::Block(lines) => Pattern::BlockStrLiteral(lines),
|
|result| match result {
|
||||||
})
|
crate::parse::string_literal::StringLiteral::Line(string) =>
|
||||||
|
Pattern::StrLiteral(string),
|
||||||
|
crate::parse::string_literal::StringLiteral::Block(lines) =>
|
||||||
|
Pattern::BlockStrLiteral(lines),
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn underscore_pattern<'a>() -> impl Parser<'a, Pattern<'a>> {
|
fn underscore_pattern<'a>() -> impl Parser<'a, Pattern<'a>> {
|
||||||
|
@ -1166,8 +1170,11 @@ fn unqualified_variant<'a>() -> impl Parser<'a, &'a str> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn string_literal<'a>() -> impl Parser<'a, Expr<'a>> {
|
pub fn string_literal<'a>() -> impl Parser<'a, Expr<'a>> {
|
||||||
map!(parse::string_literal::parse(), |result| match result {
|
map!(
|
||||||
parse::string_literal::StringLiteral::Line(string) => Expr::Str(string),
|
crate::parse::string_literal::parse(),
|
||||||
parse::string_literal::StringLiteral::Block(lines) => Expr::BlockStr(lines),
|
|result| match result {
|
||||||
})
|
crate::parse::string_literal::StringLiteral::Line(string) => Expr::Str(string),
|
||||||
|
crate::parse::string_literal::StringLiteral::Block(lines) => Expr::BlockStr(lines),
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
use bumpalo::collections::{String, Vec};
|
use crate::module::ModuleName;
|
||||||
use module::ModuleName;
|
use crate::parse;
|
||||||
use parse::ast::{
|
use crate::parse::ast::{
|
||||||
AppHeader, Attempting, CommentOrNewline, Def, ExposesEntry, ImportsEntry, InterfaceHeader,
|
AppHeader, Attempting, CommentOrNewline, Def, ExposesEntry, ImportsEntry, InterfaceHeader,
|
||||||
Module,
|
Module,
|
||||||
};
|
};
|
||||||
use parse::blankspace::{space0_around, space1};
|
use crate::parse::blankspace::{space0_around, space1};
|
||||||
use parse::ident::unqualified_ident;
|
use crate::parse::ident::unqualified_ident;
|
||||||
use parse::parse;
|
use crate::parse::parser::{
|
||||||
use parse::parser::{self, char, loc, optional, string, unexpected, unexpected_eof, Parser, State};
|
self, char, loc, optional, string, unexpected, unexpected_eof, Parser, State,
|
||||||
use region::Located;
|
};
|
||||||
|
use crate::region::Located;
|
||||||
|
use bumpalo::collections::{String, Vec};
|
||||||
|
|
||||||
pub fn module<'a>() -> impl Parser<'a, Module<'a>> {
|
pub fn module<'a>() -> impl Parser<'a, Module<'a>> {
|
||||||
one_of!(interface_module(), app_module())
|
one_of!(interface_module(), app_module())
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use parse::ast::{Attempting, Expr};
|
use crate::parse::ast::{Attempting, Expr};
|
||||||
use parse::parser::{unexpected, unexpected_eof, ParseResult, Parser, State};
|
use crate::parse::parser::{unexpected, unexpected_eof, ParseResult, Parser, State};
|
||||||
use std::char;
|
use std::char;
|
||||||
|
|
||||||
pub fn number_literal<'a>() -> impl Parser<'a, Expr<'a>> {
|
pub fn number_literal<'a>() -> impl Parser<'a, Expr<'a>> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
use crate::parse::ast::Attempting;
|
||||||
|
use crate::region::{Located, Region};
|
||||||
use bumpalo::collections::vec::Vec;
|
use bumpalo::collections::vec::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use parse::ast::Attempting;
|
|
||||||
use region::{Located, Region};
|
|
||||||
use std::{char, u16};
|
use std::{char, u16};
|
||||||
|
|
||||||
/// A position in a source file.
|
/// A position in a source file.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use region::Loc;
|
use crate::region::Loc;
|
||||||
|
|
||||||
pub type Problems = Vec<Loc<Problem>>;
|
pub type Problems = Vec<Loc<Problem>>;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
use crate::parse::ast::Attempting;
|
||||||
|
use crate::parse::parser::{unexpected, unexpected_eof, ParseResult, Parser, State};
|
||||||
use bumpalo::collections::vec::Vec;
|
use bumpalo::collections::vec::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use parse::ast::Attempting;
|
|
||||||
use parse::parser::{unexpected, unexpected_eof, ParseResult, Parser, State};
|
|
||||||
use std::char;
|
use std::char;
|
||||||
|
|
||||||
pub enum StringLiteral<'a> {
|
pub enum StringLiteral<'a> {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
use crate::collections::arena_join;
|
||||||
|
use crate::parse::ast::{Attempting, TypeAnnotation};
|
||||||
|
use crate::parse::blankspace::{space0_around, space1_before};
|
||||||
|
use crate::parse::parser::{
|
||||||
|
char, optional, string, unexpected, unexpected_eof, ParseResult, Parser, State,
|
||||||
|
};
|
||||||
|
use crate::region::Located;
|
||||||
use bumpalo::collections::string::String;
|
use bumpalo::collections::string::String;
|
||||||
use bumpalo::collections::vec::Vec;
|
use bumpalo::collections::vec::Vec;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use collections::arena_join;
|
|
||||||
use parse::ast::{Attempting, TypeAnnotation};
|
|
||||||
use parse::blankspace::{space0_around, space1_before};
|
|
||||||
use parse::parser::{
|
|
||||||
char, optional, string, unexpected, unexpected_eof, ParseResult, Parser, State,
|
|
||||||
};
|
|
||||||
use region::Located;
|
|
||||||
|
|
||||||
pub fn located<'a>(min_indent: u16) -> impl Parser<'a, Located<TypeAnnotation<'a>>> {
|
pub fn located<'a>(min_indent: u16) -> impl Parser<'a, Located<TypeAnnotation<'a>>> {
|
||||||
one_of!(
|
one_of!(
|
||||||
|
@ -36,7 +36,7 @@ fn loc_parenthetical_type<'a>(min_indent: u16) -> impl Parser<'a, Located<TypeAn
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn record_type<'a>(min_indent: u16) -> impl Parser<'a, TypeAnnotation<'a>> {
|
fn record_type<'a>(min_indent: u16) -> impl Parser<'a, TypeAnnotation<'a>> {
|
||||||
use parse::type_annotation::TypeAnnotation::*;
|
use crate::parse::type_annotation::TypeAnnotation::*;
|
||||||
|
|
||||||
map_with_arena!(
|
map_with_arena!(
|
||||||
and!(
|
and!(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use collections::{MutMap, MutSet};
|
use crate::collections::{MutMap, MutSet};
|
||||||
use subs::{Content, FlatType, Subs, Variable};
|
use crate::subs::{Content, FlatType, Subs, Variable};
|
||||||
use types;
|
use crate::types;
|
||||||
|
|
||||||
static WILDCARD: &str = "*";
|
static WILDCARD: &str = "*";
|
||||||
static EMPTY_RECORD: &str = "{}";
|
static EMPTY_RECORD: &str = "{}";
|
||||||
|
@ -53,8 +53,8 @@ fn find_names_needed(
|
||||||
root_appearances: &mut MutMap<Variable, Appearances>,
|
root_appearances: &mut MutMap<Variable, Appearances>,
|
||||||
names_taken: &mut MutSet<String>,
|
names_taken: &mut MutSet<String>,
|
||||||
) {
|
) {
|
||||||
use subs::Content::*;
|
use crate::subs::Content::*;
|
||||||
use subs::FlatType::*;
|
use crate::subs::FlatType::*;
|
||||||
|
|
||||||
match subs.get(variable).content {
|
match subs.get(variable).content {
|
||||||
FlexVar(None) => {
|
FlexVar(None) => {
|
||||||
|
@ -141,7 +141,7 @@ fn name_root(letters_used: u32, root: Variable, subs: &mut Subs, taken: &MutSet<
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_root_name(root: Variable, name: &str, subs: &mut Subs) {
|
fn set_root_name(root: Variable, name: &str, subs: &mut Subs) {
|
||||||
use subs::Content::*;
|
use crate::subs::Content::*;
|
||||||
|
|
||||||
let mut descriptor = subs.get(root);
|
let mut descriptor = subs.get(root);
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ pub fn content_to_string(content: Content, subs: &mut Subs) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_content(content: Content, subs: &mut Subs, buf: &mut String, parens: Parens) {
|
fn write_content(content: Content, subs: &mut Subs, buf: &mut String, parens: Parens) {
|
||||||
use subs::Content::*;
|
use crate::subs::Content::*;
|
||||||
|
|
||||||
match content {
|
match content {
|
||||||
FlexVar(Some(name)) => buf.push_str(&name),
|
FlexVar(Some(name)) => buf.push_str(&name),
|
||||||
|
@ -180,7 +180,7 @@ fn write_content(content: Content, subs: &mut Subs, buf: &mut String, parens: Pa
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_flat_type(flat_type: FlatType, subs: &mut Subs, buf: &mut String, parens: Parens) {
|
fn write_flat_type(flat_type: FlatType, subs: &mut Subs, buf: &mut String, parens: Parens) {
|
||||||
use subs::FlatType::*;
|
use crate::subs::FlatType::*;
|
||||||
|
|
||||||
match flat_type {
|
match flat_type {
|
||||||
Apply {
|
Apply {
|
||||||
|
|
10
src/solve.rs
10
src/solve.rs
|
@ -1,8 +1,8 @@
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use collections::ImMap;
|
use crate::collections::ImMap;
|
||||||
use subs::{Content, Descriptor, FlatType, Subs, Variable};
|
use crate::subs::{Content, Descriptor, FlatType, Subs, Variable};
|
||||||
use types::Constraint::{self, *};
|
use crate::types::Constraint::{self, *};
|
||||||
use types::Type::{self, *};
|
use crate::types::Type::{self, *};
|
||||||
|
|
||||||
type Env = ImMap<Symbol, Variable>;
|
type Env = ImMap<Symbol, Variable>;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ena::unify::{InPlace, UnificationTable, UnifyKey};
|
use crate::ena::unify::{InPlace, UnificationTable, UnifyKey};
|
||||||
|
use crate::types::Problem;
|
||||||
|
use crate::unify;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use types::Problem;
|
|
||||||
use unify;
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Subs {
|
pub struct Subs {
|
||||||
|
|
12
src/types.rs
12
src/types.rs
|
@ -1,10 +1,10 @@
|
||||||
use can::symbol::Symbol;
|
use crate::can::symbol::Symbol;
|
||||||
use collections::ImMap;
|
use crate::collections::ImMap;
|
||||||
use operator::{ArgSide, BinOp};
|
use crate::operator::{ArgSide, BinOp};
|
||||||
use region::Located;
|
use crate::region::Located;
|
||||||
use region::Region;
|
use crate::region::Region;
|
||||||
|
use crate::subs::Variable;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use subs::Variable;
|
|
||||||
|
|
||||||
// The standard modules
|
// The standard modules
|
||||||
pub const MOD_FLOAT: &str = "Float";
|
pub const MOD_FLOAT: &str = "Float";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use subs::Content::{self, *};
|
use crate::subs::Content::{self, *};
|
||||||
use subs::{Descriptor, FlatType, Subs, Variable};
|
use crate::subs::{Descriptor, FlatType, Subs, Variable};
|
||||||
use types::Problem;
|
use crate::types::Problem;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn unify_vars(subs: &mut Subs, left_key: Variable, right_key: Variable) -> Descriptor {
|
pub fn unify_vars(subs: &mut Subs, left_key: Variable, right_key: Variable) -> Descriptor {
|
||||||
|
@ -52,7 +52,7 @@ fn unify_structure(subs: &mut Subs, flat_type: &FlatType, other: &Content) -> De
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn unify_flat_type(subs: &mut Subs, left: &FlatType, right: &FlatType) -> Descriptor {
|
fn unify_flat_type(subs: &mut Subs, left: &FlatType, right: &FlatType) -> Descriptor {
|
||||||
use subs::FlatType::*;
|
use crate::subs::FlatType::*;
|
||||||
|
|
||||||
match (left, right) {
|
match (left, right) {
|
||||||
(EmptyRecord, EmptyRecord) => from_content(Structure(left.clone())),
|
(EmptyRecord, EmptyRecord) => from_content(Structure(left.clone())),
|
||||||
|
|
|
@ -10,8 +10,8 @@ mod helpers;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_canonicalize {
|
mod test_canonicalize {
|
||||||
|
use crate::helpers::can_expr_with;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use helpers::can_expr_with;
|
|
||||||
use roc::can::expr::Expr::{self, *};
|
use roc::can::expr::Expr::{self, *};
|
||||||
use roc::can::problem::RuntimeError;
|
use roc::can::problem::RuntimeError;
|
||||||
use roc::can::procedure::References;
|
use roc::can::procedure::References;
|
||||||
|
|
|
@ -11,7 +11,7 @@ mod helpers;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_gen {
|
mod test_gen {
|
||||||
use helpers::can_expr;
|
use crate::helpers::can_expr;
|
||||||
use inkwell::context::Context;
|
use inkwell::context::Context;
|
||||||
use inkwell::execution_engine::JitFunction;
|
use inkwell::execution_engine::JitFunction;
|
||||||
use inkwell::types::BasicType;
|
use inkwell::types::BasicType;
|
||||||
|
|
|
@ -10,7 +10,7 @@ mod helpers;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_infer {
|
mod test_infer {
|
||||||
use helpers::can_expr;
|
use crate::helpers::can_expr;
|
||||||
use roc::infer::infer_expr;
|
use roc::infer::infer_expr;
|
||||||
use roc::pretty_print_types::{content_to_string, name_all_type_vars};
|
use roc::pretty_print_types::{content_to_string, name_all_type_vars};
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ mod helpers;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_load {
|
mod test_load {
|
||||||
|
use crate::helpers::{fixtures_dir, im_map_from_pairs, mut_map_from_pairs};
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use helpers::{fixtures_dir, im_map_from_pairs, mut_map_from_pairs};
|
|
||||||
use roc::can::symbol::Symbol;
|
use roc::can::symbol::Symbol;
|
||||||
use roc::ident::UnqualifiedIdent;
|
use roc::ident::UnqualifiedIdent;
|
||||||
use roc::load::LoadedHeader::*;
|
use roc::load::LoadedHeader::*;
|
||||||
|
|
|
@ -14,9 +14,9 @@ mod helpers;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_parse {
|
mod test_parse {
|
||||||
|
use crate::helpers::parse_with;
|
||||||
use bumpalo::collections::vec::Vec;
|
use bumpalo::collections::vec::Vec;
|
||||||
use bumpalo::{self, Bump};
|
use bumpalo::{self, Bump};
|
||||||
use helpers::parse_with;
|
|
||||||
use roc::module::ModuleName;
|
use roc::module::ModuleName;
|
||||||
use roc::operator::BinOp::*;
|
use roc::operator::BinOp::*;
|
||||||
use roc::operator::CalledVia;
|
use roc::operator::CalledVia;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue