use crate::{ident::Ident, span::Span};
use super::{attribute::Annotation, expr::Expr, ty::Type};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Pattern {
TypePattern(TypePattern),
RecordPattern(RecordPattern),
}
impl Pattern {
pub fn span(&self) -> Span {
match self {
Self::TypePattern(p) => p.span,
Self::RecordPattern(p) => p.span,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypePattern {
pub annotations: Vec<Annotation>,
pub ty: Type,
pub name: Option<Ident>,
pub span: Span,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RecordPattern {
pub record_type: Type,
pub components: Vec<Pattern>,
pub span: Span,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Guard {
pub when_span: Span,
pub expr: Expr,
}