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

Builders for mixins should be an error #495

Open
CohenCyril opened this issue Dec 19, 2024 · 1 comment
Open

Builders for mixins should be an error #495

CohenCyril opened this issue Dec 19, 2024 · 1 comment
Labels
easy difficulty Very easy low priority Low priority

Comments

@CohenCyril
Copy link
Member

CohenCyril commented Dec 19, 2024

Or at least a warning...
See example from @MathisBD posted on zulip

From HB Require Import structures.

HB.mixin Record IsFunctor (F : Type -> Type) := {
  fmap : forall A B, (A -> B) -> F A -> F B
}.

HB.mixin Record IsMonad (M : Type -> Type) := {
  ret : forall A, A -> M A ;
  bind : forall A B, M A -> (A -> M B) -> M B
}.

HB.structure Definition Functor := { F of IsFunctor F }.
HB.structure Definition Monad := { M of IsMonad M }.

HB.builders Context M of IsMonad M.
  Let fmap A B (f : A -> B) (x : M A) := bind _ _ x (fun x => ret _ (f x)).
  HB.instance Definition _ := IsFunctor.Build M fmap.
HB.end.
@CohenCyril
Copy link
Member Author

As of today this results in the following behaviour:

HB.instance Definition _ := IsMonad.Build option
  (@Some) (fun A B x f => match x with Some a => f a | None => None end).

Check option : Functor.type. (* succeeds *)

@CohenCyril CohenCyril added easy difficulty Very easy low priority Low priority labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy difficulty Very easy low priority Low priority
Projects
None yet
Development

No branches or pull requests

1 participant