-
Notifications
You must be signed in to change notification settings - Fork 32
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
Builtin Map type #17
Comments
If we do the subtyping right then we might not even need a new syntax. In other words, if a homogeneous record is a subtype of a I'll provide two concrete examples to illustrate what I mean:
|
Hm, I guess we are talking about different things here. Maybe let isEven = Map/map Natural/even
let getFoo = \x -> x.foo
let f = \x -> getFoo (isEven x)
in
f If I am not mistaken then Grace would infer What I had in mind when I opened this issue was a type that has both properties: A type-safe lookup (no Hope this makes it a bit clearer what my idea was. Does it make sense? |
What would the type of |
That is indeed a good question. It is not yet clear to me; Maybe Map/map : forall (a : Type) . forall (b : Type) . forall (fa : MapFields a) . forall (fb : MapFields b) . (a -> b) -> { fa } -> { fb } or Map/map : forall (a : Type) . forall (b : Type) . forall (f : MapFields) . (a -> b) -> { f a } -> { f b } or Map/map : forall (a : Type) . forall (b : Type) . forall (f : Type -> Fields) . (a -> b) -> { f a } -> { f b } ? |
When working with Dhall every now and then I with for something that is a record, but with a fixed type for all the fields. Records have the advantage that we can address fields by name (
record_value.field_name
) but we cannot talk about the types of the fields. Lists have the advantage that we can do this - for instance, we can map over the elements - but we cannot address an element in a type-safe way. The idea is to have something combining both, i.e. a homogenous record. But it might be better to call it aMap
(or anObject
or aDictionary
). Since we have subtyping in this language this type would probably a subtype ofRecord
and can be easily converted to aList
.A first idea for the syntax:
{! field1 : value1, field2 : value1, ... }
, i.e. the only difference is the exclamation mark after the opening brace (no whitespace allowed inbetween - it parses as one token). This has the disadvantage that it might be easily confused with a record when one is skimming through some source code but on the other hand it one can quickly change a Record type to a Map type.The text was updated successfully, but these errors were encountered: