1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46


use crate::{
    primitives::Constant,
    boolean::{True, False},
    define
};

define! {
    /// Pair of two values.
    /// ```text
    /// λx.λy.λf.fxy
    /// ```
    pub fn Pair ::= { X. Y. F. { F, X, Y }} where
        F: X,
        {F, X}: Y;
    /// Gets the first element of a pair.
    /// ```text
    /// T ::= True
    /// λp.pT
    /// ```
    pub fn First ::= { P. { P, True }} where P: True;
    /// Gets the second element of a pair.
    /// ```text
    /// F ::= False
    /// λp.pF
    /// ```
    pub fn Second ::= { P. { P, False }} where P: False;
    /// Tests whether a value is [`Nil`].
    /// ```text
    /// F ::= False
    /// λp.p(λx.λy.F)
    /// ```
    pub fn Null ::= { P. { P, Constant<Constant<False>> }} where P: (Constant<Constant<False>>);
}

/// An empty singly linked list.
pub type Nil = Constant<True>;

#[test]
fn t() {
    use crate::prelude::*;

    let _: call!{ Null, Nil } = True::default();
    let _: call!{ Null, {Pair, (), Nil} } = False::default();
}