| 1 |
Section FreeMonad. |
| 2 |
|
| 3 |
Variable S : Type. |
| 4 |
Variable P : S -> Type. |
| 5 |
|
| 6 |
Inductive FreeF A : Type := |
| 7 |
| retFree : A -> FreeF A |
| 8 |
| opr : forall s, (P s -> FreeF A) -> FreeF A. |
| 9 |
|
| 10 |
End FreeMonad. |
| 11 |
|
| 12 |
Section Fibonnacci. |
| 13 |
|
| 14 |
Inductive gen_op := call_op : nat -> gen_op. |
| 15 |
Definition gen_ty (op : gen_op) := |
| 16 |
match op with |
| 17 |
| call_op _ => nat |
| 18 |
end. |
| 19 |
|
| 20 |
Fail Definition fib0 (n:nat) : FreeF gen_op gen_ty nat := |
| 21 |
match n with |
| 22 |
| 0 |
| 23 |
| 1 => retFree _ _ _ 1 |
| 24 |
| S (S k) => |
| 25 |
opr _ _ _ (call_op (S k)) |
| 26 |
(fun r1 => opr _ _ _ (call_op k) |
| 27 |
(fun r0 => retFree (* _ _ _ *) (r1 + r0))) |
| 28 |
end. |
| 29 |
|
| 30 |
End Fibonnacci. |