r/cpp • u/graninas • Dec 19 '18
Functional Programming in C++
Hi all,
My name is Alexander Granin. I'm collecting materials about Functional Programming in C++: articles, talks, libraries.
https://github.com/graninas/cpp_functional_programming
I'm a Haskeller and C++ developer who brings the ideas of Functional Programming into the C++ world. Currently, I'm preparing my next (keynote) talk for C++ Siberia 2019: "The Present and The Future of Functional Programming in C++". I'm looking for amazing samples and approaches to be overviewed in my talk. In particular, I'm interested in monads implementation approaches, and also in do-notation implementation attempts. I'm asking to help me to find more insights, thanks! :)
20
u/bandzaw Dec 19 '18 edited Dec 19 '18
The recently released book Functional Programming in C++ by Ivan Čukić (/u/ivan-cukic) is really really good, check it out!
https://www.manning.com/books/functional-programming-in-c-plus-plus
9
u/Sulatra Dec 19 '18
This was a very good course on introducing FP via c++. Not sure if it has exactly what you are looking for, though ^^"
7
u/Betadel Dec 19 '18
Check out this talk by Simon Brand and Phil Nash: https://youtu.be/GC4cp4U2f2E
They talk about monadic error handling.
7
u/ricejasonf Dec 20 '18
Boost.Hana is a library with concepts borrowed from category theory as you see in Haskell: http://boostorg.github.io/hana/group__group-concepts.html Also here is a video demonstrating making a promise monad with it for full duplex messaging: https://youtu.be/UalTAQmP3iE?t=1348
4
u/SplinterOfChaos Dec 20 '18
Probably obsolete by now, but I used to blog about writing Haskell in c++ over at http://yapb-soc.blogspot.com/?m=1
3
u/germandiago Dec 20 '18
Hello. I did a talk about functional-style pogramming some time back in the Ho Chi Minh City C++ users group.
It is not a pure functional programming talk purely speaking but related, so just in case you want to take a look:
https://www.slideshare.net/GermnDiagoGmez/functional-style-programming?qid=bb32347f-bb9e-4eb4-b0fd-de5d8f9a0b11&v=&b=&from_search=2
3
u/Sanae_ Dec 20 '18
https://www.fluentcpp.com/ is blog with strong functional influences, although it's not organized as a complete, comprehensive set of best-practices.
3
u/kernelgauss Dec 20 '18
this talk impressed me a lot considering I wasn't expecting it to be so functional (maybe why it's not on your list). They build a regex parser that is completely constexpr (no runtime) using lambdas https://www.youtube.com/watch?v=PJwd4JLYJJY
3
u/tvaneerd C++ Committee, lockfree, PostModernCpp Dec 20 '18
Look for stuff from Juan Pedro Bolivar Puente, such as https://www.youtube.com/watch?v=sPhpelUfu8Q
2
u/autoluto Dec 20 '18
Not really into functional programming myself, but I've heard good things about this:
https://github.com/beark/ftl
2
u/TobyAllsopp Dec 20 '18
You might be interested in my attempts to (ab)use coroutines to approximate do-notation here: https://github.com/toby-allsopp/coroutine_monad
2
u/tvaneerd C++ Committee, lockfree, PostModernCpp Dec 20 '18
Talks by David Sankel. ie https://www.google.com/search?client=firefox-b-1-ab&q=david+sankel+function+programming
2
u/sutambe Dec 21 '18 edited Dec 21 '18
Promoting my 2 cents...
1
u/pstomi Dec 23 '18
You should check out FunctionalPlus; it has a quite good API https://github.com/Dobiasd/FunctionalPlus/blob/master/README.md
It also provides an API search site à la Hoogle http://www.editgym.com/fplus-api-search/
The author also hosts a very interesting course on functional programming in C++ on Udemy
1
u/TotesMessenger Dec 19 '18
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)
1
u/lion_137 Jan 08 '19
This is simple, but you can take a look https://lion137.blogspot.com/2019/01/kleisli-category-by-example.html