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

Instantiation of inference variables might be too eager #244

Open
ice1000 opened this issue Jul 23, 2020 · 0 comments
Open

Instantiation of inference variables might be too eager #244

ice1000 opened this issue Jul 23, 2020 · 0 comments
Assignees
Labels

Comments

@ice1000
Copy link
Contributor

ice1000 commented Jul 23, 2020

Given this code:

\data Maybe (A : \Type) | just A | nothing
\func NatInf' => Maybe Nat
\func zero' => just zero

\func suc' (n : NatInf') : NatInf'
  | just a => just (suc a)
  | nothing => nothing

\func infinity' => nothing

  \data NatInf
    | nzero
    | infinity
    | nsucc NatInf
    | ntrunc I \with {
      | left => infinity
      | right => nsucc infinity
    }

  \func to (n : NatInf) : NatInf'
    | nzero => zero'
    | infinity => infinity'
    | nsucc n => suc' (to n)
    | ntrunc i => infinity'

Arend rejects this code with this little poem:

[ERROR] NatWithInfinity.ard:39:19: Cannot infer parameter 'A'
  Candidates are: Nat
  Since types of the candidates are not less than or equal to the expected type
  Expected type: \Prop
    Actual type: \Set0

It's worked around by manually giving infinity' a return type annotation NatInf'. I guess we should not need to do so in general. Maybe Arend inferred the type of infinity' as something weird, but I'd expect it to be {A : \Type} -> Maybe A.

@valis valis self-assigned this Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants