User loginNavigation |
Are 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 By Douglas McClean at 2009-06-04 02:26 | LtU Forum | previous forum topic | next forum topic | other blogs | 7961 reads
|
Browse archives
Active forum topics |
Recent comments
27 weeks 6 days ago
27 weeks 6 days ago
27 weeks 6 days ago
50 weeks 10 hours ago
1 year 2 weeks ago
1 year 3 weeks ago
1 year 3 weeks ago
1 year 6 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago