mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Parse effectful arrow in function annotations
This commit is contained in:
parent
1a5776653c
commit
ef4eeb5c1a
30 changed files with 178 additions and 19 deletions
|
@ -1530,10 +1530,22 @@ impl ImplementsAbilities<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum FunctionArrow {
|
||||
/// ->
|
||||
Pure,
|
||||
/// =>
|
||||
Effectful,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum TypeAnnotation<'a> {
|
||||
/// A function. The types of its arguments, then the type of its return value.
|
||||
Function(&'a [Loc<TypeAnnotation<'a>>], &'a Loc<TypeAnnotation<'a>>),
|
||||
/// A function. The types of its arguments, the type of arrow used, then the type of its return value.
|
||||
Function(
|
||||
&'a [Loc<TypeAnnotation<'a>>],
|
||||
FunctionArrow,
|
||||
&'a Loc<TypeAnnotation<'a>>,
|
||||
),
|
||||
|
||||
/// Applying a type to some arguments (e.g. Map.Map String Int)
|
||||
Apply(&'a str, &'a str, &'a [Loc<TypeAnnotation<'a>>]),
|
||||
|
@ -2755,7 +2767,7 @@ impl<'a> Malformed for ModuleImportParams<'a> {
|
|||
impl<'a> Malformed for TypeAnnotation<'a> {
|
||||
fn is_malformed(&self) -> bool {
|
||||
match self {
|
||||
TypeAnnotation::Function(args, ret) => {
|
||||
TypeAnnotation::Function(args, _arrow, ret) => {
|
||||
args.iter().any(|arg| arg.is_malformed()) || ret.is_malformed()
|
||||
}
|
||||
TypeAnnotation::Apply(_, _, args) => args.iter().any(|arg| arg.is_malformed()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue