Open danidiaz opened 5 years ago
A possible implementation for key lookups (should the error go in the precondition instead?):
instance KeyHelper GT k E v' right where
type Value' GT k E v' right =
TypeError (Text "Key " :<>: ShowType k :<>: Text " not found in map.")
field' _ = error "unreachable"
branch' = error "unreachable"
instance KeyHelper LT k left v E where
type Value' LT k left v E =
TypeError (Text "Key " :<>: ShowType k :<>: Text " not found in map.")
field' _ = error "unreachable"
branch' = error "unreachable"
In general, it would be desirable for the internals of the red-black tree not to leak into the error messages.
Improving errors for Delete
and Insert
would be more involved because of how they use non-linear patterns
instance InsertableHelper2 EQ k v color left k v right where
type Insert2 EQ k v color left k v right = N color left k v right
We would need yet another auxiliary typeclass perhaps, one which used an explicit comparison.
Perhaps we should introduce some custom type errors.
For example, instead of this
We could print someking like "Key foo not found in map".