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

Improve coercion matching #2982

Closed
janmasrovira opened this issue Aug 30, 2024 · 1 comment
Closed

Improve coercion matching #2982

janmasrovira opened this issue Aug 30, 2024 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@janmasrovira
Copy link
Collaborator

janmasrovira commented Aug 30, 2024

In the following example we get an error at the last return because we are unable to find a monad instance for M. We should detect Monad M because we have {{MonadS S M}} in scope and MonadS has an instance field {{monad}} : Monad M, thus we have the coercion coercion instance monad : {S : Type} → {M : Type → Type} → {{MonadS S M}} → Monad M.

The problem seems to be that MonadS has the extra (S : Type) argument and the coercion detection algorithm is not able to detect that.

module example;

trait
type Monad (f : Type -> Type) := mkMonad {return : {A : Type} -> A -> f A};

open Monad public;

trait
type MonadS (S : Type) (M : Type -> Type) :=
  mkMonadReader {
    {{monad}} : Monad M;
    getS : S
  };

projMonad {B S} {M : Type -> Type} {{MonadS S M}} : {A : Type} -> A -> M A := return;
@janmasrovira janmasrovira added enhancement New feature or request pending-review labels Aug 30, 2024
@lukaszcz lukaszcz added this to the 0.6.10 milestone Nov 15, 2024
@paulcadman paulcadman modified the milestones: 0.6.10, 0.6.11 Dec 2, 2024
@paulcadman
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants