conal / total-map

Finitely represented /total/ maps
Other
15 stars 6 forks source link

codomain always includes the default element #7

Open dmwit opened 7 years ago

dmwit commented 7 years ago

This issue doesn't actually affect me, but I thought of it in the shower this morning and thought it would be worth recording.

> codomain (fromPartial False (singleton () True))
fromList [False,True]

I don't have many good ideas about fixes, either -- perhaps the only sensible thing to do is to document this wart.

conal commented 7 years ago

Oops. Good catch.

conal commented 7 years ago

This issue is a shame, since codomain isn't denotative (cannot be explained via the denotation). Brings any use of codomain into question. Are you using it?

dmwit commented 7 years ago

I am using it, but only on maps whose source type is infinite. codomain should be denotative on such maps.

xplat commented 4 years ago

A potential fix for this would be to change the implementation from a thin layer over Data.Map to a tree that divides the domain exhaustively into non-overlapping intervals that are each assigned a value. It's a pretty involved fix, but it does have other advantages (like, you could potentially represent more functions than just the finitely supported ones)

conal commented 4 years ago

I had completely forgotten about this bug. I guess I didn't give this operation much thought at the time. I'm somewhat inclined to excise this operation altogether, since the point of total-map was to have and adhere to a precise and simple denotation. We can discuss principled alternatives.

conal commented 4 years ago

I just released a new version with codomain renamed to "range" and range deprecated as non-denotative.