Weblog of Kenny

Dec 6, 2005 at 10:04 o\clock

Design Decisions on polymorphic XML transformation. Part 2

by: luzm

I continue the write up in this new entry.

It seems that

1. Using indeterministic maching policy greatly simplifies the type system.
2. Programmer supplies explicit type information when type application is ambiguous


Here are some useful examples using polymorphic regular expression types.


Example 1.

map :: (a ->b) -> a* -> b*
map f :: (a->b) = let g :: a* -> b*
                              g (x :: a, xs :: a*) = ((f x), (map f xs))
                              g () = ()
                          in  g


Example 2.

filter :: (a|b)* -> a*
filter xs = let f :: (a|b) -> a?
                    f (x :: a) = x
                    f (x :: b) = ()
                in map f xs

Example 3.

zip :: [a]+ -> [a+]
zip (x :: [a], y :: [a], z :: [a]*) = zip ((prelude.zip x y),z)
zip (x :: [a])                         = x

d


Log in to comment:

Attention: many blogigo features are only available to registered users. Register now without any obligations and get your free weblog!