Wrong defintition of curry Alexey Romanov 10th September, 2007 19:43 (UTC)
Your curry is identity with restricted type.
Wrong defintition of curry Kirit Sælensminde 11th September, 2007 06:39 (UTC)
Alexey Romanov said

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?


To join in the discussion you should register or log in
Wrong defintition of curry Alexey Romanov 11th September, 2007 10:26 (UTC)
Kirit Sælensminde said
Alexey Romanov said

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

Wrong defintition of curry Kirit Sælensminde 11th September, 2007 10:43 (UTC)
Alexey Romanov said

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.


To join in the discussion you should register or log in
Wrong defintition of curry BobMac 5th October, 2007 14:56 (UTC)

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 ) >

Wrong defintition of curry Kirit Sælensminde 6th October, 2007 02:11 (UTC)
BobMac said

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.)


To join in the discussion you should register or log in
Wrong defintition of curry BobMac 6th October, 2007 23:27 (UTC)
You could shorten things up by adding a 'using namespace boost'