Created
October 25, 2015 18:00
-
-
Save dana-ross/d5dfcf4ac5e5888e4e24 to your computer and use it in GitHub Desktop.
Just monad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Just { | |
protected $value; | |
function __construct( $value ) { | |
$this->value = $value; | |
} | |
public static function of( $value ) { | |
return new self( $value ); | |
} | |
public function map( callable $fn ) { | |
return Just::of( $fn( $this->value ) ); | |
} | |
public function value() { | |
return $this->value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment