Map operation class
Functor only applies to type constructors (Type u -> Type v). So, is insufficient for a general purpose map : (A -> B) -> CA -> CB where perhaps CA and CB cannot contain arbitrary element types.
Example: Functor ByteArray does not typecheck, even though we can give map : (Byte -> Byte) -> ByteArray -> ByteArray
Suggested implementation:
class Map (C : Type w) (τ : Type x) (C' : Type y) (τ' : Type z) where
map : (f : τ → τ') → C → C'
This conflicts with the current Map class (which is the bag of associations abstraction commonly called a Map in other languages).
We could
- Name the new class
MapOp? Since we willexport MapOp (map)it will still be visible, but with the current naming scheme, theorems about map will end up in theMapOp.theorems_about_mapnamespace. - Rename current
MaptoMapBagor similar. I don't .. hate this solution? because it emphasizes the class's relationship toBag, but this goes against other languages with interfaces namedMap.
I haven't yet checked what Haskell libraries do. Could be a useful source.
What about Dict or Dictionary?
Gonna wait until the 4.8 release to add a Map class, so the deprecation notice sticks around for at least a little while.