Format effectful arrows in annotations

This commit is contained in:
Agus Zubiaga 2024-09-17 20:44:44 -03:00
parent ef4eeb5c1a
commit d692fc7c42
No known key found for this signature in database
2 changed files with 9 additions and 6 deletions

View file

@ -4,8 +4,8 @@ use crate::{
Buf, Buf,
}; };
use roc_parse::ast::{ use roc_parse::ast::{
AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, ImplementsAbilities, AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, FunctionArrow,
ImplementsAbility, ImplementsClause, Tag, TypeAnnotation, TypeHeader, ImplementsAbilities, ImplementsAbility, ImplementsClause, Tag, TypeAnnotation, TypeHeader,
}; };
use roc_parse::ident::UppercaseIdent; use roc_parse::ident::UppercaseIdent;
use roc_region::all::Loc; use roc_region::all::Loc;
@ -195,8 +195,7 @@ impl<'a> Formattable for TypeAnnotation<'a> {
let self_is_multiline = self.is_multiline(); let self_is_multiline = self.is_multiline();
match self { match self {
Function(args, _arrow, ret) => { Function(args, arrow, ret) => {
// [purity-infrence] TODO: format arrow
let needs_parens = parens != Parens::NotNeeded; let needs_parens = parens != Parens::NotNeeded;
buf.indent(indent); buf.indent(indent);
@ -237,7 +236,11 @@ impl<'a> Formattable for TypeAnnotation<'a> {
buf.spaces(1); buf.spaces(1);
} }
buf.push_str("->"); match arrow {
FunctionArrow::Pure => buf.push_str("->"),
FunctionArrow::Effectful => buf.push_str("=>"),
}
buf.spaces(1); buf.spaces(1);
ret.value ret.value

View file

@ -1,4 +1,4 @@
launchTheNukes : {} -> Result Bool LaunchNukeErr launchTheNukes : {} => Result Bool LaunchNukeErr
launchTheNukes = \{} -> launchTheNukes = \{} ->
crash "todo" crash "todo"