Idris2-boot icon indicating copy to clipboard operation
Idris2-boot copied to clipboard

Missing functionality: impossibility assertions in pattern-matching anonymous functions

Open vfrinken opened this issue 4 years ago • 4 comments

If possible, please include complete self contained source files (for example by uploading to https://gist.github.com) that exhibit the issue in addition to quoting from them here. The smaller the example the better!

Steps to Reproduce

import Decidable.Equality

data MyDATA = ABC | DEF

DecEq MyDATA where
  decEq ABC ABC = Yes Refl
  decEq ABC DEF = No (\Refl impossible)
  decEq DEF ABC = No (\Refl impossible)
  decEq DEF DEF = Yes Refl

Expected Behavior

type checking without problems Idris: File loaded successfully like Idris 1

Observed Behavior

Parse error: Not the end of a block entry (next tokens: [symbol (, symbol \, identifier Refl, impossible, symbol ), identifier decEq, identifier DEF, identifier ABC, symbol =, identifier No])

vfrinken avatar Apr 10 '20 23:04 vfrinken

I think this is because the impossible on a pattern match in an anonymous function is not yet implemented.

If you're blocked on this, here's a work-around:

import Decidable.Equality

data MyDATA = ABC | DEF

DecEq MyDATA where
  decEq ABC ABC = Yes Refl
  decEq ABC DEF = No $ \case Refl impossible
  decEq DEF ABC = No $ \case Refl impossible
  decEq DEF DEF = Yes Refl

ohad avatar Apr 11 '20 00:04 ohad

Worth noting we have lambda-case thanks to #244

gallais avatar Apr 11 '20 00:04 gallais

Thanks!

I guess we should decide on whether this is a missing feature, or \case is the way to go.

ohad avatar Apr 11 '20 13:04 ohad

I would argue that lambda case is a good way to go. Especially, if it is well documented.

jfdm avatar Apr 15 '20 20:04 jfdm