Rename Located -> Loc

This commit is contained in:
Joshua Warner 2021-12-22 19:18:22 -08:00
parent c66c845cd2
commit f19220473a
55 changed files with 680 additions and 683 deletions

View file

@ -9,7 +9,7 @@ use roc_module::symbol::IdentIds;
use roc_parse::ast;
use roc_parse::ast::CommentOrNewline;
use roc_parse::ast::{AssignedField, Def};
use roc_region::all::Located;
use roc_region::all::Loc;
// Documentation generation requirements
@ -91,7 +91,7 @@ pub fn generate_module_docs<'a>(
scope: Scope,
module_name: ModuleName,
ident_ids: &'a IdentIds,
parsed_defs: &'a [Located<ast::Def<'a>>],
parsed_defs: &'a [Loc<ast::Def<'a>>],
) -> ModuleDocumentation {
let (entries, _) =
parsed_defs

View file

@ -8,7 +8,7 @@ use roc_collections::all::{MutSet, SendMap};
use roc_module::called_via::CalledVia;
use roc_module::ident::TagName;
use roc_module::symbol::Symbol;
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
use roc_types::types::Type;
@ -112,7 +112,7 @@ fn build_effect_always(
let const_closure = {
let arguments = vec![(
var_store.fresh(),
Located::at_zero(empty_record_pattern(var_store)),
Loc::at_zero(empty_record_pattern(var_store)),
)];
let body = Expr::Var(value_symbol);
@ -126,7 +126,7 @@ fn build_effect_always(
captured_symbols: vec![(value_symbol, var_store.fresh())],
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Located::at_zero(body)),
loc_body: Box::new(Loc::at_zero(body)),
})
};
@ -137,12 +137,12 @@ fn build_effect_always(
variant_var: var_store.fresh(),
ext_var: var_store.fresh(),
name: effect_tag_name.clone(),
arguments: vec![(var_store.fresh(), Located::at_zero(const_closure))],
arguments: vec![(var_store.fresh(), Loc::at_zero(const_closure))],
};
let arguments = vec![(
var_store.fresh(),
Located::at_zero(Pattern::Identifier(value_symbol)),
Loc::at_zero(Pattern::Identifier(value_symbol)),
)];
let function_var = var_store.fresh();
@ -155,7 +155,7 @@ fn build_effect_always(
captured_symbols: Vec::new(),
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Located::at_zero(body)),
loc_body: Box::new(Loc::at_zero(body)),
});
(function_var, closure)
@ -199,8 +199,8 @@ fn build_effect_always(
let mut pattern_vars = SendMap::default();
pattern_vars.insert(always_symbol, function_var);
let def = Def {
loc_pattern: Located::at_zero(pattern),
loc_expr: Located::at_zero(always_closure),
loc_pattern: Loc::at_zero(pattern),
loc_expr: Loc::at_zero(always_closure),
expr_var: function_var,
pattern_vars,
annotation: Some(def_annotation),
@ -255,12 +255,12 @@ fn build_effect_map(
let force_thunk_call = {
let boxed = (
var_store.fresh(),
Located::at_zero(Expr::Var(thunk_symbol)),
Loc::at_zero(Expr::Var(thunk_symbol)),
var_store.fresh(),
var_store.fresh(),
);
let arguments = vec![(var_store.fresh(), Located::at_zero(Expr::EmptyRecord))];
let arguments = vec![(var_store.fresh(), Loc::at_zero(Expr::EmptyRecord))];
Expr::Call(Box::new(boxed), arguments, CalledVia::Space)
};
@ -268,12 +268,12 @@ fn build_effect_map(
let mapper_call = {
let boxed = (
var_store.fresh(),
Located::at_zero(Expr::Var(mapper_symbol)),
Loc::at_zero(Expr::Var(mapper_symbol)),
var_store.fresh(),
var_store.fresh(),
);
let arguments = vec![(var_store.fresh(), Located::at_zero(force_thunk_call))];
let arguments = vec![(var_store.fresh(), Loc::at_zero(force_thunk_call))];
Expr::Call(Box::new(boxed), arguments, CalledVia::Space)
};
@ -292,7 +292,7 @@ fn build_effect_map(
let inner_closure = {
let arguments = vec![(
var_store.fresh(),
Located::at_zero(empty_record_pattern(var_store)),
Loc::at_zero(empty_record_pattern(var_store)),
)];
Expr::Closure(ClosureData {
@ -307,26 +307,26 @@ fn build_effect_map(
],
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Located::at_zero(mapper_call)),
loc_body: Box::new(Loc::at_zero(mapper_call)),
})
};
let arguments = vec![
(
var_store.fresh(),
Located::at_zero(Pattern::AppliedTag {
Loc::at_zero(Pattern::AppliedTag {
whole_var: var_store.fresh(),
ext_var: var_store.fresh(),
tag_name: effect_tag_name.clone(),
arguments: vec![(
var_store.fresh(),
Located::at_zero(Pattern::Identifier(thunk_symbol)),
Loc::at_zero(Pattern::Identifier(thunk_symbol)),
)],
}),
),
(
var_store.fresh(),
Located::at_zero(Pattern::Identifier(mapper_symbol)),
Loc::at_zero(Pattern::Identifier(mapper_symbol)),
),
];
@ -335,7 +335,7 @@ fn build_effect_map(
variant_var: var_store.fresh(),
ext_var: var_store.fresh(),
name: effect_tag_name.clone(),
arguments: vec![(var_store.fresh(), Located::at_zero(inner_closure))],
arguments: vec![(var_store.fresh(), Loc::at_zero(inner_closure))],
};
let function_var = var_store.fresh();
@ -348,7 +348,7 @@ fn build_effect_map(
captured_symbols: Vec::new(),
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Located::at_zero(body)),
loc_body: Box::new(Loc::at_zero(body)),
});
let mut introduced_variables = IntroducedVariables::default();
@ -411,8 +411,8 @@ fn build_effect_map(
let mut pattern_vars = SendMap::default();
pattern_vars.insert(map_symbol, function_var);
let def = Def {
loc_pattern: Located::at_zero(pattern),
loc_expr: Located::at_zero(map_closure),
loc_pattern: Loc::at_zero(pattern),
loc_expr: Loc::at_zero(map_closure),
expr_var: function_var,
pattern_vars,
annotation: Some(def_annotation),
@ -467,12 +467,12 @@ fn build_effect_after(
let force_thunk_call = {
let boxed = (
var_store.fresh(),
Located::at_zero(Expr::Var(thunk_symbol)),
Loc::at_zero(Expr::Var(thunk_symbol)),
var_store.fresh(),
var_store.fresh(),
);
let arguments = vec![(var_store.fresh(), Located::at_zero(Expr::EmptyRecord))];
let arguments = vec![(var_store.fresh(), Loc::at_zero(Expr::EmptyRecord))];
Expr::Call(Box::new(boxed), arguments, CalledVia::Space)
};
@ -480,31 +480,31 @@ fn build_effect_after(
let to_effect_call = {
let boxed = (
var_store.fresh(),
Located::at_zero(Expr::Var(to_effect_symbol)),
Loc::at_zero(Expr::Var(to_effect_symbol)),
var_store.fresh(),
var_store.fresh(),
);
let arguments = vec![(var_store.fresh(), Located::at_zero(force_thunk_call))];
let arguments = vec![(var_store.fresh(), Loc::at_zero(force_thunk_call))];
Expr::Call(Box::new(boxed), arguments, CalledVia::Space)
};
let arguments = vec![
(
var_store.fresh(),
Located::at_zero(Pattern::AppliedTag {
Loc::at_zero(Pattern::AppliedTag {
whole_var: var_store.fresh(),
ext_var: var_store.fresh(),
tag_name: effect_tag_name.clone(),
arguments: vec![(
var_store.fresh(),
Located::at_zero(Pattern::Identifier(thunk_symbol)),
Loc::at_zero(Pattern::Identifier(thunk_symbol)),
)],
}),
),
(
var_store.fresh(),
Located::at_zero(Pattern::Identifier(to_effect_symbol)),
Loc::at_zero(Pattern::Identifier(to_effect_symbol)),
),
];
@ -518,7 +518,7 @@ fn build_effect_after(
captured_symbols: Vec::new(),
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Located::at_zero(to_effect_call)),
loc_body: Box::new(Loc::at_zero(to_effect_call)),
});
let mut introduced_variables = IntroducedVariables::default();
@ -578,8 +578,8 @@ fn build_effect_after(
let mut pattern_vars = SendMap::default();
pattern_vars.insert(after_symbol, function_var);
let def = Def {
loc_pattern: Located::at_zero(pattern),
loc_expr: Located::at_zero(after_closure),
loc_pattern: Loc::at_zero(pattern),
loc_expr: Loc::at_zero(after_closure),
expr_var: function_var,
pattern_vars,
annotation: Some(def_annotation),
@ -602,7 +602,7 @@ pub fn build_host_exposed_def(
let mut pattern_vars = SendMap::default();
pattern_vars.insert(symbol, expr_var);
let mut arguments: Vec<(Variable, Located<Pattern>)> = Vec::new();
let mut arguments: Vec<(Variable, Loc<Pattern>)> = Vec::new();
let mut linked_symbol_arguments: Vec<(Variable, Expr)> = Vec::new();
let mut captured_symbols: Vec<(Symbol, Variable)> = Vec::new();
@ -626,7 +626,7 @@ pub fn build_host_exposed_def(
let arg_var = var_store.fresh();
arguments.push((arg_var, Located::at_zero(Pattern::Identifier(arg_symbol))));
arguments.push((arg_var, Loc::at_zero(Pattern::Identifier(arg_symbol))));
captured_symbols.push((arg_symbol, arg_var));
linked_symbol_arguments.push((arg_var, Expr::Var(arg_symbol)));
@ -663,16 +663,16 @@ pub fn build_host_exposed_def(
recursive: Recursive::NotRecursive,
arguments: vec![(
var_store.fresh(),
Located::at_zero(empty_record_pattern(var_store)),
Loc::at_zero(empty_record_pattern(var_store)),
)],
loc_body: Box::new(Located::at_zero(low_level_call)),
loc_body: Box::new(Loc::at_zero(low_level_call)),
});
let body = Expr::Tag {
variant_var: var_store.fresh(),
ext_var: var_store.fresh(),
name: effect_tag_name,
arguments: vec![(var_store.fresh(), Located::at_zero(effect_closure))],
arguments: vec![(var_store.fresh(), Loc::at_zero(effect_closure))],
};
Expr::Closure(ClosureData {
@ -684,7 +684,7 @@ pub fn build_host_exposed_def(
captured_symbols: std::vec::Vec::new(),
recursive: Recursive::NotRecursive,
arguments,
loc_body: Box::new(Located::at_zero(body)),
loc_body: Box::new(Loc::at_zero(body)),
})
}
_ => {
@ -725,15 +725,15 @@ pub fn build_host_exposed_def(
name: effect_closure_symbol,
captured_symbols,
recursive: Recursive::NotRecursive,
arguments: vec![(var_store.fresh(), Located::at_zero(empty_record_pattern))],
loc_body: Box::new(Located::at_zero(low_level_call)),
arguments: vec![(var_store.fresh(), Loc::at_zero(empty_record_pattern))],
loc_body: Box::new(Loc::at_zero(low_level_call)),
});
Expr::Tag {
variant_var: var_store.fresh(),
ext_var: var_store.fresh(),
name: effect_tag_name,
arguments: vec![(var_store.fresh(), Located::at_zero(effect_closure))],
arguments: vec![(var_store.fresh(), Loc::at_zero(effect_closure))],
}
}
}
@ -747,8 +747,8 @@ pub fn build_host_exposed_def(
};
Def {
loc_pattern: Located::at_zero(pattern),
loc_expr: Located::at_zero(def_body),
loc_pattern: Loc::at_zero(pattern),
loc_expr: Loc::at_zero(def_body),
expr_var,
pattern_vars,
annotation: Some(def_annotation),

View file

@ -29,7 +29,7 @@ use roc_parse::header::{
};
use roc_parse::module::module_defs;
use roc_parse::parser::{ParseProblem, Parser, SyntaxError};
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_solve::module::SolvedModule;
use roc_solve::solve;
use roc_types::solved_types::Solved;
@ -777,7 +777,7 @@ struct ParsedModule<'a> {
imported_modules: MutMap<ModuleId, Region>,
exposed_ident_ids: IdentIds,
exposed_imports: MutMap<Ident, (Symbol, Region)>,
parsed_defs: &'a [Located<roc_parse::ast::Def<'a>>],
parsed_defs: &'a [Loc<roc_parse::ast::Def<'a>>],
}
/// A message sent out _from_ a worker thread,
@ -2544,7 +2544,7 @@ fn parse_header<'a>(
};
let info = HeaderInfo {
loc_name: Located {
loc_name: Loc {
region: header.name.region,
value: ModuleNameEnum::Interface(header.name.value),
},
@ -2578,7 +2578,7 @@ fn parse_header<'a>(
let packages = unspace(arena, header.packages.items);
let info = HeaderInfo {
loc_name: Located {
loc_name: Loc {
region: header.name.region,
value: ModuleNameEnum::App(header.name.value),
},
@ -2603,7 +2603,7 @@ fn parse_header<'a>(
match header.to.value {
To::ExistingPackage(existing_package) => {
let opt_base_package = packages.iter().find_map(|loc_package_entry| {
let Located { value, .. } = loc_package_entry;
let Loc { value, .. } = loc_package_entry;
if value.shorthand == existing_package {
Some(value)
@ -2615,7 +2615,7 @@ fn parse_header<'a>(
if let Some(PackageEntry {
shorthand,
package_or_path:
Located {
Loc {
value: package_or_path,
..
},
@ -2753,14 +2753,14 @@ enum ModuleNameEnum<'a> {
#[derive(Debug)]
struct HeaderInfo<'a> {
loc_name: Located<ModuleNameEnum<'a>>,
loc_name: Loc<ModuleNameEnum<'a>>,
filename: PathBuf,
is_root_module: bool,
opt_shorthand: Option<&'a str>,
header_src: &'a str,
packages: &'a [Located<PackageEntry<'a>>],
exposes: &'a [Located<ExposedName<'a>>],
imports: &'a [Located<ImportsEntry<'a>>],
packages: &'a [Loc<PackageEntry<'a>>],
exposes: &'a [Loc<ExposedName<'a>>],
imports: &'a [Loc<ImportsEntry<'a>>],
to_platform: Option<To<'a>>,
}
@ -2970,10 +2970,10 @@ struct PlatformHeaderInfo<'a> {
shorthand: &'a str,
header_src: &'a str,
app_module_id: ModuleId,
packages: &'a [Located<PackageEntry<'a>>],
provides: &'a [Located<ExposedName<'a>>],
requires: &'a [Located<TypedIdent<'a>>],
imports: &'a [Located<ImportsEntry<'a>>],
packages: &'a [Loc<PackageEntry<'a>>],
provides: &'a [Loc<ExposedName<'a>>],
requires: &'a [Loc<TypedIdent<'a>>],
imports: &'a [Loc<ImportsEntry<'a>>],
}
// TODO refactor so more logic is shared with `send_header`
@ -3311,11 +3311,11 @@ fn run_solve<'a>(
}
}
fn unspace<'a, T: Copy>(arena: &'a Bump, items: &[Located<Spaced<'a, T>>]) -> &'a [Located<T>] {
fn unspace<'a, T: Copy>(arena: &'a Bump, items: &[Loc<Spaced<'a, T>>]) -> &'a [Loc<T>] {
bumpalo::collections::Vec::from_iter_in(
items
.iter()
.map(|item| Located::at(item.region, item.value.extract_spaces().item)),
.map(|item| Loc::at(item.region, item.value.extract_spaces().item)),
arena,
)
.into_bump_slice()
@ -3342,7 +3342,7 @@ fn fabricate_pkg_config_module<'a>(
app_module_id,
packages: &[],
provides: unspace(arena, header.provides.items),
requires: &*arena.alloc([Located::at(
requires: &*arena.alloc([Loc::at(
header.requires.signature.region,
header.requires.signature.extract_spaces().item,
)]),
@ -3492,7 +3492,7 @@ fn fabricate_effects_module<'a>(
scope.add_alias(
effect_symbol,
Region::zero(),
vec![Located::at_zero(("a".into(), a_var))],
vec![Loc::at_zero(("a".into(), a_var))],
actual,
);
@ -3612,8 +3612,8 @@ fn fabricate_effects_module<'a>(
fn unpack_exposes_entries<'a>(
arena: &'a Bump,
entries: &'a [Located<Spaced<'a, TypedIdent<'a>>>],
) -> bumpalo::collections::Vec<'a, (Located<&'a str>, Located<TypeAnnotation<'a>>)> {
entries: &'a [Loc<Spaced<'a, TypedIdent<'a>>>],
) -> bumpalo::collections::Vec<'a, (Loc<&'a str>, Loc<TypeAnnotation<'a>>)> {
use bumpalo::collections::Vec;
let iter = entries.iter().map(|entry| {