git clone git://github.com/mkoppanen/php-zmq.git
cd php-zmq
phpize && ./configure
make && make install
Finally add the following line to your php.ini:
{-# LANGUAGE ExistentialQuantification #-} | |
module Beauforma where | |
import qualified Data.Map.Strict as M | |
data Event = | |
GuestBookedAppointment { | |
appointmentId :: Guid, | |
guestId :: GuestId, | |
appointmentDateAndTime :: DateTime, |
<?php | |
final class FuckYouPHPTest extends \PHPUnit_Framework_TestCase { | |
/** @test */ | |
public function should_fail () { | |
new WantsAString(new NotAString()); | |
// Fails as expected | |
} | |
/** @test */ |
module Lib where | |
import Data.List.Split | |
import System.Random | |
a4by4Maze :: Maze | |
a4by4Maze = Maze [ | |
[(╝),(╦),(╝),(╣)], | |
[(╩),(╣),(╗),(╝)], | |
[(═),(╩),(║),(╝)], |
git clone git://github.com/mkoppanen/php-zmq.git
cd php-zmq
phpize && ./configure
make && make install
Finally add the following line to your php.ini:
module Workflow where | |
import Data.Maybe | |
import Data.Set | |
newtype State = State String deriving(Ord, Show, Eq) | |
type States = Set State | |
data Action = Action String deriving(Eq, Show) | |
type Workflow = [Transition] | |
data Transition = Transition { |
module MonoidalFizzBuzz where | |
import Data.Monoid | |
import Data.Maybe | |
-- based on @mittie https://twitter.com/mittie/status/798257339736453120 | |
monoidalFizzbuzz = zipWith fromMaybe numbers strings | |
where | |
fizzes = cycle [Nothing, Nothing, Just "Fizz"] | |
buzzes = cycle [Nothing, Nothing, Nothing, Nothing, Just "Buzz"] |
<?php | |
final class Foo { | |
public function bar (AnemicObject $object) { | |
switch (true) { | |
case $object instanceof Alfa: | |
// do alpha shizzle | |
case $object instanceof Beta: | |
// do beta shizzle | |
} |
<?php | |
// method overloading example (not possible in php) | |
final class SomeEventListener { | |
public function when(EmployeeWasHired $event) { | |
// set a salary | |
} | |
public function when(EmployeeWasPromoted $event) { | |
// increase salary | |
} |
<?php | |
// duck typing | |
final class Foo { | |
public function bar ($object) { | |
$object->quack(); | |
} | |
} | |
// Because we know nothing about $object, it's only by calling quack that we can | |
// tell whether object supports quack() |
<?php declare(strict_types = 1); | |
function volume (array $levels) { | |
return array_sum( | |
zipWith( | |
'subtract', | |
zipWith( | |
'min', | |
scanl('max', $levels), | |
scanr('max', $levels) |