-- | Make a non-injective function injectivemkInjective::Ordb=>[a]->(a->b)->a->(b,Maybea)mkInjectivedomainf=letimage=mapfdomainnonInjectiveImage=Set.fromList$dupsimagein\a->letb=fainifSet.memberbnonInjectiveImagethen(b,Justa)else(b,Nothing)wheredups=Map.keys.Map.filter(>1).Map.fromListWith(+).fmap(,1::Int)
See it in action here. https://funprog.srid.ca/general/ Note that almost all topics have "clean URLs" (matching topic title), except for two topics titled "Interface". They differ only case of the first letter, so their URL slug has a md5 hash appended to it.
So I began writing this:
Final implementation:
Guess what it is used for.
https://github.com/srid/zulip-archive/commit/d583777b4a14360e794c87a0e271743faa4da9d4
Entirely thing has been put in the
Web.UniqSlug
module: https://github.com/srid/zulip-archive/blob/master/src/Web/UniqSlug.hsSee it in action here. https://funprog.srid.ca/general/ Note that almost all topics have "clean URLs" (matching topic title), except for two topics titled "Interface". They differ only case of the first letter, so their URL slug has a md5 hash appended to it.