I'm looking for example type systems that can type list structure.
For a simple example... (Sorry, I think in code)
// Map two elts at a time, not two lists
def map2(alist:List, f(*,* -> 'u) -> 'u List) // f(*,*) is not good
def mklis(nl: 'u List, rest: List)
match rest
| a :: b :: r -> mklis(f(a,b) :: nl, r) // types of a and b?
| else -> reverse(nl)
in mklis(nil, alist);
def plist2alist(plist:List -> <List>List)
map2(plist, fn(a,b) a :: b :: nil);
plist2alist('(A, 1, B, 2, C, 3))
=> ((A,1),(B,2),(C,3))
It would be very nice to type plist's internal structure,
thus allowing for typing the map2 function, plist2alist()'s
resulting internal structure, etc.
I can sort of imagine some kind of regex typing construct,
but I have no clear ideas on this. Any languages out there
do a good job of typing repeating internal patterned structure
like this?
If this is impossible for any theoretical reason, I'd love
to know that too :-)
Many thanks.
Scott
Recent comments
27 weeks 1 day ago
27 weeks 1 day ago
27 weeks 1 day ago
49 weeks 3 days ago
1 year 1 week ago
1 year 3 weeks ago
1 year 3 weeks ago
1 year 5 weeks ago
1 year 10 weeks ago
1 year 10 weeks ago