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! |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
module FunctorInstancesExercises where | |
-- | 1. | |
data Quant a b = Finance | |
| Desk a | |
| Bloor b | |
instance Functor (Quant a) where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<style> | |
body { | |
margin: 0px; | |
padding: 0px; | |
} | |
</style> | |
</head> |
NewerOlder