Skip to content

Commit

Permalink
Optimize tmBind
Browse files Browse the repository at this point in the history
Fixes #441
  • Loading branch information
JasonGross committed Apr 12, 2023
1 parent f0d3dda commit 8a7c37f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
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

0 comments on commit 8a7c37f

Please sign in to comment.