Skip to content

Instantly share code, notes, and snippets.

title author date datePretty description tags
Intro to FP Through λ-Calc Part 1. - Motivating Laziness
Jonathan Lorimer
19/03/2020
Mar 19, 2020
Introduction to Functional Programming Through Lambda Calculus gave a thorough explanation of evaluation in lambda calculus, I found this helped motivate a better understanding of evaluation in haskell!
lambda-calculus

Table of Contents

const productType = { a: 3, b: "hello", c: false }
// this has the implied type data ProductType = { a :: Number, b :: String, c :: false }
// even if javascript doesn't demand that we think about it, it matters
// as demonstrated by the below function which IMPLICITLY expects that type signature
const repeatWord = ({a, b, c}) => b + (c ? " " : "/n") + (a <= 0 ? "" : repeatWord({a: a - 1, b, c})
// if you give the above function the wrong 'type' you will get unexpected behaviour
// rather than resulting in a type error you will get either a runtime error or an unexpected return value
// Similarly you might have this
{-# LANGUAGE FlexibleInstances #-}
module FunctorInstancesExercises where
-- | 1.
data Quant a b = Finance
| Desk a
| Bloor b
instance Functor (Quant a) where
module FunctorInstances where
import Test.QuickCheck
newtype Identity a = Identity a
deriving (Eq, Show)
instance Functor Identity where
fmap f (Identity a) = Identity (f a)

Keybase proof

I hereby claim:

  • I am jonathanlorimer on github.
  • I am jonathanlorimer (https://keybase.io/jonathanlorimer) on keybase.
  • I have a public key ASAb-Ce7Wm_xSErNRTLCnG7b_wupUYXxu9JujmOK-b-r6wo

To claim this, I am signing this object:

<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>