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
use crate::func::*;

pub type CountedInstance = instances::effect::EffectInstance<usize>;

impl instances::effect::Effect for usize {
    fn e_pure() -> Self {
        0
    }

    fn e_parallel(el: Self, er: Self) -> Self {
        std::cmp::max(el, er)
    }

    fn e_after(self, effect: Self) -> Self {
        self + effect
    }
}

pub type Counted<A> = instances::effect::WithEffect<A, usize>;

impl<A> Counted<A> {
    pub fn after_resolution(self) -> Self {
        Counted {
            value: self.value,
            effect: self.effect + 1,
        }
    }

    pub fn count(&self) -> usize {
        self.effect
    }
}