add missing Makefile
[coinductive-monad.git] / Computation / Eval.v
1 Require Export Computation.Monad.
2 Require Export Computation.Termination.
3
4 (* evaluate up to [n] computation steps *)
5 Fixpoint bounded_eval (A:Set) (n:nat) (c:#A) {struct n} : option A :=
6   match n with
7     | O      => None
8     | (S n') =>
9       match c with
10         | Return b   => Some b
11         | Bind _ f c' =>
12           match (bounded_eval _ n' c') with
13             | None   => None
14             | Some a => bounded_eval A n' (f a)
15           end
16       end
17   end.
18
19 Inductive Unit : Set := unit : Unit.
20 Definition eval (A:Set) (c:#A) (t:Terminates c) : A :=
21   match eval' c Unit (Return unit) (termination_is_safe A c t) with
22     | exist x pf => x
23   end.
24
25 Implicit Arguments eval [A].
26 Implicit Arguments bounded_eval [A].