Your curry is identity with restricted type.
Thanks Alexey, that makes sense. The right hand side of curry is the same as the left of papply whose right hand side is the same as the arguments to curry.
Clearly I haven't got my head around this sort of thing in Haskell yet. I'll have to try it again :)
Do you happen to know what the result of currying papply is meant to be?
Your curry is identity with restricted type.
Thanks Alexey, that makes sense. The right hand side of curry is the same as the left of papply whose right hand side is the same as the arguments to curry.
Clearly I haven't got my head around this sort of thing in Haskell yet. I'll have to try it again :)
Do you happen to know what the result of currying papply is meant to be?
You are welcome. Thinking it through, it seems to me that we should have
curry f a b = f (a, b)
Checked it in GHCi and this is correct.
curry :: ((t, t1) -> t2) -> t -> t1 -> t2
and
papply :: ((t, t1) -> t2, t) -> t1 -> t2
So curry papply makes sense and
curry papply :: ((t, t1) -> t2) -> t -> t1 -> t2 curry papply f a b = papply (f, a) b = f (a, b)
Or pointlessly,
curry papply = curry
You are welcome. Thinking it through, it seems to me that we should have
curry f a b = f (a, b)
Checked it in GHCi and this is correct.
curry :: ((t, t1) -> t2) -> t -> t1 -> t2
That makes a lot more sense than what I was trying. Well done!
and
papply :: ((t, t1) -> t2, t) -> t1 -> t2
So curry papply makes sense and
curry papply :: ((t, t1) -> t2) -> t -> t1 -> t2
curry papply f a b = papply (f, a) b = f (a, b)
Or pointlessly,
curry papply = curry
Which is great because it's exactly what I was thinking it ought to be. If I can only work out the right way of doing it in C++ I'll be able to post a follow up.
Thanks again for your help.
Looks like your error is in the type signature for curry:
Curry returns a function that takes an argument of its first parameter type and returns function which takes its second parameter type So curry's return type is: boost::function< boost::function< R ( V2 ) > ( V1 ) > Not boost::function< boost::function< R ( V1 ) > ( V2 ) >
Looks like your error is in the type signature for curry:
Curry returns a function that takes an argument of its first parameter type and returns function which takes its second parameter type So curry's return type is: boost::function< boost::function< R ( V2 ) > ( V1 ) > Not boost::function< boost::function< R ( V1 ) > ( V2 ) >
Of course. I'd have never seen that myself! — And of course didn't for a very long time. Now I can get on and write it up properly, but I think I really need to find a better function than one that takes ints everywhere. It isn't especially illuminating is it?
boost::function<
boost::function<
boost::function< int ( int ) > ( int ) > (
boost::function< int ( int, int ) > ) >
fcurry( curry( fpapply ) );
boost::function< int ( int ) > inc4( fcurry( fadd )( 1 ) );
std::cout << inc4( 6 ) << “ ” << inc4( 10 ) << std::endl;(I think once you get this far there really isn't any readable way of laying it out.)