
Hello, exists any algorithm to determine how terms can be changed to safisty the type of one function? example: f:: a-> b -> c -> (b,c,a) f1 :: c -> a -> d In my first function "f" i want assign the output "c" and "a" for to input of function "f1". I searched for any solution, but i didn't find any anything. One clue i have found is "minimal edit distance algorithm" for 2 strings. Perhaps if i convert de output type of "f" to one string, and de input of "f1" to another string and then use this algorithm , i will get one "dirty" solution... I'm open to any sugestion.

Excerpts from André Batista Martins's message of Sat Oct 09 17:45:05 -0400 2010:
Hello, exists any algorithm to determine how terms can be changed to safisty the type of one function?
Your terminology is a little off: in particular, your example doesn't include any "terms" (which are understood to be the things to the right of the =, not the double-colon). The term you are actually looking for is "unification". One way of looking at this is that you have two types that are the same type, but due to their structure they impose various constraints on each other. Solve all of the constraints and you have a unified type (indeed, the "best" such type in many type systems--the correct term is principal type), and if you can't solve them then you have a type error. Cheers, Edward

You can use Djinn to generate the glue. Note that in the example you
give there are many possible ways to make the glue just looking at the
types.
Changing the output types of f so they can't be confused with the
input types we get:
Djinn> ? compose :: (c1 -> a1 -> d) -> (a-> b -> c -> (b1,c1,a1)) ->
(a -> b -> c -> d)
compose :: (c1 -> a1 -> d) -> (a -> b -> c -> (b1, c1, a1)) -> a -> b -> c -> d
compose a b c d e =
case b c d e of
(_, f, g) -> a f g
-- Lennart
2010/10/9 André Batista Martins
Hello, exists any algorithm to determine how terms can be changed to safisty the type of one function?
example:
f:: a-> b -> c -> (b,c,a)
f1 :: c -> a -> d
In my first function "f" i want assign the output "c" and "a" for to input of function "f1". I searched for any solution, but i didn't find any anything.
One clue i have found is "minimal edit distance algorithm" for 2 strings. Perhaps if i convert de output type of "f" to one string, and de input of "f1" to another string and then use this algorithm , i will get one "dirty" solution...
I'm open to any sugestion.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
André Batista Martins
-
Edward Z. Yang
-
Lennart Augustsson