Zulip Chat Archive

Stream: general

Topic: What's causing failure to synthesize here?


nrs (Sep 01 2024 at 23:23):

inductive myTerms where
  | var : String -> myTerms
  | other : myTerms

prefix: max "**" => myTerms.var

def myCheck : myTerms -> Type
  | **_ => myTerms
  | _ => Empty

def testFunc (t: myTerms) {_ : myCheck t} : String :=
  match t with
  | **s => s

#eval testFunc **"m"

Seems to me there's only a single possible way to resolve the type, but I'm a bit lost. Basically, I want to make a function that enforces at the type-level that t be pattern-matchable with **s. Anyone got tips/suggestions/readings?

Bjørn Kjos-Hanssen (Sep 08 2024 at 05:52):

We can see explicitly that there's more than way like this:

#eval @testFunc **"m" myTerms.other
#eval @testFunc **"m" <| myTerms.var "hello"

Maybe add the assumption [Nonempty (myCheck t)] instead.

nrs (Sep 09 2024 at 04:03):

Bjørn Kjos-Hanssen ☀️ said:

We can see explicitly that there's more than way like this:

#eval @testFunc **"m" myTerms.other
#eval @testFunc **"m" <| myTerms.var "hello"

Maybe add the assumption [Nonempty (myCheck t)] instead.

ah I see! thanks a lot for the example!


Last updated: May 02 2025 at 03:31 UTC