use super::*;
mod display;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum MatchKind {
Typing,
Effect,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MatchStatement {
pub kind: MatchKind,
pub bind: Option<IdentifierNode>,
pub main: ExpressionKind,
pub patterns: PatternsList,
pub span: Range<u32>,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MatchCallNode {
pub monadic: bool,
pub base: ExpressionKind,
pub kind: MatchKind,
pub patterns: PatternsList,
pub span: Range<u32>,
}
impl MatchKind {
pub fn as_str(&self) -> &'static str {
match self {
MatchKind::Typing => "match",
MatchKind::Effect => "catch",
}
}
}
impl MatchCallNode {
pub fn with_base(self, base: ExpressionKind) -> Self {
Self { base, ..self }
}
}