Skip to content

Commit

Permalink
Format effectful arrows in annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
agu-z committed Oct 15, 2024
1 parent 394a01f commit 2322960
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions crates/compiler/fmt/src/annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
Buf,
};
use roc_parse::ast::{
AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, ImplementsAbilities,
ImplementsAbility, ImplementsClause, Tag, TypeAnnotation, TypeHeader,
AbilityImpls, AssignedField, Collection, Expr, ExtractSpaces, FunctionArrow,
ImplementsAbilities, ImplementsAbility, ImplementsClause, Tag, TypeAnnotation, TypeHeader,
};
use roc_parse::ident::UppercaseIdent;
use roc_region::all::Loc;
Expand Down Expand Up @@ -195,8 +195,7 @@ impl<'a> Formattable for TypeAnnotation<'a> {
let self_is_multiline = self.is_multiline();

match self {
Function(args, _arrow, ret) => {
// [purity-infrence] TODO: format arrow
Function(args, arrow, ret) => {
let needs_parens = parens != Parens::NotNeeded;

buf.indent(indent);
Expand Down Expand Up @@ -237,7 +236,11 @@ impl<'a> Formattable for TypeAnnotation<'a> {
buf.spaces(1);
}

buf.push_str("->");
match arrow {
FunctionArrow::Pure => buf.push_str("->"),
FunctionArrow::Effectful => buf.push_str("=>"),
}

buf.spaces(1);

ret.value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
launchTheNukes : {} -> Result Bool LaunchNukeErr
launchTheNukes : {} => Result Bool LaunchNukeErr
launchTheNukes = \{} ->
crash "todo"

Expand Down

0 comments on commit 2322960

Please sign in to comment.