Reputation: 6788
Traditionally functors in Haskell are supposed to support identity and composition laws. In Agda these laws should be formalized, but the standard library only ships RawFunctor
s yet (i.e. an fmap without laws). In the process of formalizing functors a few questions arise:
Should functors support congruence in general?
Setoid
s or just Relation.Binary.PropositionalEquality.setoid
?Function.Equality.Π
?(id′ : A → A) → id′ ≗ id
)?Upvotes: 1
Views: 631
Reputation: 6788
Partial answer:
Functors on equivalence relations
If a mapping F : Setoid ℓ ℓ → Setoid ℓ ℓ
is to be turned into a functor, then congruence does not follow from other laws. For instance, F
could map an s
with the trivial relation to Relation.Binary.PropositionalEquality.setoid (Carrier s)
and set fmap = id
. Then, congruence does not hold in general. So as soon as the first equivalence relation is something different from equality, congruence is not a consequence.
Functors on propositional equality
It seems that all congruence proofs have the same structure: induction on the syntax of the fmap
function. Thus they fall in the same category as free theorems. Other than something similar to lightweight free theorems, there is no automatic way to obtain such a proof.
More answers welcome.
Upvotes: 2