GSoC 2014 - Functional - Monad
Hello, Boost. This is Xiangfei, a first year CS student from National University of Sinagpore. I am familiar with C++ template programming and have learnt a little functional programming language by myself. Therefore I find the monad project in boost will be very interesting and useful. This is my first time applying for GSoC. I have past boost use experience, but it is my first time also to contribute in Boost library. I have a question for the implementation of monad. What is the degree of integration of this module with other Boost utilities other than sequences and containers? Thank you. Regards, Xiangfei
Le 05/03/14 16:36, Ding Xiangfei a écrit :
Hello, Boost. This is Xiangfei, a first year CS student from National University of Sinagpore. I am familiar with C++ template programming and have learnt a little functional programming language by myself. Therefore I find the monad project in boost will be very interesting and useful. Hi Ding and welcome to Boost
Which functional language do you know?
This is my first time applying for GSoC. I have past boost use experience, but it is my first time also to contribute in Boost library.
I have a question for the implementation of monad. What is the degree of integration of this module with other Boost utilities other than sequences and containers? Thank you.
There is no implied dependencies on any Boost library. Of course, there is no need to reinvent the wheel. However at least the library must provide mapping for boost/std::future, boost::optional and the on going boost::expected classes between others. Mapping to containers could be provided in order to check for the ability to configure it, but it is not mine main goal for the library. Been able to understand the implementation of the Pure library is a must. (https://github.com/splinterofchaos/Pure) Please take a look at it a let me know how do you fill with this kind of code. I would appreciate if you can give you impression of the library, what you like, what you would change, any additional feedback .... HTH, Vicente
Vicente J. Botet Escriba
Le 05/03/14 16:36, Ding Xiangfei a écrit :
Hello, Boost. This is Xiangfei, a first year CS student from National University of Sinagpore. I am familiar with C++ template programming and
have
learnt a little functional programming language by myself. Therefore I find the monad project in boost will be very interesting and useful. Hi Ding and welcome to Boost
Which functional language do you know?
This is my first time applying for GSoC. I have past boost use experience, but it is my first time also to contribute in Boost library.
I have a question for the implementation of monad. What is the degree of integration of this module with other Boost utilities other than sequences and containers? Thank you.
There is no implied dependencies on any Boost library. Of course, there is no need to reinvent the wheel. However at least the library must provide mapping for boost/std::future, boost::optional and the on going boost::expected classes between others.
Mapping to containers could be provided in order to check for the ability to configure it, but it is not mine main goal for the library.
Been able to understand the implementation of the Pure library is a must. (https://github.com/splinterofchaos/Pure) Please take a look at it a let me know how do you fill with this kind of code. I would appreciate if you can give you impression of the library, what you like, what you would change, any additional feedback ....
HTH, Vicente
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hello, Vincete, Sorry for this delayed reply. Yes, I have learnt a subset of Javascript as a functional programming language which includes list manipulation, function composition, lazy computation (memoization), etc. I am currently learning Scala and Haskell. I also have understood the concept of Monad as well after reading the Haskell Wiki. boost/std::future.then fits in the Monad concept quite well. The future class is used as the container of computed results from the previous task, and the method then() is to apply a function to these results, which can detach from the main thread if launch::async is used. The template for categories and monad can be overloaded to accept future objects and allow mappend a functor to a future object to give an asynchronous function call. This chaining of functions is similar to how Monads. The support for std::future in Monads will be useful because with this feature, algorithms like quick sort or merge sort can work in a multithreading fashion by packing the sub-routines into Monads and branches out. boost::expected, which was the project in previous year's GSOC, boost::expected and boost::optional are also monads. It can be seen as a pair of two values, which are a value and a validity indicator. It is implemented by classes "Maybe", "Either" in the library and this can be our blueprint in the implementation of expected and optional. I have spent time carefully reading the code of the Pure library and think that the Pure library provides a good framework for implementation of monads. Here, I propose an extension to monad templates in the library to make monads for std::future using the then() method. I also propose monads containing functions as well that enables chaining of functions and potentially currying. The implementation may slightly differ from the Pure library because some parts of functors for specific categories can be moved inside monads to reduce compilation time on template resolution. My concern is that when chaining of functions is frequent, compilation time may increase significantly since this library relies on template heavily and functors are placed outside monad definitions. Regards, Ding Xiangfei
Le 11/03/14 19:26, Ding Xiangfei a écrit :
Hello, Vincete,
Sorry for this delayed reply. Yes, I have learnt a subset of Javascript as <snip>
I have spent time carefully reading the code of the Pure library and think that the Pure library provides a good framework for implementation of monads. Here, I propose an extension to monad templates in the library to make monads for std::future using the then() method. I also propose monads containing functions as well that enables chaining of functions and potentially currying. The implementation may slightly differ from the Pure library because some parts of functors for specific categories can be moved inside monads to reduce compilation time on template resolution. My concern is that when chaining of functions is frequent, compilation time may increase significantly since this library relies on template heavily and functors are placed outside monad definitions.
Hi Ding, its time to make a concrete proposal. Best, Vicente
Vicente J. Botet Escriba
Le 11/03/14 19:26, Ding Xiangfei a écrit :
Hello, Vincete,
Sorry for this delayed reply. Yes, I have learnt a subset of Javascript as <snip>
I have spent time carefully reading the code of the Pure library and think that the Pure library provides a good framework for implementation of monads. Here, I propose an extension to monad templates in the library to make monads for std::future using the then() method. I also propose monads containing functions as well that enables chaining of functions and potentially currying. The implementation may slightly differ from the Pure library because some parts of functors for specific categories can be moved inside monads to reduce compilation time on template resolution. My concern is that when chaining of functions is frequent, compilation time may increase significantly since this library relies on template heavily and functors are placed outside monad definitions.
Hi Ding,
its time to make a concrete proposal.
Best, Vicente
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hello, Vincete, Thank you for the previous advice. Based on the ideas I had, I have written a draft proposal for this project. The Google Doc link is as follow: https://docs.google.com/document/d/1sdgO63-SFo9IhPvfcwNSrwVEey9Pl9V9ftmZDPzr... As the proposal is not final and I am still thinking about any new ideas about monads, I would like to invite you for comments and evaluation on the manageability and viability of this project. Besides, I also added some experimental features that I would like to make during (hopfully) or after this summer. Comments on these features are also appreciated. Thank you very much. Regards, Ding
Le 17/03/14 08:46, Ding Xiangfei a écrit :
Hello, Vincete,
Thank you for the previous advice. Based on the ideas I had, I have written a draft proposal for this project. The Google Doc link is as follow:
https://docs.google.com/document/d/1sdgO63-SFo9IhPvfcwNSrwVEey9Pl9V9ftmZDPzr...
As the proposal is not final and I am still thinking about any new ideas about monads, I would like to invite you for comments and evaluation on the manageability and viability of this project.
Besides, I also added some experimental features that I would like to make during (hopfully) or after this summer. Comments on these features are also appreciated.
Hi, there is something I find incoherent on the prose. Fisrt you say "the conception of monads allows functional programming languages to perform a sequence of instructions just as imperative languages. Last you say that "monads will simplify function chaining and exception handling when the code is written in a functional fashion". C++ is a multi-paradigm language that supports already the imperative style and a clean exception handling machinery. How monads can help C++? Why it would be worth to write programms in C++ in a functional monadic style? To be able to perform a sequence of instructions? C++ has already all that. Why monads style will be useful in C++? How do you plan to "simplify type resolution and compile time"? Could you tell more about "dynamic typing of monads"? Could you elaborate on the operations the monads you plan to provide will support? In addition to monad operations do you plan to provide other? e.g. what list operations? Waat do you mean by asynchronous function chaining? Error-handling? Could you show an example of user code making use of monads interface? Could you show an example of developer code making a type behave as a monad? Do you plan to use CRTP? Do you plan to use dynamic polymorphism? What kind of performance would you evaluate? And to which alternative would you compare? Do you have already an idea of the bechmarks 1 and 2? Having a concept without associated algorithms is not too useful. Do you have examples of algorithms that build on top of the monads interface? Do you think that you will be able to finish with a Boost ready for review library at the end of the program? Globally your proposal could be improved a lot by adding more detail. HTH, Vicente
Vicente J. Botet Escriba
Le 17/03/14 08:46, Ding Xiangfei a écrit :
Hello, Vincete,
Thank you for the previous advice. Based on the ideas I had, I have
written a draft proposal for this
project. The Google Doc link is as follow:
SFo9IhPvfcwNSrwVEey9Pl9V9ftmZDPzrqO4/edit?usp=sharing
As the proposal is not final and I am still thinking about any new
ideas about monads, I would like to invite you for comments and evaluation on
the manageability and viability of this project.
Besides, I also added some experimental features that I would like to make during (hopfully) or after this summer. Comments on these features are also appreciated.
Hi,
there is something I find incoherent on the prose. Fisrt you say "the conception of monads allows functional programming languages to perform a sequence of instructions just as imperative languages. Last you say that "monads will simplify function chaining and exception handling when the code is written in a functional fashion".
C++ is a multi-paradigm language that supports already the imperative style and a clean exception handling machinery. How monads can help C++? Why it would be worth to write programms in C++ in a functional monadic style? To be able to perform a sequence of instructions? C++ has already all that. Why monads style will be useful in C++?
How do you plan to "simplify type resolution and compile time"?
Could you tell more about "dynamic typing of monads"?
Could you elaborate on the operations the monads you plan to provide will support? In addition to monad operations do you plan to provide other? e.g. what list operations? Waat do you mean by asynchronous function chaining? Error-handling?
Could you show an example of user code making use of monads interface?
Could you show an example of developer code making a type behave as a monad?
Do you plan to use CRTP? Do you plan to use dynamic polymorphism?
What kind of performance would you evaluate? And to which alternative would you compare? Do you have already an idea of the bechmarks 1 and 2?
Having a concept without associated algorithms is not too useful. Do you have examples of algorithms that build on top of the monads interface?
Do you think that you will be able to finish with a Boost ready for review library at the end of the program?
Globally your proposal could be improved a lot by adding more detail.
HTH, Vicente
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hello Vicente, Thank you very much for your valuable advice. As I am amending the proposal I will give some examples of the interface and algorithms running on it. In order to make the project more manageable, I decided not to go too ambitious and trimmed out the part on 'dynamic typing' (because I think that it is trivial at this moment) and trying to increase type-resolution efficiency to make sure things just work nicely before the end of summer. Regards, Ding Xiangfei
Ding Xiangfei
Vicente J. Botet Escriba
writes: Le 17/03/14 08:46, Ding Xiangfei a écrit :
Hello, Vincete,
Thank you for the previous advice. Based on the ideas I had, I have
written a draft proposal for this
project. The Google Doc link is as follow:
SFo9IhPvfcwNSrwVEey9Pl9V9ftmZDPzrqO4/edit?usp=sharing
As the proposal is not final and I am still thinking about any new
ideas about monads, I would like to invite you for comments and evaluation on
the manageability and viability of this project.
Besides, I also added some experimental features that I would like
make during (hopfully) or after this
summer. Comments on these features are
also appreciated.
Hi,
there is something I find incoherent on the prose. Fisrt you say "the conception of monads allows functional programming languages to perform a sequence of instructions just as imperative languages. Last you say that "monads will simplify function chaining and exception handling when the code is written in a functional fashion".
C++ is a multi-paradigm language that supports already the imperative style and a clean exception handling machinery. How monads can help C++? Why it would be worth to write programms in C++ in a functional monadic style? To be able to perform a sequence of instructions? C++ has already all that. Why monads style will be useful in C++?
How do you plan to "simplify type resolution and compile time"?
Could you tell more about "dynamic typing of monads"?
Could you elaborate on the operations the monads you plan to provide will support? In addition to monad operations do you plan to provide other? e.g. what list operations? Waat do you mean by asynchronous function chaining? Error-handling?
Could you show an example of user code making use of monads interface?
Could you show an example of developer code making a type behave as a monad?
Do you plan to use CRTP? Do you plan to use dynamic polymorphism?
What kind of performance would you evaluate? And to which alternative would you compare? Do you have already an idea of the bechmarks 1 and 2?
Having a concept without associated algorithms is not too useful. Do you have examples of algorithms that build on top of the monads interface?
Do you think that you will be able to finish with a Boost ready for review library at the end of the program?
Globally your proposal could be improved a lot by adding more detail.
HTH, Vicente
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hello Vicente,
Thank you very much for your valuable advice. As I am amending the proposal I will give some examples of the interface and algorithms running on it. In order to make the project more manageable, I decided not to go too ambitious and trimmed out the part on 'dynamic typing' (because I think
to that
it is trivial at this moment) and trying to increase type-resolution efficiency to make sure things just work nicely before the end of summer.
Regards, Ding Xiangfei
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hello Vicente, I have replied the comment on the proposal. Just in case, I will explain wwhat I have done recently here. I have make the part of the implementation working for the bitonic sorter example. Here is the link to the source code: https://gist.github.com/dingxiangfei2009/4970b62159cd1dca1868. I was not aware of the wait_for_all issue, so that one was re- implemented for illustrative purpose. Besides, then() method was not implemented, so a rudimentary implementation was used to replace that method. I also read the documentation on boost::optional and wrote a skeleton for optional monad. I was not clear whether there was a proposal for expected class, but I indeed found an implementation written by ptal on github. I took it as a reference. I hope that you can give some feedback on this sample code, what are the improvements to be made and what I have overlooked, etc. Thank you very much. Have a nice day. Regards, Ding Xiangfei
Le 27/03/14 02:45, Ding Xiangfei a écrit :
Ding Xiangfei
writes: Vicente J. Botet Escriba
writes: Hello, Vincete,
Thank you for the previous advice. Based on the ideas I had, I have written a draft proposal for this
Le 17/03/14 08:46, Ding Xiangfei a écrit : project. The Google Doc link is as follow:
SFo9IhPvfcwNSrwVEey9Pl9V9ftmZDPzrqO4/edit?usp=sharing
As the proposal is not final and I am still thinking about any new
ideas about monads, I would like to invite you for comments and evaluation on
the manageability and viability of this project.
Besides, I also added some experimental features that I would like to make during (hopfully) or after this summer. Comments on these features are also appreciated.
Hi,
there is something I find incoherent on the prose. Fisrt you say "the conception of monads allows functional programming languages to perform a sequence of instructions just as imperative languages. Last you say that "monads will simplify function chaining and exception handling when the code is written in a functional fashion".
C++ is a multi-paradigm language that supports already the imperative style and a clean exception handling machinery. How monads can help C++? Why it would be worth to write programms in C++ in a functional monadic style? To be able to perform a sequence of instructions? C++ has already all that. Why monads style will be useful in C++?
How do you plan to "simplify type resolution and compile time"?
Could you tell more about "dynamic typing of monads"?
Could you elaborate on the operations the monads you plan to provide will support? In addition to monad operations do you plan to provide other? e.g. what list operations? Waat do you mean by asynchronous function chaining? Error-handling?
Could you show an example of user code making use of monads interface?
Could you show an example of developer code making a type behave as a monad? Do you plan to use CRTP? Do you plan to use dynamic polymorphism?
What kind of performance would you evaluate? And to which alternative would you compare? Do you have already an idea of the bechmarks 1 and 2?
Having a concept without associated algorithms is not too useful. Do you have examples of algorithms that build on top of the monads interface?
Do you think that you will be able to finish with a Boost ready for review library at the end of the program?
Globally your proposal could be improved a lot by adding more detail.
HTH, Vicente
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hello Vicente,
Thank you very much for your valuable advice. As I am amending the proposal I will give some examples of the interface and algorithms running on it. In order to make the project more manageable, I decided not to go too ambitious and trimmed out the part on 'dynamic typing' (because I think that it is trivial at this moment) and trying to increase type-resolution efficiency to make sure things just work nicely before the end of summer.
Regards, Ding Xiangfei
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hello Vicente, I have replied the comment on the proposal. Just in case, I will explain wwhat I have done recently here.
I have make the part of the implementation working for the bitonic sorter example. Here is the link to the source code: https://gist.github.com/dingxiangfei2009/4970b62159cd1dca1868.
I was not aware of the wait_for_all issue, so that one was re- implemented for illustrative purpose. Besides, then() method was not implemented, so a rudimentary implementation was used to replace that method.
I also read the documentation on boost::optional and wrote a skeleton for optional monad. I was not clear whether there was a proposal for expected class, but I indeed found an implementation written by ptal on github. I took it as a reference.
I hope that you can give some feedback on this sample code, what are the improvements to be made and what I have overlooked, etc.
Thank you very much. Have a nice day.
Regards, Ding Xiangfei
Hi Ding, it is too late to improve the proposals. We could continue the discussion once the slots of Boost are know and the projects assigned. Best, Vicente
Vicente J. Botet Escriba
Hi Ding,
it is too late to improve the proposals.
We could continue the discussion once the slots of Boost are know and the projects assigned.
Best, Vicente
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Dear Vicente, Since I am very interested in this project and am quite free this summer, I think I will just go ahead even without GSOC. May I have your reviews, comments or advice on this project or the code? Is there anything I have look out for and improve? Regards, Ding Xiangfei
Vicente J. Botet Escriba
writes: Dear Vicente,
Hi,
Since I am very interested in this project and am quite free this summer, I think I will just go ahead even without GSOC. May I have your reviews, comments or advice on this project or the code?
We are waiting to see if there is an student selected by GSoC for this
Le 18/04/14 11:27, Ding Xiangfei a écrit : project. If you want to work on this project independently of GSoC, I suggest you contact me directly.
Is there anything I have look out for and improve?
There were a lot of good proposal and not too many mentors.
Best, Vicente
participants (2)
-
Ding Xiangfei
-
Vicente J. Botet Escriba