News for hackers. Stuff that matters.
Re:Roll your own minilanguages with mini-interpreters (1989) by mjburgess on Thursday July 08, 2021 @09:20AM (#27771591)

    p = newPerson();
    w = walk(p);
    t = talk(p, w);
    s = shout(p, t);

becomes,

    seq(shout, seq(talk, seq(walk, seq(newPerson())))

"infix",

    newPerson() seq
    walk seq
    talk seq
    shout 

The operations `newPerson` and `seq` form a monad.

If you can omit `w =`, `t=`, and `s=` you have an applicative, rather than a monad. Ie., the operations being sequenced are independent.

There are no comments on this comment yet.