mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
WIP
This commit is contained in:
parent
743030fc99
commit
8a566dc339
260 changed files with 6344 additions and 2958 deletions
|
@ -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;
|
||||
|
@ -149,7 +149,7 @@ impl<'a> Formattable for TypeAnnotation<'a> {
|
|||
}
|
||||
|
||||
Wildcard | Inferred | BoundVariable(_) | Malformed(_) => false,
|
||||
Function(args, result) => {
|
||||
Function(args, _arrow, result) => {
|
||||
result.value.is_multiline()
|
||||
|| args.iter().any(|loc_arg| loc_arg.value.is_multiline())
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ impl<'a> Formattable for TypeAnnotation<'a> {
|
|||
let self_is_multiline = self.is_multiline();
|
||||
|
||||
match self {
|
||||
Function(args, ret) => {
|
||||
Function(args, arrow, ret) => {
|
||||
let needs_parens = parens != Parens::NotNeeded;
|
||||
|
||||
buf.indent(indent);
|
||||
|
@ -236,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
|
||||
|
|
|
@ -4,6 +4,7 @@ use crate::expr::fmt_str_literal;
|
|||
use crate::pattern::fmt_pattern;
|
||||
use crate::spaces::{fmt_default_newline, fmt_default_spaces, fmt_spaces, INDENT};
|
||||
use crate::Buf;
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_parse::ast::{
|
||||
AbilityMember, Defs, Expr, ExtractSpaces, ImportAlias, ImportAsKeyword, ImportExposingKeyword,
|
||||
ImportedModuleName, IngestedFileAnnotation, IngestedFileImport, ModuleImport,
|
||||
|
@ -423,6 +424,7 @@ impl<'a> Formattable for ValueDef<'a> {
|
|||
ModuleImport(module_import) => module_import.is_multiline(),
|
||||
IngestedFileImport(ingested_file_import) => ingested_file_import.is_multiline(),
|
||||
Stmt(loc_expr) => loc_expr.is_multiline(),
|
||||
StmtAfterExpr => internal_error!("shouldn't exist before can"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,6 +466,7 @@ impl<'a> Formattable for ValueDef<'a> {
|
|||
ModuleImport(module_import) => module_import.format(buf, indent),
|
||||
IngestedFileImport(ingested_file_import) => ingested_file_import.format(buf, indent),
|
||||
Stmt(loc_expr) => loc_expr.format_with_options(buf, parens, newlines, indent),
|
||||
StmtAfterExpr => internal_error!("shouldn't exist before can"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue