Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize tmBind #916

Draft
wants to merge 1 commit into
base: coq-8.16
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions template-coq/theories/TemplateMonad/Core.v
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ Definition TemplateMonad_UnoptimizedMonad@{t u} : Monad@{t u} TemplateMonad@{t u
Definition TemplateMonad_OptimizedMonad@{t u} : Monad@{t u} TemplateMonad@{t u} :=
{| ret := @tmReturn ; bind := @tmOptimizedBind |}.

(* We don't want to make the optimized monad an instance, because it blows up performance in some cases *)
Definition TemplateMonad_Monad@{t u} : Monad@{t u} TemplateMonad@{t u} :=
Eval hnf in TemplateMonad_UnoptimizedMonad.
Eval hnf in TemplateMonad_OptimizedMonad.
Global Existing Instance TemplateMonad_Monad.

Polymorphic Definition tmDefinitionRed
Expand Down Expand Up @@ -202,7 +201,7 @@ Definition TypeInstanceOptimized : Common.TMInstance :=
|}.

Definition TypeInstance : Common.TMInstance :=
Eval hnf in TypeInstanceUnoptimized.
Eval hnf in TypeInstanceOptimized.

Definition tmQuoteUniverse@{U t u} : TemplateMonad@{t u} Universe.t
:= u <- @tmQuote Prop (Type@{U} -> True);;
Expand Down
2 changes: 0 additions & 2 deletions test-suite/bug441.v
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
From MetaCoq Require Import Template.All.
Import MCMonadNotation.

#[local] Existing Instance TemplateMonad_OptimizedMonad.

Fixpoint tm_double n : TemplateMonad nat :=
match n with
| 0 => ret 0
Expand Down