-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need class for containers of elements that have their own keys #129
Comments
Can you give an example of one of these other container types you're
talking about?
…On Fri, Apr 14, 2017, 2:08 AM Ashley Yakeley ***@***.***> wrote:
Currently, there's the IsMap class:
class (MonoTraversable map, SetContainer map) => IsMap map where
type MapValue map
lookup :: ContainerKey map -> map -> Maybe (MapValue map)
insertMap :: ContainerKey map -> MapValue map -> map -> map
-- etc.
In most (all?) instances of IsMap, we have Element map ~ (ContainerKey
map, MapValue map), that is, there's some MapValue type that is "the
element minus the key".
However, for some containers, there isn't a suitable MapValue type
because the key cannot easily be removed from the Element type. Instead,
we'd want a class that looks more like this:
class (MonoTraversable map, SetContainer map) => KeyContainer map where
elementKey :: Element map -> ContainerKey map
lookupElement :: ContainerKey map -> map -> Maybe (Element map)
insertElement :: Element map -> map -> map
-- etc.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#129>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AADBB5AFjQXY7ZJzj5uWFAcHK_fNFt6sks5rvqr_gaJpZM4M9TTt>
.
|
I don't know if such types already exist, but:
|
I'm sorry, but at this level of abstraction I'm having a really hard time understanding the request here. |
Fair enough. Given that I don't actually know of any types in existing Haskell packages that would implement this and not |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, there's the
IsMap
class:In most (all?) instances of
IsMap
, we haveElement map ~ (ContainerKey map, MapValue map)
, that is, there's someMapValue
type that is "the element minus the key".However, for some containers, there isn't a suitable
MapValue
type because the key cannot easily be removed from theElement
type. Instead, we'd want a class that looks more like this:The text was updated successfully, but these errors were encountered: