Pull out alias header as its own struct

This commit is contained in:
ayazhafiz 2021-12-26 09:03:05 -06:00
parent dae94f4aaa
commit 11da888c07
5 changed files with 53 additions and 28 deletions

View file

@ -3,7 +3,7 @@ use crate::{
spaces::{fmt_comments_only, fmt_spaces, NewlineAt, INDENT},
Buf,
};
use roc_parse::ast::{AssignedField, Expr, Tag, TypeAnnotation};
use roc_parse::ast::{AliasHeader, AssignedField, Expr, Tag, TypeAnnotation};
use roc_region::all::Loc;
/// Does an AST node need parens around it?
@ -245,16 +245,16 @@ impl<'a> Formattable for TypeAnnotation<'a> {
}
}
As(lhs, _spaces, (name, args)) => {
As(lhs, _spaces, AliasHeader { name, vars }) => {
// TODO use spaces?
lhs.value.format(buf, indent);
buf.spaces(1);
buf.push_str("as");
buf.spaces(1);
buf.push_str(name);
for arg in *args {
for var in *vars {
buf.spaces(1);
buf.push_str(arg.value);
buf.push_str(var.value);
}
}