Exploring Data Abstraction and Functional Programming at Lambda Jam Sessions

Table of Contents

Sessions

Data, Visibility, and Abstraction - Stuart Sierra

  • Basic (low abstraction but direct)
  • QBAsic (subroutines vs. functions; IDE, debugger, immediate calling)
  • C++ (limited visibility, create your own data structures)
  • Perl (abstractions that actually helped; new generic data structures; tied data structures (array tied to Tie::File))
  • XSLT (pattern matching, recursion, immutable variables, homoiconic; transformations against)
  • Java (boilerplate with visibility)
  • Common Lisp (required new abstractions rather than just relying on builtins) http://stuartsierra.com/download/perl-in-lisp-literate-full.html
  • Rails (lambdas, flexible language; see division in Hpricot for subset)
  • Clojure (immutability, inspect-tree, lazy sequences)

Side Effects

As programs became more complicated there wasn't any outcomes. Using threading macros: data transformaitons with only one side effect at the end:

  (defn execute-action []
    (->
     (lookup-data)
     (lookup-data2)
     (side-effect)
     (transform-data)
     (retransform-data)
     (modify-state)))

Simile-Free Monad Recipes - Aditya Siram

http://lanyrd.com/2013/lambda-jam/scghtq/

  • Haskell
  • IO, Reader, Writer, State, Monad Transform

Monads and Macros - Chris Houser & Jonathan Claggett

http://lanyrd.com/2013/lambda-jam/scghtw/

Session that covered differences in the threading macro with the work on threading macros (more precisely sythread) vs. macros (though macros weren't covered as much as I would have expected).

https://github.com/LonoCloud/synthread http://docs.racket-lang.org/reference/stxtrans.html

The Art of Several Interpreters

Run through all of the examples to show static and dynamic scope.

Applying the Y combinator wasn't even discussed but for some reason covered an example of execution of (car (cdr '(foo bar baz))) in the interpreter.

The following is another form for Church Numerals since the lexical scope for quote wins in Scheme.

  (((lambda (quote) (lambda (x) ''''x)) add1) 0)

Work through the construction of Lamdba Calculus:

;; boolean 
(define yes (lambda (f) (lambda x) f x))
;; identity
(lambda f.0 f.0)

Clojure BOF

Channels on JVM @puredanger

http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html

Covered some of the use of Channels in core.async.

ClojureScript Channels @swannodette

core.async working with ClojureScript.

rx.js as one of the options for managing conditional activities based on async requests.

https://github.com/swannodette/async-tests/blob/master/src/async_test/robpike/core.cljs

This continues some of the work on having better composability than what is provided just through callbacks or futures.

  (defn handler [[e c]]
    (match [e]
           [{"x" x} {"y" y}]))

Requires bringing the async edges in to channels. Example was using the Google JSONP interface dumping values into a channel.

  (defn fastest []
    ())
  

This also provides precise event control when using throttle rules with timeouts.

  (defn throttle
    ([src ms]
       ())
    ([c src ms]
       ()))
  

See a comparable implementation: http://davidwalsh.name/function-debounce

  • Multiplex channels
  • event channel
  • map includes the munction to removeEventListener el
  • go blocks
  • Fan-in
  • Blocking

http://en.wikipedia.org/wiki/Communicating_sequential_processes

Functional Reactive Programming in the Netflix API - Ben Christensen

Use Case

Problem: Fetch a value then async conditional data request.

Research:

Looking at Futures and Observable .

Treat the contruction of Observable endpoint based on machine state, amount of work, data in memory.

Implementation

Solution

Havae a grid of movies each with metadata that, based on that data, will require a second (or more) request(s): VideoMetadata, VideoBookmark, VideoRating.

This used Groovy for the implementations against the service:

  • getVideos
  • take
  • mapMany / flatMap
  • metadata, bookmark, rating:
  • return zip(a, b, F)

Takeaway

Apply functions to async

Emphasize developer training re: functional and reactive programming. Initial hurdle was just in setting up the workshops, brought in a technical writer just for the documentation for the on-boarding.

Debugging and performance was the next area of improvement.

Only rule: "Don't mutate state outside of function."

Functional Async Without the Pain - Jim Powers

http://lanyrd.com/2013/lambda-jam/scghwp/

  • aync approach in nodejs and Java concurrently makes it hard to reasons about
  • Actors scale well
  • RX looks interesting but was only reviewed
  • Based on http://akka.io/
val system = ActorSystem.create()

class FooActor extends Actor { 

} 
  • Scatter/Gather

Transformer Functions

  • Next
  • Error
  • Empty
  • Complete

Videos

TBD

Functional CoffeeScript for Web UIs - Richard Feldman

Covered some of the considerations for when to use a transpiler for JavaScript.

https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS

  • Look at descructuring of the the object from data in a callback (e.g., [x, y] for point if that were the data).

Compilers From Scratch

Problem Statement

Starting with Lambda Calculus and BNF of SExpr, Var, Int, Bool, Binop.

Regular Expressions

3 basic operations.

  • symbol
  • repetion
  • concatenation

Strings in Haskell are just lists.

  • pull characters from string one at a time
  • at end of string check the match

Workflow

  • Define a list of tokens we want to suport
  • Define a sample program that we want to run
  (let (y (lambda f
            ((lambda x (x x))
             (lambda x (f (lambda v ((x x) v)))))))
    (let (factH (lambda partial
                  (lambda n (if (= n 0)
                           1
                         (* n (partial (- n 1)))))))
      (let (fact (y factH))
        (print (fact 5)))))
  
  • Lex the program by finding matches for types associated with If, Sub, Mul, Eq, Gt, Lt, Or, And, Let
  • Create the rules as RegExp matches
  • Running from Haskell
jwalsh:CompilersFromScratch/ (master) $ ghci SExpr
  • Provide a simple example
(let (x 1) 

Tasks

Review: coroutines in Clojure vs. yeild with generators in Python

Watch: Josh Suereth - Introduction to Actors Systems

POC: LiveScript

This had more love than expected (possibly due to the F# contingent) but more highly regarded than at most JS conferences (e.g., the heavy push at CascadiaJS).

http://livescript.net/

As a replacement for underscore.js ; backcalls from Haskell in underscore.js.

Author: Jason Walsh

j@wal.sh

Last Updated: 2025-07-30 13:45:27

build: 2025-12-23 09:11 | sha: a10ddd7