Skip to content

Releases: witchcrafters/quark

Elixir 1.11 & use guards instead of *_list

14 Mar 01:03
ce0465d
Compare
Choose a tag to compare

Includes:

compose_list and fix Elixir 1.4 warnings

27 Jun 06:11
Compare
Choose a tag to compare

Compose functions, from the head of the list of functions. The is the reverse
order versus what one would normally expect (left-to-right rather than
right-to-left).

Examples

  iex> sum_plus_one = compose_list([&(&1 + 1), &Enum.sum/1])
  ...> sum_plus_one.([1, 2, 3])
  7

Pointfree

12 Sep 07:00
Compare
Choose a tag to compare

Pointfree unary functions!

Allows defining functions as straight function composition (ie: no need to state the argument). Provides a clean, composable named functions. Also doubles as an aliasing device.

defmodule Foo do
  use Quark
  defx foo, do: Enum.sum |> succ
  defx bar, do: ((&Enum.sum/1) <~> succ).()
end

[1,2,3] |> Foo.foo
#=> 7

[1,2,3] |> Foo.bar
#=> 7

Pointfree n-ary functions (based on the first function in the body) is still coming πŸ˜„

v2.0.0

29 Aug 21:13
Compare
Choose a tag to compare

Nothing terribly major. The breaking change is that a number of top-level functions have moved into submodules, and there's now a handy top-level use macro.

Also modernized the deps, updated the docs, and altered the layout of the doctests for readability.

v1.0.0

02 Jan 21:06
Compare
Choose a tag to compare

πŸŽ‰ πŸŽ‰ πŸŽ‰ Happy New Year and a happy first Quark release! πŸŽ‰ πŸŽ‰ πŸŽ‰

Quark 1.0.0 has arrived! Having recently undergone mitosis from Witchcraft, we've fleshed out quite a few functional programming basics that we felt would be useful in Elixir.

Functional Overview

SKI combinators

Yes, now you too can define all of your algorithms in incomprehensible strings of s and k! Get your s k (k k) on! But seriously, a lot of this stuff is pretty useful. We've provided friendlier names at the top-level Quark module, so that you can write const, rather than having remember what k does.

BCKW combinators

The classic b, c, k, and w combinators of lore. Pretty much the same idea as with SKI, but some different functionality. And as usual, we've aliased the names at the top-level.

Fixed Point

Fixed point combinators, for helping with recursion. Several formulations are provided, but stick to fix (should be the most efficient at any given time, and thus somewhat more future-proof).

Compose

Compose functions to do convenient partial applications. Versions for composing left-to-right and right-to-left are provided, but the operator <|> is done "the math way" (right-to-left). Versions on lists also available.

Sequence

Really here for pred and succ on integers, by why stop there? This works with any ordered collection.

Curry

Functions

curry creates a 0-arity function that curries an existing function. uncurry applies arguments to curried functions, or if passed a function creates a function on pairs.

Macros

Why define the function before currying it? defcurry and defcurryp return fully-curried 0-arity functions.

Partial

πŸ‘‘ We think that this is really the crowning jewel of Quark. defpartial and defpartialp create all arities possible for the defined function, bare, partially applied, and fully curried. This does use up all the full arity-space for that function name, however.

Closing Remarks

We hope that you enjoy Quark! Please let us know if you have new feature requests.

With humanity,

~ Robot Overlord Inc.