Skip to content

Instantly share code, notes, and snippets.

@marcosh
marcosh / elm.md
Created January 15, 2016 19:49
ELM OR HOW I LEARNED TO LOVE FRONT-END DEVELOPMENT

Front-end development is evolving very rapidly, with new frameworks appearing and then declining very rapidly. Among the many options that a developer has for developing the graphical user interface of its web application, Elm steps out as one of the most original and most promising approaches. It combines the principles of reactive programming with the elegance of strongly typed functional programming, still providing a nice integration with javascript code.

In this talk Marco will present Elm digging into at a real project built with it, exploring the best features of the language and focusing on the architecture that naturally emerges building Elm applications, which is great for modularity, code reuse and testing.

<?php
namespace MyTestNamespace;
//relevant use clauses
use ...
final class AddItemIntegrationTest extends \PHPUnit_Framework_TestCase
{
public function testAddItem()
module Hanoi
import Data.Vect
data Peg
= First
| Second
| Third
-- TODO : can we do better here?

Characterize recursable data structures

Recursion

Recursion is a procedure that allows us to iterate through certain data structure. For example we can iterate through lists

sum : List Nat -> Nat
sum list =
@marcosh
marcosh / Application.hs
Created June 14, 2018 13:20
Web applications as profunctors
module Application where
import Data.Profunctor
newtype Application request response = Application {unApplication :: request -> IO response}
instance Profunctor Application where
dimap actOnRequest actOnResponse application = Application $ (fmap actOnResponse) . (unApplication application) . actOnRequest
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Graph where
import Control.Comonad
-- we need to separate `a` and `b` because `a` is covariant while `b` is contravariant => this is actually a profuctor
data PointedGraph moves b a = PointedGraph
@marcosh
marcosh / Boolean.php
Created January 16, 2020 11:16
Boolean implementation in PHP
<?php
declare(strict_types=1);
namespace Marcosh\PhpValidationDSL;
final class Boolean
{
/** @var Bool */
private $isTrue;
<?php
declare(strict_types=1);
/**
* @template F
* @template A
* @extends Functor<F,A>
*/
interface Apply extends Functor
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module NamedTypeclass where
import Prelude hiding (Monoid, mempty, (<>))