Design Decisions on polymorphic XML transformation. Part 2
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
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
