catlog/dbl/
model_diagram.rs

1//! Diagrams in models of a double theory.
2//!
3//! A **diagram** in a [model](super::model) is simply a
4//! [morphism](super::model_morphism) into that model. This includes the domain of
5//! that morphism, which is assumed to be a free model.
6//!
7//! Diagrams are currently used primarily to represent instances of models from a
8//! fibered perspective, generalizing how a diagram in a category can be used to
9//! represent a copresheaf over that category.
10
11use derive_more::Into;
12
13#[cfg(feature = "serde")]
14use serde::{Deserialize, Serialize};
15#[cfg(feature = "serde-wasm")]
16use tsify::Tsify;
17
18pub use super::discrete::model_diagram::*;
19
20/// A diagram in a model of a double theory.
21///
22/// This struct owns its data, namely, the domain of the diagram (a model) and the
23/// model mapping itself.
24#[derive(Clone, Into)]
25#[into(owned, ref, ref_mut)]
26pub struct DblModelDiagram<Map, Dom>(pub Map, pub Dom);
27
28/// A failure of a diagram in a model to be valid.
29#[derive(Clone, Debug, PartialEq, Eq)]
30#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31#[cfg_attr(feature = "serde", serde(tag = "tag", content = "err"))]
32#[cfg_attr(feature = "serde-wasm", derive(Tsify))]
33#[cfg_attr(feature = "serde-wasm", tsify(into_wasm_abi, from_wasm_abi))]
34pub enum InvalidDblModelDiagram<DomErr, MapErr> {
35    /// Domain of the diagram is invalid.
36    Dom(DomErr),
37
38    /// Mapping underlying the diagram is invalid.
39    Map(MapErr),
40}