Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some Dec operations more easily accessible? #1229

Closed
masaeedu opened this issue Jun 6, 2020 · 6 comments · Fixed by #2110
Closed

Make some Dec operations more easily accessible? #1229

masaeedu opened this issue Jun 6, 2020 · 6 comments · Fixed by #2110
Assignees
Milestone

Comments

@masaeedu
Copy link

masaeedu commented Jun 6, 2020

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?

@masaeedu
Copy link
Author

masaeedu commented Jun 6, 2020

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

@gallais
Copy link
Member

gallais commented Jun 6, 2020

This is respectively:

@masaeedu
Copy link
Author

masaeedu commented Jun 6, 2020

Doii, should have looked around more. Thanks

@gallais
Copy link
Member

gallais commented Jun 6, 2020

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.

@gallais gallais changed the title Add some operations for Decs Make some Dec operations more easily accessible? Jun 6, 2020
@gallais gallais reopened this Jun 6, 2020
@JacquesCarette
Copy link
Contributor

JacquesCarette commented Jun 6, 2020

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.

@MatthewDaggitt MatthewDaggitt added this to the v2.0 milestone Jul 11, 2021
@MatthewDaggitt
Copy link
Contributor

Mimic structure of e.g. Relation.Unary by moving Nullary.Product etc. contents into the main module and decidability to Relation.Nullary.Properties module. Put out an RFC before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants