Learning to Love Type Systems Swipe Left, Uncaught TypeError - PowerPoint PPT Presentation
Learning to Love Type Systems: Swipe Left, Uncaught TypeError sugarpirate_ poteto Learning to Love Type Systems Swipe Left, Uncaught TypeError PRESENTED BY Lauren Tan (she/her) Cinemagraph by /u/orbojunglist QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Curry–Howard–Lambek correspondence QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Stop with the jargon, Lauren QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Stop with the jargon, Lauren QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError declare function Addition(x: number, y: number) : number; �/0 proposition function add(x: number, y: number) : number { return x + y; } �/0 proof QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Proposition: If x and y are numbers, a number exists declare function Addition(x: number, y: number) : number; �/0 proposition function add(x: number, y: number) : number { return x + y; } �/0 proof QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Proposition: If x and y are numbers, a number exists declare function Addition(x: number, y: number) : number; �/0 proposition function add(x: number, y: number) : number { return x + y; } �/0 proof Proof: x + y proves that a number exists QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError What is a function? QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError f : A → B f a : A b : B QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError f �:; function from type A to type B f an object * of type B an object * of type A * not a JS object QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Types are propositions Programs are proofs Curry-Howard Correspondence QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Let the type system suggest the implementation QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError function head<T>(list: T[]) : T { �/0 ��../ } QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError [ts] Type 'T[]' is not assignable to type 'T'. (parameter) list: T[] function head<T>(list: T[]) : T { return list; } QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError function head<T>(list: T[]) : T { return list[0]; } QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError function map<A, B>(fn: (item: A) �=? B, items: A[]) : B[] { �/0 ��../ } QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError [ts] Type 'A[]' is not assignable to type 'B[]'. Type 'A' is not assignable to type 'B'. (parameter) items: A[] function map<A, B>(fn: (item: A) �=? B, items: A[]) : B[] { return items; } QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError [ts] Type 'B' is not assignable to type 'B[]'. (parameter) fn: (item: A) �=? B function map<A, B>(fn: (item: A) �=? B, items: A[]) : B[] { return fn(items[0]); } QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError function map<A, B>(fn: (item: A) �=? B, items: A[]) : B[] { return items.reduce((acc, curr) �=? { acc.push(fn(curr)); return acc; }, [] as B[]); } QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError myStatelessComponent �:; Props �-? React.ReactNode QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError [ts] Type '1' is not assignable to type 'StatelessComponent<MyProps>'. const MyStatelessComponent: React.StatelessComponent<MyProps> const MyStatelessComponent: React.SFC<MyProps> = 1; QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError [ts] Type '() �=? number' is not assignable to type 'StatelessComponent<MyProps>'. Type 'number' is not assignable to type 'ReactElement<any>'. const MyStatelessComponent: React.StatelessComponent<MyProps> const MyStatelessComponent: React.SFC<MyProps> = () �=? 1; QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError const MyStatelessComponent: React.SFC<MyProps> = props �=? <div> ��../�<0 div>; QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Writing better functions QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError f ( x ) = x 2 QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError f ( x ) = x 2 Domain Codomain 1 1 2 4 3 9 4 16 5 25 6 36 ��../ ��../ QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Total vs Partial functions QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError Total Partial Impure & Total Impure & Partial Impure Pure & Total Pure & Partial Pure QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError A partial function is a function Partial that is not defined for all possible input values. QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError const half = x �=? x / 2; QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError const half = x �=? x / 2; Possible Domains Possible Codomains number number string NaN void Uncaught TypeError object array symbol QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError const half = x �=? x / 2; Possible Domains Possible Codomains number number string NaN void Uncaught TypeError object array symbol QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError const half = x �=? x / 2; Possible Domains Possible Codomains number number string NaN void Uncaught TypeError object array symbol QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError const half = x �=? x / 2; Possible Domains Possible Codomains 路 half('10') �/0 5 number number half('hello world') �/0 NaN string NaN void Uncaught TypeError object array symbol QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError const half = x �=? x / 2; Possible Domains Possible Codomains number number string NaN void Uncaught TypeError object array symbol QCon SF 2018
Learning to Love Type Systems: Swipe Left, Uncaught TypeError const half = x �=? x / 2; Possible Domains Possible Codomains number number string NaN void Uncaught TypeError object array symbol QCon SF 2018
Recommend
More recommend
Explore More Topics
Stay informed with curated content and fresh updates.