• Stars
    star
    124
  • Rank 287,311 (Top 6 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 10 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lambdalicious - Experiments in Elegant Functional Programming in PHP

Lambdalicious

Experiments in Elegant Functional Programming in PHP.

Recursive Percy

Build Status

Read Higher Order Programming for an introduction.

Design Goals

  • LISPy Love for Lists!
  • Higher order Happiness!
  • Posh Partial Application!
  • Gloriously Global!

Example

<?php
atom(@jim, @jenny, @jack, @jules);
$accounts = l(
    pair(jim, 100),
    pair(jenny, 30),
    pair(jack, -50),
    pair(jules, -43)
);

$negate = multiply(-1, __); // __ is a partial application placeholder
$isnegative = lt(__, 0); // lt is short for "less than"
$balance = tail; // Alias tail(), which returns the second item in a pair
$totalOutstanding = pipe( // think *nix pipes and filters
    map($balance, __), 
    filter($isnegative, __), 
    reduce(add, __, 0),
    $negate
);

assert(isequal(
    $totalOutstanding($accounts),
    93
));

Find more in the examples folder, or read the tests.

FAQ

What is this all about?

Read the The Little Schemer. Or learn LISP (or Clojure or some variant). There's also some Erlang-ish ideas in there.

Wait but why?

Why did I try to build a radio when I was ten? Why did I take apart my father's computer when I was eleven?

But but but... Global functions? Global constants?

You're very observant! Don't think of it as polluting the global namespace. Think of it as cleaning up the global namespace!

Are there unit tests?

Yes, check out the /topics directory. These are omikron topics. To run them, use this command:

bin/omikron topics

Can you backport it to older PHP versions?

Boring, next question please.

Wouldn't this all be a lot easier and more elegant using HHVM/Hack?

I know right?

Should I use it in production?

Yes! Be a pioneer, be an early adopter, be an innovator! Show your boss you can take risks on company time! You are a strong individual who makes your own decisions, even in the face of constant change and breakage! You are a legend!

Really?

I don't think you're ready for this curry cuz my codez is too Lamdalicious for ya babe.

I want to contribute!

I like you already!

Recursive Mustache

More Repositories

1

15yearsddd

Domain-Driven Design: The First 15 Years
66
star
2

uptodocs

UpToDocs scans a Markdown file for PHP code blocks, and executes each one in a separate process.
PHP
57
star
3

jdump

J!Dump is a very easy to use debugging extension for Joomla developers and template designers. Download links below.
PHP
43
star
4

symfony-live-2014

Workshop: "Domain-Driven Design for Symfony Developers" at Symfony Live London 2014
PHP
42
star
5

classfunctions

Functions to manipulate PHP class names
PHP
34
star
6

extract-till-you-drop

Code for my refactoring talk "Extract Till You Drop"
PHP
15
star
7

jira-issues-in-github

Turn Jira issue numbers (like XX-123) in GitHub into links.
JavaScript
15
star
8

DomainTools

Tools for Domain Driven Design
PHP
11
star
9

maintainable-regex

Simple tutorial on how to write maintainable, composable, regular expression patterns. Read the commits from oldest to newest to see how we build it up.
PHP
9
star
10

skiphaltprint

FizzBuzz in Haskell by Embedding a Domain-Specific Language by Maciej Pirog
Haskell
6
star
11

magictree

Because magic.
PHP
4
star
12

playingwithprojections-php

Playing With Projections
PHP
4
star
13

playingwithprojections-haskell

Playing with Projections - Haskell
Haskell
4
star
14

kildoc

Declarative interfaces > documentation
PHP
4
star
15

speakingjenkins

Command line PHP app that announces the status of a Jenkins/Hudson CI build using text-to-speech.
PHP
2
star
16

dddinphp.org

Domain-Driven Design in PHP
CSS
1
star
17

hedy-haskell

Hedy is a gradual programming language by @felienne.
Haskell
1
star
18

simple-timer

Simple countdown timer
1
star
19

socra

Haskell
1
star
20

stageclock

Stage Clock, built using 100% certified Stack Overflow Driven Development.
HTML
1
star