UlfNorell / agda-test

Agda test
0 stars 0 forks source link

Case splitting emits hidden record patterns that should remain implicit. #635

Open UlfNorell opened 10 years ago

UlfNorell commented 10 years ago

From pumpkingod@gmail.com on May 10, 2012 21:34:38

On recent Agda:

module Splitting where

record Monoid : Set₁ where field Carrier : Set empty : Carrier times : Carrier → Carrier → Carrier equal : Carrier → Carrier → Set

record MonoidMorphism (M₁ M₂ : Monoid) : Set where constructor monMor module M₁ = Monoid M₁ module M₂ = Monoid M₂ field f : M₁.Carrier → M₂.Carrier .identity : M₂.equal (f M₁.empty) M₂.empty

f : ∀ {M₁ M₂ : Monoid} → MonoidMorphism M₁ M₂ → MonoidMorphism M₁ M₂ f x = {!x!}

case splitting on x in that hole produces this monstrosity:

f {.Splitting.recCon-NOT-PRINTED Carrier empty times equal} {.Splitting.recCon-NOT-PRINTED Carrier₁ empty₁ times₁ equal₁} (monMor f identity) = ?

Original issue: http://code.google.com/p/agda/issues/detail?id=635

UlfNorell commented 10 years ago

From pumpkingod@gmail.com on May 14, 2012 07:34:19

I think there are two issues here, really. The case splitter for some reason decides that it needs to provide the implicit arguments as patterns to be able to match on monMor (something to do with eta expansion?), which isn't true. And second, because there is no way to match on records with no constructors, we're getting some weird internal representation of the constructor filled in for those implicit patterns.

UlfNorell commented 10 years ago

From nils.anders.danielsson on May 21, 2012 05:34:15

Status: Accepted
Owner: ulf.nor...@gmail.com
Labels: Type-Defect

UlfNorell commented 10 years ago

From andreas....@gmail.com on September 20, 2012 02:36:05

Labels: Milestone-2.3.2 Pattern-Matching

UlfNorell commented 10 years ago

From nils.anders.danielsson on October 08, 2012 09:47:30

Owner: andreas....@gmail.com
Labels: -Milestone-2.3.2 Priority-High

UlfNorell commented 10 years ago

From andreas....@gmail.com on October 19, 2012 01:04:08

Labels: -Pattern-Matching PatternMatching

UlfNorell commented 10 years ago

From andreas....@gmail.com on October 29, 2012 11:11:20

In issue 473 eager eta-expansion of implicit patterns of record type was introduced. Maybe that should be done on demand only.

Labels: Eta

UlfNorell commented 10 years ago

From andreas....@gmail.com on March 04, 2013 14:22:49

Issue 810 has been merged into this issue.

UlfNorell commented 10 years ago

From stevan.a...@gmail.com on March 05, 2013 04:57:05

Issue 810 has been merged into this issue.

UlfNorell commented 10 years ago

From andreas....@gmail.com on March 21, 2013 15:19:25

Fixed by only eta-expanding implicit patterns of record type with a constructor. This weakens the fix for issue 473 a bit. Let's see if this becomes a problem...

Status: Fixed

UlfNorell commented 10 years ago

From stevan.a...@gmail.com on March 22, 2013 07:16:26

The example from Issue 810 still doesn't work (should I open a new issue?):

record Cont : Set₁ where constructor field Sh : Set Pos : Sh → Set

open Cont

data W (C : Cont) : Set where sup : (s : Sh C) (k : Pos C s → W C) → W C

-- If I case split on w: bogus : {C : Cont} → W C → Set bogus w = {!!}

-- I get this: bogus′ : {C : Cont} → W C → Set bogus′ {Sh ◃ Pos} (sup s k) = {!!}

UlfNorell commented 10 years ago

From andreas....@gmail.com on March 22, 2013 07:44:50

Well, yes, but it does not crash Agda. It just makes interactive case annoying, because you have to clean up manually. But this is my experience with case-splitting anyway.

To fix this properly, one would have to check wether the expanded record pattern contains has introduced variables that are used in later patterns (e.g. in dot patterns). If not, it can be folded back into an implicit pattern.

Summary: Case splitting emits hidden record patterns that should remain implicit. (was: Case splitting emits things that should never be emitted!)
Status: Accepted
Labels: -Type-Defect -Priority-High Type-Enhancement Priority-Medium