57: Staying the Course - JSToElm
All Episodes

57: Staying the Course

We go from planned topic to full scale book review. But we've strung together a small string of victories, and that feels pretty good.

Sticking with Haskell

  • Not really wanting to do JS at work, daily.
  • I want to understand the underlying workings of it.
  • I want more stable, elegant code. I keep trying to make custom types in JS, and it’s totally not working. Hence my interest in TypeScript lately. By defining the shape of the data that is allow, it removes an entire class of bullshit that I have to be reactive to in JS. And I really don’t like it.
  • How can I do this better ?

Lambda Functions and Scope

Prelude> oVer x = (\x -> (\x -> (\x -> x) 4 ) 3 ) 2
Prelude> oVer 4

Prelude> overWrite x = (\x -> (\x -> (\x -> x) ) )(2)(3)(4)
Prelude> overWrite 1
  • So why does this work? At first I wasn’t sure. I have this nagging sense that nested functions are difficult to reason about, this is about the time I struggled with the pipe operator (|>)

These let and where examples of using a lambda function may initially seem academic and contrived, but they’re the basis of one of the most important design patterns in JavaScript

It’s mind bending to me to have lambda expressions explained in a Haskell book, using JS. I need to remember all the little nuances of JS that I have absorbed over the years, and that other languages are the same.

JS using lambda functions to encapsulate scope.

Holy sh-nikes haskell uses lexical scope too. It even has a diagram.

Resources

Follow

Published 8 Nov 2018

A show about learning Elm, Functional Programing, and generally leveling up as a JS developer.
JavaScript To Elm on Twitter