c++boost.gif (8819 bytes)HomeLibrariesPeopleFAQMore

Boost.FC++

Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Table of Contents

1. Introduction, important definitions, and notes (Read this!)
2. Pure Functional Programming
3. Roadmap
4. Overview Examples
5. Direct Functoids
5.1. Issues with representing higher-order polymorphic functions
5.2. The past and the future
5.3. Defining a direct functoid
6. Indirect Functoids
6.1. Subtype-polymorphism
6.2. Relation to boost::function
7. Full Functoids
7.1. Currying
7.2. Infix Syntax
7.3. Lambda Awareness
7.4. Smartness
7.5. Return-type deduction
8. Effects and thunks
9. Lists and lazy evaluation
9.1. Interface to list
9.2. Writing lazy list functoids
9.3. Other details about lazy evaluation
10. Library
10.1. Nuts and bolts
10.2. Constants
10.3. Data types
10.4. Basic list functions
10.5. Haskell standard prelude
10.6. Operators
10.7. Currying, thunks, and effect combinators
10.8. General combinators
10.9. Functoid promotion
10.10. Other
10.11. Note about lambda/monads
11. Relationships with other libraries
11.1. Interfaces to STL
11.2. Relation to Boost
12. Lambda
12.1. Lambda in FC++
12.2. Naming the C++ types of lambda expressions
12.3. FC++ lambda versus boost::lambda
13. Monads
14. Applications
15. Performance
16. Limitations and future work
16.1. Limitations
16.2. Future work
17. Acknowledgements
18. To find out more...
Bibliography

1. Introduction, important definitions, and notes (Read this!)

FC++ is a library for doing functional programming in C++. The library provides a general framework to support various functional programming aspects, such as higher-order[1] polymorphic[2] functions, currying, lazy evaluation, and lambda. In addition to the framework, FC++ also provides a large library of useful functions and data types.

In FC++, we program with functoids, which are C++ classes or structs which overload operator() and obey certain other conventions. We will describe functoids in more detail in Section 5, Section 6, and Section 7. Functoids are simply our chosen representation for functions in C++; for now you may equate the terms "functoid" and "function" in your mind. Later we shall see what exactly a functoid is and why it is useful.

This document describes "Boost FC++". Prior to being "boostified", FC++ existed as a research project at Georgia Tech for a number of years [FC++]. This is the first document to describe the boostified version of FC++. It is important to note the changes made to the library between "FC++" and "Boost FC++", in order to understand the old documentation. The changes are mostly just a matter of naming conventions. In Table 1, we summarize the naming changes from FC++ to Boost FC++, by giving a sense of the general name changes as well as some particular examples. To avoid confusion, the reader of this document should at least be aware of this mapping before reading any of the prior documentation on FC++.

Table 1. Naming changes from FC++ to Boost FC++

Original FC++Boost FC++Example (orig)Example (Boost)
SomeFunctoidsome_functoid_typeEnumFromenum_from_type
someFunctoidsome_functoidenumFromenum_from
SomeType some_typeFull2 full2
SomeFunc_ some_func_x_typeBindM_ bind_m_x_type
NestedTypenested_typeArg1Typearg1_type
MiscMiscRT,LAM,COMP,...unchanged
MiscMiscElementType,LEType,Inv,Varvalue_type,LE,INV,VAR
MiscMiscRef,IRefboost::shared_ptr, boost::intrusive_ptr
MiscMisccurryNthunkN

The only other major change to the library is that now the fun_type class only takes one argument (the result type). That is, code which used to say

   template <class X, class Y>
   struct sig : public fun_type<X,Y,Something> {};
now reads
   template <class X, class Y>
   struct sig : public fun_type<Something> {};
See Section 5 for details.

Bibliography

[Jär&Pow03] Jaakko Järvi, Gary Powell, and Andrew Lumsdaine. The Lambda Library: unnamed functions in C++. Software: Practice and Experience . March, 2003.

[Jär&Pow01] Jaakko Järvi and Gary Powell. The Lambda Library: Lambda Abstraction in C++. October, 2001. Workshop on C++ Template Programming. 2. Tampa, Florida. .

[McN&Sma to appear] Brian McNamara and Yannis Smaragdakis. Functional Programming with the FC++ library. Journal of Functional Programming. to appear. Available from the FC++ web site.

[McN&Sma00] Brian McNamara and Yannis Smaragdakis. Static Interfaces in C++. October, 2000. Workshop on C++ Template Programming. 1. Erfurt, Germany. .

[McN&Sma03] Brian McNamara and Yannis Smaragdakis. August, 2003. DPCOOL. 1. Uppsala, Sweden. . Syntax sugar for FC++: lambda, infix, monads, and more. Available at the FC++ web site .

[Sie&Lum00] Jeremy Siek and Andrew Lumsdaine. Concept Checking: Binding Parametric Polymorphism in C++. October, 2000. Workshop on C++ Template Programming. 1. Erfurt, Germany. .

[Sma&McN02] Yannis Smaragdakis and Brian McNamara. FC++: Functional Tools for Object-Oriented Tasks. Software: Practice and Experience . August, 2002. A previous version of this paper is available from the FC++ web site.

[ReturnType] A uniform method for computing function object return types. Available at http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1454.html .



[1] A higher-order function is a function which takes another function as an argument or returns a function as a result.

[2] We use the term "polymorphism" to mean parametric polymorphism (e.g. templates). This is the usual definition in the sphere of functional programming. In object-oriented programming, the term "polymorphism" usually refers to dynamic dispatch (virtual function call). Please note the definition we are using. In contrast, a monomorphic function is a function which only works on one set of argument types.

Last revised: October 03, 2003 at 23:27:22 GMT