User loginNavigation |
archivesAre extensible records first class patterns?If you have a language with extensible records (like those of Gaster and Jones), and you view functions like a -> Maybe { r } for some row r as patterns, are there practical obstacles that prevent you from extending the environment of a case alternative with the row of the result type of its controlling pattern? I would appreciate pointers to anywhere that this is discussed in the literature, or an explanation of why it is a bad idea. Google hasn't been especially helpful.
-- concrete syntax for records is entirely made-up
wildcard_pattern = const Just {}
-- without first class labels, the compiler would have to make a whole family
-- of declarations like this, one for each variable bound by a pattern
variable_pattern_x val = Just { x := val }
-- same comment applies
as_pattern_x pat val = case pat val of
Just rec -> { x := val, rec }
Nothing -> Nothing
-- I'm not 100% sure that this handles laziness correctly, but you get the idea
-- declarations like this would be automatically generated from the datatype declarations
cons_pattern pat_head pat_tail [] = Nothing
cons_pattern pat_head pat_tail (x:xs) = case pat_head x of
Just rec_head -> case pat_tail xs of
Just rec_tail -> record_join rec_head rec_tail
Nothing -> Nothing
Nothing -> Nothing
nil_pattern [] = Just {}
nil_pattern _ = Nothing
Peter LandinI was just forwarded a message that Peter Landin passed away yesterday.
Landin was one of the founders of our field, and did a lot of work of lasting value. We've discussed his papers here many times before, even though some of them were written decades ago. He did work that cast a long shadow, or phrased better, did work that illuminated wide vistas. |
Browse archivesActive forum topics |
Recent comments
2 days 11 hours ago
3 days 8 hours ago
4 days 13 hours ago
4 days 13 hours ago
1 week 2 days ago
1 week 2 days ago
1 week 2 days ago
4 weeks 3 days ago
5 weeks 1 day ago
5 weeks 1 day ago