Agda-stdlib: Make some `Dec` operations more easily accessible?

Created on 6 Jun 2020  Β·  5Comments  Β·  Source: agda/agda-stdlib

Hello there. I was doing some stuff with decidable equality and ended up needed the following operations:

  imap : βˆ€ {β„“} {a b : Set β„“} β†’ (a β†’ b) β†’ (b β†’ a) β†’ Dec a β†’ Dec b
  imap f _ (yes x) = yes (f x)
  imap _ g (no  x) = no $ x ∘ g

  zip : βˆ€ {β„“} {a b : Set β„“} β†’ Dec a β†’ Dec b β†’ Dec (a Γ— b)
  zip (yes x) (yes y) = yes $ (x , y)
  zip (no  x) _       = no $ Ξ» { (x' , _) β†’ x x' }
  zip _       (no  y) = no $ Ξ» { (_ , y') β†’ y y' }

  _βˆͺ_ : βˆ€ {β„“} {a b : Set β„“} β†’ Dec a β†’ Dec b β†’ Dec (a ⊎ b)
  _βˆͺ_ (yes a) _ = yes (inj₁ a)
  _βˆͺ_ (no  a) b = imap injβ‚‚ ([ βŠ₯-elim ∘ a , id ]β€²) b

Does it make any sense to add these to the Relation.Nullary module that Dec is exported from?

discussion refactoring

Most helpful comment

No bother. I myself find it annoying that you have to import 3 or 4 modules to
start working with Dec. I wonder whether we could reorganise this part of the
hierarchy in a backwards-compatible manner that would allow you to import, say
Relation.Decidability and have immediately access to a whole host of functions.

Edit: I have hijacked this issue to discuss such a change.

All 5 comments

zip and _βˆͺ_ respectively have the following units, but doesn't seem to be much of a use for exporting these given that they're very thin aliases for stuff that's already exported under other names:

  pure : βˆ€ {β„“} {a : Set β„“} β†’ a β†’ Dec a
  pure = yes

  βˆ… : Dec βŠ₯
  βˆ… = no βŠ₯-elim

This is respectively:

Doii, should have looked around more. Thanks

No bother. I myself find it annoying that you have to import 3 or 4 modules to
start working with Dec. I wonder whether we could reorganise this part of the
hierarchy in a backwards-compatible manner that would allow you to import, say
Relation.Decidability and have immediately access to a whole host of functions.

Edit: I have hijacked this issue to discuss such a change.

I am definitely a big fan of having the "developer's library" be made of tons of small files with carefully crafted minimal dependencies, and a "user's library" with fewer modules that provide 'broad utility' with few imports. Both would be part of the standard library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uzytkownik picture uzytkownik  Β·  5Comments

gallais picture gallais  Β·  7Comments

WolframKahl picture WolframKahl  Β·  5Comments

JacquesCarette picture JacquesCarette  Β·  8Comments

asr picture asr  Β·  3Comments