Skip to content

Commit

Permalink
Use try_collect_many in more spots.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivorforce committed Apr 26, 2024
1 parent f08d03b commit 44a5ea1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/parser/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut};

use itertools::Itertools;

use crate::error::{RResult, RuntimeError};
use crate::error::{RResult, RuntimeError, TryCollectMany};
use crate::program::allocation::Mutability;
use crate::program::functions::ParameterKey;
use crate::util::fmt::write_separated_display;
Expand Down Expand Up @@ -371,7 +371,7 @@ impl<V> Decorated<V> {
}

Ok(&d.value.value)
}).try_collect()
}).try_collect_many()
}

pub fn no_decorations(&self) -> RResult<()> {
Expand Down
6 changes: 3 additions & 3 deletions src/program/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::rc::Rc;
use itertools::{Itertools, zip_eq};
use uuid::Uuid;

use crate::error::{RResult, RuntimeError};
use crate::error::{RResult, RuntimeError, TryCollectMany};
use crate::program::traits::Trait;
use crate::program::types::{TypeProto, TypeUnit};

Expand Down Expand Up @@ -59,7 +59,7 @@ impl TypeForest {
TypeUnit::Generic(alias) => self.resolve_binding_alias(alias).map(|x| x.clone()),
_ => Ok(Rc::new(TypeProto {
unit: type_.unit.clone(),
arguments: type_.arguments.iter().map(|x| self.resolve_type(x)).try_collect()?
arguments: type_.arguments.iter().map(|x| self.resolve_type(x)).try_collect_many()?
}))
}
}
Expand All @@ -77,7 +77,7 @@ impl TypeForest {
unit: binding.clone(),
arguments: self.identity_to_arguments.get(&identity).unwrap().iter()
.map(|x| self.resolve_binding_alias(x))
.try_collect()?
.try_collect_many()?
}))
}

Expand Down
4 changes: 2 additions & 2 deletions src/resolver/decorations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::rc::Rc;
use itertools::Itertools;
use uuid::Uuid;

use crate::error::{RResult, RuntimeError};
use crate::error::{RResult, RuntimeError, TryCollectMany};
use crate::resolver::grammar::{Pattern, PatternPart};
use crate::resolver::scopes;
use crate::parser::ast;
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn try_parse_pattern(decoration: &ast::Expression, function: Rc<FunctionHead
_ => Err(RuntimeError::error("Bad pattern.").to_array()),
}
})
.try_collect()?;
.try_collect_many()?;

Ok(Rc::new(Pattern {
id: Uuid::new_v4(),
Expand Down
8 changes: 4 additions & 4 deletions src/resolver/imperative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::rc::Rc;
use itertools::Itertools;
use uuid::Uuid;

use crate::error::{ErrInRange, RResult, RuntimeError};
use crate::error::{ErrInRange, RResult, RuntimeError, TryCollectMany};
use crate::interpreter::runtime::Runtime;
use crate::resolver::ambiguous::{AmbiguityResult, AmbiguousAbstractCall, AmbiguousFunctionCall, AmbiguousFunctionCandidate, ResolverAmbiguity};
use crate::resolver::grammar::parse::{resolve_expression_to_tokens, resolve_tokens_to_value};
Expand Down Expand Up @@ -186,7 +186,7 @@ impl <'a> ImperativeResolver<'a> {
let statements: Vec<ExpressionID> = body.statements.iter().map(|pstatement| {
self.resolve_statement(&mut scope, pstatement)
.err_in_range(&pstatement.value.position)
}).try_collect()?;
}).try_collect_many()?;

let expression_id = self.register_new_expression(statements);
self.expression_tree.values.insert(expression_id, ExpressionOperation::Block);
Expand Down Expand Up @@ -355,7 +355,7 @@ impl <'a> ImperativeResolver<'a> {
_ => {
let mut parts: Vec<_> = parts.iter()
.map(|part| self.resolve_string_part(part, scope))
.try_collect()?;
.try_collect_many()?;

// TODO We should call concat() with an array instead.
let last = parts.pop().unwrap();
Expand All @@ -377,7 +377,7 @@ impl <'a> ImperativeResolver<'a> {
let values = struct_.arguments.iter().map(|x| {
self.resolve_expression_with_type(&x.value.value, &x.value.type_declaration, scope)
.err_in_range(&x.position)
}).try_collect()?;
}).try_collect_many()?;

Ok(Struct {
keys: struct_.arguments.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/resolver/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::rc::Rc;
use itertools::Itertools;
use try_map::FallibleMapExt;

use crate::error::{RResult, RuntimeError};
use crate::error::{RResult, RuntimeError, TryCollectMany};
use crate::interpreter::runtime::Runtime;
use crate::resolver::scopes;
use crate::resolver::type_factory::TypeFactory;
Expand Down Expand Up @@ -124,7 +124,7 @@ pub fn _resolve_function_interface<'a>(representation: FunctionRepresentation, p

let parameters = parameters
.map(|p| resolve_function_parameter(p, &mut type_factory))
.try_collect()?;
.try_collect_many()?;

let mut generics = generics.clone();
generics.extend(type_factory.generics);
Expand Down
4 changes: 2 additions & 2 deletions src/transpiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::rc::Rc;

use itertools::Itertools;

use crate::error::RResult;
use crate::error::{RResult, TryCollectMany};
use crate::interpreter::runtime::Runtime;
use crate::program::function_object::FunctionRepresentation;
use crate::program::functions::FunctionHead;
Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn transpile(transpiler: Box<Transpiler>, runtime: &mut Runtime, context: &d

let exported_functions = refactor.explicit_functions.iter()
.map(|head| fn_logic.get(head).unwrap().as_implementation())
.try_collect()?;
.try_collect_many()?;
let mut implicit_functions = vec![];
let mut native_functions = HashMap::new();

Expand Down

0 comments on commit 44a5ea1

Please sign in to comment.