GitPedia
evhub

evhub/coconut

Simple, elegant, Pythonic functional programming.

30 Releases
Latest: 5mo ago
Coconut v3.2.0v3.2.0Latest
evhubevhub·5mo ago·December 31, 2025
GitHub

Compiler Features

  • [Support Python 3.14 #873](https://github.com/evhub/coconut/issues/873): Full support for Python 3.14, including compatibility with the new interpreter changes and native t-string support.

🐛 Bugfixes

  • [Cannot use Coconut 3.1.2 as Jupyter kernel with default installation #865](https://github.com/evhub/coconut/issues/865): Fixed Jupyter kernel installation and registration issues.
  • [IsADirectoryError while importing module #861](https://github.com/evhub/coconut/issues/861): Fixed package import hook to properly handle directory imports.
Coconut v3.1.2v3.1.2
evhubevhub·1y ago·September 1, 2024
GitHub

📋 Changes

  • #851, #852: Fixed comments inside of parentheses in the Jupyter kernel.
  • #846: `reduce`, `takewhile`, and `dropwhile` now support keyword arguments.
  • #848: Class and data patterns now support keyword argument name elision.
  • #847: New pattern-matching syntax for matching anonymous named tuples.
  • #843: Added compiler warnings for (some cases of) undefined variables.
Coconut v3.1.1v3.1.1
evhubevhub·2y ago·June 9, 2024
GitHub

📋 Changes

  • #833: New `case def` syntax for more easily defining pattern-matching functions with many patterns.
  • #811: New `f(name=)` syntax as a shorthand for `f(name=name)`, replacing the now deprecated `f(...=name)` syntax.
  • #836: New `CoconutWarning` built-in used for Coconut runtime warnings.
  • #837: Coconut will now warn about implicit string concatenation and disable it completely with `--strict`.
  • #718: Coconut will now warn about use of `addpattern def` without a prior `match def`. This was a previously-supported feature to make pattern-matching functions with many patterns easier to write, but the new recommended way to do that is now via `case def`.
  • #785: Initial [pyright](https://github.com/microsoft/pyright) support via the `--pyright` flag.
  • #839, #840: Fixed some f-string parsing issues.
  • #834: Fixed `len` of empty `zip` objects.
  • + 2 more
Coconut v3.1.0v3.1.0
evhubevhub·2y ago·March 2, 2024
GitHub

📋 Changes

  • #814: Changes to statement lambda scoping rules, including capturing names introduced in the surrounding expression.
  • #618: Changes to handling of pattern-matching function defaults including support for e.g. `match def f(x, y=x) = (x, y)`.
  • #809: New array concatenation implicit partials (e.g. `[. ; a]`).
  • #823: New `(x := .)` implicit partial syntax (only available in pipes).
  • #807: New `lift_apart` built-in combinator.
  • #813: New `(if)` operator function.
  • #826 (thanks @JayXon!): Better universalization and `fmap` support for `bytes` and `bytearray`.
  • #816: Support for `xarray` to match existing `numpy`/`pandas` support.
  • + 8 more
Coconut v3.0.4v3.0.4
evhubevhub·2y ago·November 28, 2023
GitHub

📋 Changes

  • #784: `where` statements now use temporary variable names to limit the scope of contained assignments.
  • #795: New `async_map` function utilizing `anyio` to work with `asyncio` or `trio`.
  • #793: New `mapreduce`, `collectby.using_threads`, `collectby.using_processes`, `mapreduce.using_threads`, and `mapreduce.using_processes` built-ins.
  • #787: Support for `.method[index]` implicit partials.
  • #749, #792: Some built-ins have been renamed for clarity (the old names will still work unless `--strict` is passed). Specifically:
  • `recursive_iterator` -> `recursive_generator`
  • `parallel_map` -> `process_map`
  • `concurrent_map` -> `thread_map`
  • + 9 more
Coconut v3.0.3v3.0.3
evhubevhub·2y ago·July 29, 2023
GitHub

📋 Changes

  • #738: New `and_then` and `and_then_await` built-ins for async function composition.
  • #763: Lambdas now support fat arrows (`x => x`) as an alternative to skinny arrows (`x -> x`) to better distinguish them from type annotations. Skinny arrow lambdas will be deprecated at some later date.
  • #756: Coconut now fully supports Python 3.12's enhanced `f`-string syntax on all targets.
  • #773: `f`-strings with no expressions in them (e.g. `f"why does this have an f"` will now show a warning by default and an error on `--strict`.
  • #761: `--line-numbers` are now on by default. Pass `--no-line-numbers` to turn them off.
  • #768 (thanks @kxmh42!): Automatic compilation now uses a cache directory rather than compiling files in-place; additionally, automatic compilation options can now be set via `coconut-run`.
  • #767: New `--target psf` support for targeting all versions not considered end-of-life.
  • #765 (thanks @rtbs-dev!): New `coconut --jupyter install` command for easily installing all Jupyter kernels added as an alternative to the existing `coconut --jupyter` syntax.
  • + 6 more
Coconut v3.0.2v3.0.2
evhubevhub·3y ago·May 30, 2023
GitHub

📋 Changes

  • #753: `async with for` loops provide a simple syntax for implementing the recommended pattern for handling `async` generators.
  • #752: `typing` imports will redirect to `typing_extensions` whenever possible to ensure you always get the latest implementation of `typing` objects on all versions.
  • #754: `async` generators and some related utilities will now be automatically backported to 3.5 via the `async_generator` library.
  • #748: Certain confusing Unicode operator alternatives removed.
  • #750: `coconut.convenience` renamed to `coconut.api` (`coconut.convenience` is still available as an alias for backwards compatibility).
  • #751: Coconut in `xonsh` will no longer throw an error in certain situations.
  • #755: Due to a documentation rendering issue, previous 3.0.x releases weren't getting their documentation rendered successfully.
Coconut v3.0.1v3.0.1
evhubevhub·3y ago·May 25, 2023
GitHub

📋 Changes

  • #743: New `f(...=long_name)` syntax as a shorthand for `f(long_name=long_name)`.
  • #744: `f ..> g` will now preserve the signature of `f` when inspected using `inspect.signature`.
  • #736: `fmap` will now raise `TypeError` rather than falling back to a default implementation when it encounters an unknown type. For backwards compatibility, the old behavior can be recovered with `fmap$(fallback_to_init=True)`.
  • #737: `fmap` now works properly on `multiset`.
  • #746: Syntax errors produced when using Coconut's Jupyter kernel will now present themselves nicely rather than causing an error.
  • #745 (thanks @Starwort!): `xonsh` will no longer fail on semicolon-seperated commands when using the Coconut extension.
  • #739 (thanks @yggdr!): Compiling a single directory in `--stand-alone` mode will now properly make use of `--jobs`.
  • #742 (thanks @kloczek!): Fixed a deprecation warning when installing Coconut.
Coconut v3.0.0v3.0.0
evhubevhub·3y ago·May 2, 2023
GitHub

📋 Changes

  • #714: `set` patterns now work like `dict` patterns where they allow extra keys, such that `{1, 2}` will match `{1, 2, 3}`. To get back the strict behavior, use the `{1, 2, 3, *()}` pattern. Coconut will warn you if your code contains set patterns without an explicit strictness marker.
  • #707: the precedence of implicit function application has been changed to be compatible with implicit coefficients, such that `f x2` is now equivalent to `f(x2)` rather than `f(x)**2`. Coconut will warn you if your code contains expressions with new precedence.
  • #733: `.$[]` will now only default to using an existing `__getitem__` if the object is registered as a `collections.abc.Sequence`. `__iter_getitem__` will still always be used. Lets you do things like `{"k": "v"}$[0]`.
  • #730: `obj.` syntax as a shorthand for `getattr$(obj)` deprecated.
  • #732: `--jobs` now defaults to `sys` rather than `0`.
  • #707: New implicit coefficient syntax! Polynomials are just `a x**2 + b x + c`, with support for single variable names and numeric constants as coefficients.
  • #731: New `copyclosure def` functions that copy their closures on function creation, allowing them to e.g. hold on to loop variables.
  • #709: `(+)` syntax in a typing context now yields a `typing.Protocol` that requires supporting that operator.
  • + 12 more
Coconut v2.2.0v2.2.0
evhubevhub·3y ago·December 30, 2022
GitHub

📋 Changes

  • #694: New `multiset` built-in based on `collections.Counter`, including new multiset literal syntax (`m{1, 1, 2, 3, 3, 4}`).
  • #691: New `Expected` built-in based on Haskell's `Either`, plus new `safe_call` built-in that calls a function while collecting any errors into an `Expected`. Additionally, the `of` built-in has been renamed to `call` (`of` is still available as a deprecated alias when compiled without `--strict`).
  • #701: New `windowsof` built-in for iterating over sliding windows of the given iterable.
  • #688: New `cartesian_product` built-in as an enhanced version of `itertools.product` including `numpy` support.
  • #690: New `cycle` built-in as an enhanced version of `itertools.cycle`.
  • #704, #703, #702, #693, #692: Lots of improvements to existing built-ins:
  • `map` now supports a `strict=True` keyword-only argument that works as in `zip`.
  • `flatten` now supports a `levels` argument for how many levels to flatten.
  • + 17 more
v2.1.1 [The Spanish Inquisition]v2.1.1
evhubevhub·3y ago·November 14, 2022
GitHub

📋 Changes

  • #682: Coconut no longer errors out on Python 3.11.
  • #677: New type parameter syntax following [PEP 695](https://peps.python.org/pep-0695/)! For example: type a generic function as `def ident[T](x: T) -> T = x`.
  • #679: Error and logging output is now colored on terminals that support it.
  • #678: Non-`mypy` type checkers should now have an easier time type-checking Coconut code.
  • #680: New `async (...) -> ...` and `(..., **P) -> ...` enhanced type annotation constructs for Callables following [PEP 677](https://peps.python.org/pep-0677/).
  • #644: `f = async def x -> x` async statement lambda syntax now supported.
  • #624: `x |> (.+1)` syntax now produces better optimized compiled Python.
  • #681: `case`/`match` syntax now deprecated on `--strict` in favor of Python 3.10 `match`/`case` syntax.
v2.1.0 [The Spanish Inquisition]v2.1.0
evhubevhub·3y ago·October 25, 2022
GitHub

📋 Changes

  • #4, #674: Coconut now supports custom operators! See the documentation for more information on how to declare, define, and use custom operators.
  • #147: Very substantial performance improvements (up to 100x) when compiling small quantities of code (e.g. at the interpreter, in Jupyter notebooks, when using `xonsh`, etc.). Compile times for large files should be unchanged.
  • #673: New `multi_enumerate` built-in for enumerating multi-dimensional arrays (e.g. `numpy` arrays).
  • #385: Universalized imports no longer trigger `mypy` errors.
  • `xonsh` support updated to the latest `xonsh` version, should now be enabled by default without requiring `xonsh install coconut`, and should now be substantially faster.
  • #672: New `in <expr>` pattern for easier containment checking in pattern-matching.
  • #556: Coconut now respects `NOQA`/`noqa` comments when showing warnings for unused imports in `--strict` mode.
v2.0.0 [How Not to Be Seen]v2.0.0
evhubevhub·3y ago·September 26, 2022
GitHub

📋 Changes

  • #605: Coconut pattern-matching is now fully unified with Python 3.10 pattern-matching: pattern-matching always works the same way regardless of where it is used, always uses Python 3.10 rules, but also always supports all additional Coconut pattern-matching features. Some implications of this:
  • Coconut now fully supports [class patterns](https://peps.python.org/pep-0622/#class-patterns) everywhere, including in pattern-matching function definition and destructuring assignment.
  • As a result, `x is int` type-checking syntax is now deprecated in favor of using the `int(x)` class pattern. For cases where there is no rewriting as a class pattern, ``x `isinstance` int`` syntax is also supported.
  • Pattern-matching for dictionaries has been changed so that `{"a": a}` now matches a dictionary with _at least_ `"a"` as a key rather than exactly `"a"` as its only key to be consistent with Python 3.10. Coconut will warn if such syntax is detected and suggest the explicit `{"a": a, _}` or `{"a": a, {}}` syntax instead.
  • #639: Coconut `data` types no longer support adding or multiplying them like tuples unless explicitly added via `__add__`/`__mul__` methods.
  • #623: `fmap` over a Mapping (e.g. `dict`) now does a normal map instead of a `starmap`. Thus, you'll need to do `fmap$(def ((k, v)) -> (new_k, new_v))` instead of `fmap$((k, v) -> (new_k, new_v))`. Old behavior can also be recovered with `fmap$(starmap_over_mappings=True)`.
  • #615: `($[])` spelling for the iterator slicing operator function has been removed in favor of `.$[]` and the normal getitem operator has been added as `.[]`.
  • #613: Precedence of the function composition operator `..` has been lowered such that `f x .. g y` is now equivalent to `(f x) .. (g y)` rather than `((f x) .. g) y`.
  • + 37 more
v1.6.0 [Vocational Guidance Counsellor]v1.6.0
evhubevhub·4y ago·November 6, 2021
GitHub

📋 Changes

  • #558, #601: Coconut now fully supports [Python 3.10 pattern-matching syntax](https://www.python.org/dev/peps/pep-0634/#class-patterns), including compiling Python 3.10 pattern-matching syntax to any Python version and mixing and matching between Python 3.10 pattern-matching and Coconut pattern-matching (including in destructuring assignment and pattern-matching function definition).
  • #566: Coconut can now specifically target Python `3.9`, Python `3.10`, and/or Python `3.11`.
  • #425 (thanks @ExpHP for the issue!): Coconut pattern-matching now supports view patterns that allow calling a function in pattern-matching and matching on the result.
  • #607: Coconut pattern-matching now supports infix patterns that allow calling a binary boolean function in pattern-matching and matching only if the return value is truthy.
  • #570: Coconut now supports an `@override` built-in that, when used to decorate a method, asserts that it is overwriting some method from a base class.
  • #582, #583 (thanks @aananko for the issue!): Coconut now supports a `flatten` built-in for flattening one layer of an iterable of iterables.
  • #574: Coconut now supports `reveal_type` and `reveal_locals` built-ins that will print the inferred type of the contained expression when compiled with `coconut --mypy`.
  • #421: Coconut now supports `yield def` function definition syntax for explicitly specifying that you want a generator function, regardless of whether a `yield` actually occurs somewhere in the function.
  • + 31 more
v1.5.0 [Fish License]v1.5.0
evhubevhub·5y ago·March 6, 2021
GitHub

📋 Changes

  • #545: Added support for embedding a Coconut interpreter for debugging; just `from coconut import embed; embed()`.
  • #562: All lazy lists are now reiterable.
  • #550: All enhanced built-ins are now reiterable when given an iterable.
  • #542: New `None`-aware pipe operators.
  • #105: New `zip_longest` built-in.
  • #552: Full [PEP 553](https://www.python.org/dev/peps/pep-0553/) (breakpoint built-in) support on all Python versions.
  • #531: Add support for `=` specifier in `f`-strings.
  • #508: Added `.multiple_sequential_calls()` context managers to `parallel_map` and `concurrent_map`.
  • + 12 more
v1.4.3 [Ernest Scribbler]v1.4.3
evhubevhub·6y ago·January 7, 2020
GitHub

📋 Changes

  • #527: Coconut once again builds properly on Python 2 (thanks @hasufell for the issue!)
  • #526: fixes `=` function definition returning string literals not working (thanks @vietspaceanh for the issue!)
  • attributes now work properly in implicit function application (e.g. `f b.x c.y`)
v1.4.2 [Ernest Scribbler]v1.4.2
evhubevhub·6y ago·December 9, 2019
GitHub

📋 Changes

  • #521: prevents Coconut from installing an incompatible version of `cPyparsing` by default
  • #515: prevents Coconut from installing `trollius` on Python 3 when doing `pip install coconut[all]` (thanks @DennisMitchell for the issue!)
  • #496, #506: `addpattern` now issues a warning if passed a non-pattern-matching function unless `allow_any_func=True` is passed (thanks @m-burst for the PR and @pavelbraginskiy for the issue!)
  • #517: simple implicit function application such as `f x y` is now supported
v1.4.1 [Ernest Scribbler]v1.4.1
evhubevhub·6y ago·August 8, 2019
GitHub

📋 Changes

  • #465: new `addpattern def` shorthand syntax (thanks @MichalMarsalek for the issue!)
  • #301, #504, #505: full support for Python 3.6 f-strings on all targets including (thanks @m-burst for the PR!)
  • #323: added support for `|**>` kwargs pipes (thanks @ArneBachmann for the issue!)
  • #490: new `(assert)` operator function (thanks @arnauorriols for the issue!)
  • #503: added support for Python 3.8 positional-only arguments (thanks @pavelbraginskiy fo the issue!)
  • #483: `fmap` now works on numpy arrays (thanks @hoishing for the issue!)
  • #494: added support for pattern-matching in `data` definitions (thanks @arnauorriols for the issue!)
  • #493: added truncation for long MatchError messages (thanks @arnauorriols for the issue!)
  • + 4 more
v1.4.0 [Ernest Scribbler]v1.4.0
evhubevhub·7y ago·August 16, 2018
GitHub

📋 Changes

  • #320: added import hook to automatically compile imported Coconut files (thanks @ArneBachmann!)
  • #347: added `where` clauses
  • #270: added a `memoize` decorator (thanks @iamrecursion!)
  • #403: added a `TYPE_CHECKING` constant
  • #409: added support for ``M `bind` x -> y`` syntax
  • #419: `data` type equality is now typed (thanks everyone in #418!)
  • #331: support negative pattern-matching with `match ... not in ...`
  • #411: `count` now supports a step size of `0`
  • + 8 more
v1.3.1 [Dead Parrot]v1.3.1
evhubevhub·8y ago·October 23, 2017
GitHub

📋 Changes

  • #326: fixed Jupyter kernel installation (thanks, @auscompgeek!)
  • #333: fixed `--watch` placing compiled files in the wrong location (thanks, @dileep-kishore!)
  • #337: fixed `--jupyter console` on Windows (thanks, @mlarocca!)
  • #317: fixed numerous MyPy errors (thanks, @ArneBachmann!)
v1.3.0 [Dead Parrot]v1.3.0
evhubevhub·8y ago·September 4, 2017
GitHub

📋 Changes

  • #220: new function composition pipe operators (thanks, @cgarciae!)
  • #243: new none-aware operators
  • #200: new enhanced type annotation syntax (thanks, @fredcallaway!)
  • #257: `data` types now support default arguments
  • #276: `data` types now support type annotations (thanks, @jonathanplatzer!)
  • #275: pipes and infix calls now support lambdas in them
  • #256: new string destructuring pattern-matching
  • #267: improved dictionary pattern-matching (thanks, @cgarciae!)
  • + 25 more
v1.2.3 [Colonel]v1.2.3
evhubevhub·9y ago·May 15, 2017
GitHub

📋 Changes

  • #237: new `fmap` built-in that preserves data types (thanks, @hasufell!)
  • #214: `data name(*args)` syntax now supported
  • #227: `data from` syntax for data type inheritance
  • #232: `--no-tco` option to disable tail call optimization (also implied by `--mypy`)
  • #228: `.method(**kwargs)` implicit partial now supported
  • #231: `.[a:b, c:d]` implicit partial now supported (thanks, @cgarciae!)
  • #226: PEP 542 dotted function names now supported
  • #221, #234: Jupyter kernel issues resolved (thanks, @cgarciae!)
  • + 4 more
v1.2.2 [Colonel]v1.2.2
evhubevhub·9y ago·February 20, 2017
GitHub

📋 Changes

  • Version-dependent requirements are now properly installed when installing Coconut (thanks @Nexus6!)
  • Jupyter kernel works properly on Python 2 (thanks @DavidPratten!)
  • Jupyter kernel performance significantly improved (thanks @cgarciae!)
  • MyPy support is faster and emits fewer spurious errors
  • Fails nicely on missing optional dependencies (thanks @Nexus6!)
v1.2.1 [Colonel]v1.2.1
evhubevhub·9y ago·February 15, 2017
GitHub

📋 Changes

  • `--mypy` flag for automatic type-checking (including real-time in the REPL)
  • Support for Python type annotations on all versions
  • New enhanced partial application (e.g. `func$(?, y)`) (thanks @Sitwon!)
  • Tail recursion elimination added in addition to tail call optimization
  • Support for `%magic` commands on Coconut's Jupyter kernel
  • Syntax highlighting for Coconut's Jupyter kernel
  • Support for keyword and star arguments in pattern-matching function definition
  • Support for pattern-matching in statement lambdas (e.g. `def (x is int) -> x`)
  • + 11 more
v1.2.0 [Colonel]v1.2.0
evhubevhub·9y ago·September 24, 2016
GitHub

📋 Changes

  • removed `@recursive` (now does auto tco)
  • function composition (`..`) precedence changed
  • removed `--autopep8` flag
  • automatic tail call optimization
  • statement (multiline) lambdas
  • command-line syntax highlighting
  • `--jobs` flag
  • assignment function notation
  • + 5 more
v1.1.1 [Brontosaurus]v1.1.1
evhubevhub·9y ago·July 6, 2016
GitHub

📋 Changes

  • Adding a `--watch` flag (#99, #106, thanks @Boscillator!)
  • Improving Jupyter / IPython console autocompletion (#114)
  • Adding methodcaller implicit partial (#112)
  • Adding links to 3rd party Vim and Emacs highlighters (thanks, @manicmaniac and @NickSeagull!)
  • Adding `pip install coconut[...]` as a way to install optional dependencies
v1.1.0 [Brontosaurus]v1.1.0
evhubevhub·10y ago·June 24, 2016
GitHub

📋 Changes

  • Adding `addpattern` and `prepattern` built-ins (#92, #103)
  • Changing recommended file extension from `.coc` to `.coco` (#88)
  • Making interpreter print the result of an expression (#100, thanks @Boscillator!)
  • Fixing IPython / Jupyter kernel support (#97)
  • Adding support for guards in pattern-matching function definition (#98)
  • Upgrading to `pyparsing` 2.1.5
v1.0.0 [Albatross]v1.0.0
evhubevhub·10y ago·June 17, 2016
GitHub

[Albatross](https://en.wikipedia.org/wiki/Albatross_%28Monty_Python_sketch%29) is the first production release (v1.0.0) of the Coconut programming language. No new features have been added since Pinnate (v0.4.1), although there have been major stability improvements. For documentation, see our new website at http://coconut-lang.org.

[P]innatev0.4.1
evhubevhub·10y ago·April 11, 2016
GitHub

Pinnate (v0.4.1) is the first candidate release for v1.0.0. The language has become relatively stable and is unlikely to change much until a release is selected for v1.0.0. Massive changes have been made to Coconut since Odisha (v0.3.6). If you've been following Coconut development, you should read the new [tutorial](http://coconut.readthedocs.org/en/master/HELP.html) and go over the new [documentation](http://coconut.readthedocs.org/en/master/DOCS.html) to familiarize yourself with all the changes. _[Pinnate](https://en.wikipedia.org/wiki/Pinnation) is the type of leaf on the Coconut palm._

[O]dishav0.3.6
evhubevhub·10y ago·January 11, 2016
GitHub

📋 Changes

  • New: `--package` or `-p` and `--standalone` or `-a` flags for forcing the type of compilation to perform
  • `--print` or `-p` is now `--display` or `-d` (`-d` is no longer an alias of `--debug`)
  • Fixes issues in `data` mutability and augmented assignment
  • Significantly increases compilation speed