-
Notifications
You must be signed in to change notification settings - Fork 245
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
Can we unify Relation.Binary.Morphism.Definitions and Function.Definitions? #2318
Comments
"Can"? or "Should"? It seems as though (modulo dependencies/dependency cycles? not sure about this...) we can. Not obvious to me that we should... partly because of the ergonomics of the whole |
I agree with @jamesmckinna. We absolutely can, but I don't think we should because it would be violating the standard design of hierarchies in the library. Obviously if we could do it for every hierarchy in the library that would be a different question.... |
Revisiting this in the course of reconsidering #1436 ... not to go back on my earlier judgment, but to observe that if Eg. in module Function.Structures {a b ℓ₁ ℓ₂}
{A : Set a} (_≈₁_ : Rel A ℓ₁) -- Equality over the domain
{B : Set b} (_≈₂_ : Rel B ℓ₂) -- Equality over the codomain
where
open import Data.Product.Base as Product using (∃; _×_; _,_)
open import Function.Base
open import Function.Definitions _≈₁_ _≈₂_
open import Level using (_⊔_) in the preamble, and thus not endlessly have to repeat the explicit parameters (And yes, the module is instantiated at different relations at various points, so better would be to have a qualified import, and then supply the parameters... but this doesn't really vitiate the point) Ditto. in the concrete Ditto. in (Unless I really don't understand how module instantiation works... I'm guessing that module Foo (p : P) where
defn : ...
defn = ... is not the same, on module Foo where
module _ (p : P) where
defn : ...
defn = ... or are these two 'the same'?) |
... And the above remarks apply also to |
See also #2581 for yet another variation on this theme... |
About your two different |
I'll refine the example to explain how I think they could be different at usage sites... returning to this now: module Foo (p : P) where
defn : ...
defn = ... can be imported (qualified or unqualified) two ways in client modules
By contrast, module Foo where
module _ (p : P) where
defn : ...
defn = ... can only be imported (qualified or unqualified) in the 'uninstantiated'/'local' way above. So the first style seems both more ergonomically flexible, as well as extending that of the second in a compatible way. As such, it seems preferable (cf. NB. the local/global distinction cashes out on |
Looping back to @Taneb 's OP, and mine and @MatthewDaggitt 's comments, there's a separate problem with 'too much' DRY-delegation of one hierarchy to another: the cognitive load on the user/reader in needing definitional equality to be 'transparent' across modules... it is, semantically, of course, but not 'visually'. Hence the recent discussion/critique of #2566 / #2581 |
Or more succinctly: mentally expanding definitions has non-zero cognitive load. |
Closing this, as I think it's been answered "we shouldn't do this even if we technically can" and the discussion has gone way further than I expected it would when I opened it. |
Relation.Binary.Morphism.Definitions
has as module parameters the domain and codomain of the functions over which the definitions are made, whereasFunction.Definitions
has them in avariable
block. The former module only containsHomomorphic₂
, which is exactly the same as the latter'sCongruent
, and a re-export ofMorphism
fromFunction.Core
, which I think is otherwise unused in the library (and is just a synonym for the function arrow).Can we deprecate
Relation.Morphism.Definitions
in favour ofFunction.Definitions
?The text was updated successfully, but these errors were encountered: