agda / agda2hs

Compiling Agda code to readable Haskell

Home Page:https://agda.github.io/agda2hs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make return type of `case_of_` and `if_then_else_` dependent

flupe opened this issue · comments

Change

case_of_ : (x : a)  ((y : a)  @0 {{ x ≡ y }}  b)  b

to

case_of_ : {b : @0 a  Set} (x : a)  ((y : a)  @0 {{ x ≡ y }}  b y)  b x

Possibly even erase b, and a, possibly even make b depend on the erased equality between x and y.

Related to: #105

I'm sorry to say, but this is a terrible idea. It will make inference of b fail basically always when x is not a variable. It is also not really necessary: with the current version you can already do basically anything you want by using the equality proof: the dependent version would not give you any additional information beyond the fact that x is equal to y in each of the branches.

Yes I'm not really in favor of changing the type of the current case_of_ but provide an additional one (dcase?) that does, but desugars into the same Haskell syntax. That's why we really need #105 (so that I can do it myself without the prelude).

I have an actual use case that requires the dependency! (I think)

I'm curious, could you give your use case here? I was under the impression that the current version was already expressive enough to express basically anything we want.

Ah apologies, after a few hours of sleep I now see you're right, we can use case_of_ dependently already, closing this.