[Haskell-cafe] Re: Re-order type

Ryan Ingram ryani.spam at gmail.com
Mon Oct 11 05:18:12 EDT 2010


djinn[1] can derive some glue functions for you.

you tell it something like
> glue :: (x -> y -> z -> (b,(c,a)) -> (c -> a -> d) -> x -> y -> z -> d
and it tells you something like
> glue f g x y z = let (b,(c,a)) = f x y z in g c a
I changed the type of f slightly to avoid the trivial answer
> glue _ g a _ c = g c a

[1] http://hackage.haskell.org/package/djinn



2010/10/9 André Batista Martins <andre_bm at netcabo.pt>:
>
> Might have not been clear, but i will try illustrate .
>
>
> f:: a-> b -> c -> (b,(c,a))
>
> f1 ::  c -> a -> d
>
>
> input type:
>                                A   B   C
>                                  ----------
>                                |    f      |
>                                | _____ |
>
> output                       (B,(C,A))
>
>
>                                  C    A
>                                  ----------
>                                |    f1    |
>                                | _____ |
>
> output                         D
>
> If i want compose   f  and f1, i need to do a correct input to f1 from the
> output of f.
> So i want one function to  convert the output of "f" to input off "f!".
> In this case,  we do      f1 fst (snd (t,(t1,t2)))  snd (snd (t,(t1,t2)))
> But i want do this automaticaly, for type of any two function. I search for
> the "glue".
>
> I don't have any concern about what the function does, i only have interess
> on input and output types.
>
>
> Cheers,
>  André
>
>
>
> No dia 9 de Outubro de 2010 22:38, André Batista Martins
> <andre_bm at netcabo.pt> escreveu:
>>
>> 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


More information about the Haskell-Cafe mailing list