{"id":9755,"library":"fnc","title":"fnc - Functional Programming Utilities","description":"fnc is a Python library that provides functional programming utilities, primarily focusing on working with generators and iterable data. It offers curried versions of common functions like `map`, `filter`, and `pipe` for a more declarative style. The current version is 0.5.3, released in October 2021, and the project is in a maintenance mode with infrequent updates.","status":"maintenance","version":"0.5.3","language":"en","source_language":"en","source_url":"https://github.com/dgilland/fnc","tags":["functional programming","generators","iterators","pipe","curry","utilities"],"install":[{"cmd":"pip install fnc","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"pipe","correct":"from fnc import pipe"},{"note":"fnc.map is a curried function, unlike Python's built-in map. It's intended for use with `pipe` or by calling it with arguments sequentially, e.g., `fnc_map_double = map(lambda x: x * 2); result = fnc_map_double([1,2,3])`.","wrong":"map(lambda x: x*2, [1,2,3]) # using fnc.map without currying or pipe","symbol":"map","correct":"from fnc import map"},{"note":"Similar to fnc.map, fnc.filter is a curried function.","wrong":"filter(lambda x: x>0, [1,0,-1]) # using fnc.filter without currying or pipe","symbol":"filter","correct":"from fnc import filter"},{"symbol":"curry","correct":"from fnc import curry"}],"quickstart":{"code":"from fnc import pipe, map, filter, take\n\ndata = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\n# Example 1: Use pipe for a functional chain\nresult_pipe = pipe(\n    data,\n    map(lambda x: x * 2),     # Double each number\n    filter(lambda x: x > 10), # Keep only numbers greater than 10\n    take(3),                  # Take the first 3 results\n    list                      # Materialize the generator into a list\n)\n\nprint(f\"Result with pipe: {result_pipe}\") # Expected: [12, 14, 16]\n\n# Example 2: Curried map and filter manually\ndouble = map(lambda x: x * 2)\nodd = filter(lambda x: x % 2 != 0)\n\nprocessed_data = double(odd(data)) # Apply odd filter, then double\nprint(f\"Manual curried chain: {list(processed_data)}\") # Expected: [2, 6, 10, 14, 18]\n","lang":"python","description":"Demonstrates the use of `pipe` for chaining functional operations and how curried functions like `map` and `filter` are applied."},"warnings":[{"fix":"When importing `fnc.map` or `fnc.filter`, either alias them (e.g., `from fnc import map as fnc_map`) or ensure you understand their curried nature and use them accordingly, typically within a `pipe` call or by first applying the function argument.","message":"fnc's `map` and `filter` conflict with Python's built-in `map` and `filter`. The `fnc` versions are curried, meaning they expect to be called with arguments in stages (e.g., `map(func)(iterable)` or used within `pipe`), unlike the built-in versions which expect `map(func, iterable)`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Append `.list()` or `list()` around the final operation in your functional chain to materialize the results. Example: `pipe(data, ..., list)` or `list(some_fnc_operation(data))`.","message":"Most `fnc` utilities return generators or iterators. For immediate evaluation and to see concrete results, you must explicitly convert them to a list, tuple, or other materializable collection (e.g., `list(result)`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware that new issues or Python version incompatibilities might not be addressed immediately. It's generally stable for Python 3.6+, but extensive testing with newer Python versions is recommended for critical applications.","message":"The `fnc` library is in maintenance mode; the last release (0.5.3) was in 2021. While stable, active development and new features are not frequent. Consider this for long-term project planning or if cutting-edge functional features are required.","severity":"gotcha","affected_versions":"0.5.3 and previous"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure the final step in your functional chain or direct `fnc` call includes a materialization step, such as `list()`, `tuple()`, or `set()`. Example: `result = list(pipe(data, ...))`.","cause":"This often occurs when you forget to materialize the result of an `fnc` operation, which returns a generator. For example, trying to iterate over `map(...)` directly without `list()` or `tuple()`.","error":"TypeError: 'map' object is not iterable"},{"fix":"Understand that `fnc.map` and `fnc.filter` are curried. Use them in a `pipe` operation or by first providing the function argument, then the iterable: `fnc_map_double = map(lambda x: x * 2); result = list(fnc_map_double(data))`.","cause":"This can happen if you import `fnc.map` or `fnc.filter` but then attempt to use them with the syntax for Python's built-in `map` or `filter` (i.e., `map(func, iterable)` instead of `map(func)(iterable)` or `pipe(iterable, map(func))`). Python's built-in `map` function gets shadowed, and `fnc.map` is a curried function requiring a different call pattern.","error":"TypeError: 'builtin_function_or_method' object is not callable"}]}