What if we wanted to use backbone-style event delegation within the component paradigm afforded by react/preact/etc? Would that be useful?
Basic usage:
| %.coffee: %.coffee.md | |
| sed -n -e '/^ \{4\}/s/^ \{4\}//p' $< > $@ | |
| %.js: %.js.md | |
| sed -n -e '/^ \{4\}/s/^ \{4\}//p' $< > $@ | |
| %.js: %.coffee | |
| coffee -cb $< | |
| all: multi-inherit.coffee multi-inherit.future.js | |
| clean: |
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE DeriveFoldable #-} | |
| {-# LANGUAGE DeriveTraversable #-} | |
| module Main where | |
| import Prelude hiding (foldr) | |
| import Control.Applicative | |
| import Control.Monad (void) | |
| import Data.Foldable | |
| import Data.Traversable |
| // This supports more cases but removes support for if-statements. | |
| macro $do { | |
| // Base Cases | |
| case {_ { $ma:expr } } => { | |
| return #{ | |
| function() { | |
| return $ma | |
| }() | |
| } |
| function IO(unsafePerform) { | |
| this.unsafePerform = unsafePerform; | |
| } | |
| IO.prototype.of = IO.of = function (v) { | |
| return new IO(function (ctx, cb) { | |
| cb(null, v); | |
| }); | |
| }; |
| /* | |
| This replaces <Sequencer> + multiple <Sampler>s with a marble diagram sequencer. | |
| You can use it like this: | |
| <Marble | |
| resolution={16} | |
| samples={[ | |
| 'samples/kick.wav', | |
| 'samples/snare.wav', | |
| ]} |
| const I = x => x; | |
| const K = x => y => x; | |
| const A = f => x => f(x); | |
| const T = x => f => f(x); | |
| const W = f => x => f(x)(x); | |
| const C = f => y => x => f(x)(y); | |
| const B = f => g => x => f(g(x)); | |
| const S = f => g => x => f(x)(g(x)); | |
| const P = f => g => x => y => f(g(x))(g(y)); | |
| const Y = f => (g => g(g))(g => f(x => g(g)(x))); |
| //Combinators | |
| const I = x => x; | |
| //List manipulation | |
| const head = xs => xs[0]; | |
| const tail = xs => xs.slice(1); | |
| const append = x => xs => [...xs, x]; | |
| //Iteration | |
| const foldl = f => y => xs => xs.length > 0 ? foldl(f)(f(y)(head(xs)))(tail(xs)) : y; |
| const S = f => g => x => f(x)(g(x)) | |
| const K = x => y => x | |
| const I = S(K)(K) | |
| const B = S(K(S))(K) | |
| const C = S(S(K(B))(S))(K(K)) | |
| const A = S(K(I)) | |
| const T = C(A) | |
| const W = S(S)(K(I)) |
| var Maybe = require('./maybe.js') | |
| var List = require('./list.js') | |
| //Pass fantasy implementations to it | |
| var {concat, map} = require('fantasy')({Maybe, List}) | |
| mapDouble = map(a => 2 * a) | |
| mapDouble([1, 2]) | |
| //[2, 4] |