oak_valkyrie/ast/
types_nodes.rs1use super::{Expr, Identifier, NamePath, Span};
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum Type {
7 Named {
9 path: NamePath,
11 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
13 span: Span,
14 },
15 Generic {
17 name: Identifier,
19 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
21 span: Span,
22 },
23 Tuple {
25 elements: Vec<Type>,
27 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
29 span: Span,
30 },
31 Function {
33 params: Vec<Type>,
35 return_type: Box<Type>,
37 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
39 span: Span,
40 },
41 Optional {
43 inner: Box<Type>,
45 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
47 span: Span,
48 },
49 AssociatedType {
51 base: Identifier,
53 name: Identifier,
55 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
57 span: Span,
58 },
59 QualifiedAssociatedType {
61 ty: Box<Type>,
63 trait_path: NamePath,
65 name: Identifier,
67 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
69 span: Span,
70 },
71}
72
73#[derive(Debug, Clone, PartialEq, Eq, Hash)]
75#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
76pub struct GenericParam {
77 pub name: Identifier,
79 pub constraints: Vec<Type>,
81 pub default: Option<Type>,
83 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
85 pub span: Span,
86}
87
88#[derive(Debug, Clone, PartialEq, Eq, Hash)]
90#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
91pub struct Param {
92 pub name: Identifier,
94 pub ty: Option<Type>,
96 pub default: Option<Expr>,
98 #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
100 pub span: Span,
101}