Haskell Tour (Part 1)

Download Haskell Tour (Part 1)

Post on 05-Sep-2014

4.313 views

Category:

Technology

4 download

DESCRIPTION

We introduce Haskell. Why is it interesting. Where did it come from. What is it like. How to get started. We show a GHCi session. We introduce simple recursive function and data. And we demo QuickCheck for testing properties of automatically generated data.

TRANSCRIPT

  • HaskellA Whirlwind Tour William Taysom 2011
  • Haskell
  • HaskellWho?What?When?Where?Why?How?
  • HaskellWho?What?When?Where?Why?How?
  • Why? Aesthetics
  • Why? AestheticsWe provided DARPA with a copy of our prototypeimplemented in Haskell without explaining that it wasa program, and based on preconceptions from theirpast experience, they had studied the program underthe assumption that it was a mixture of requirementsspecification and top level design. They wereconvinced it was incomplete because it did not addressissues such as data structure design and executionorder. Paul Hudak
  • Why? AestheticsTake Lisp: you know its the most beautiful languagein the world. At least up until Haskell came along. Larry Wall
  • Why? AestheticsReading Haskell is like reading poetry.Writing Haskell is like writing poetry. Oliver Steele
  • Why? AestheticsI also have interest in Haskell, but my brain justexplodes every time I read a Haskell program biggerthan ten lines. Matz
  • Why? AestheticsThe biggest advantage of Haskell to me is that it helpsme write better programs in other languages. Tenerife Skunkworks
  • Why? Aesthetics.NET LINQPython List ComprehensionsJava GenericsJavaScript jQuery
  • Why? Pragmatics
  • Why? PragmaticsPlatform Compiler Debugger Profiler TestingLibraries Network Graphics HackageCommunity Books Documentation Hoogle
  • Why? PragmaticsPlatform Compiler Debugger Profiler TestingLibraries Network Graphics HackageCommunity Books Documentation Hoogle
  • Why? Pragmatics Hoogle
  • Why? Pragmatics Hoogle
  • Why? PragmaticsPlatform Compiler Debugger Profiler TestingLibraries Network Graphics HackageCommunity Books Documentation Hoogle
  • Why? PragmaticsPlatform Compiler Debugger Profiler TestingLibraries Network Graphics HackageCommunity Books Documentation Hoogle
  • How? GHC Documentation Libraries Cabal Hackage
  • Why? PragmaticsPlatform Compiler Debugger Profiler TestingLibraries Network Graphics HackageCommunity Books Documentation Hoogle
  • Why? Pragmatics
  • Why? Pragmatics
  • Why? PragmaticsA programming language must be considered in thecontext of its community, and Haskell has anexemplary one. I have come to believe, however, thatthis polite exterior conceals a deep and consumingmadness. Avdi Grimm
  • Why? Performance
  • Why? PerformanceThe Computer Language Benchmarks Game
  • Why? Performance Web Server Pong benchmark, extra large instance, requests/second
  • Why? Performance Web Server Pong benchmark, extra large instance, requests/second
  • Why? Aesthetics Pragmatics Performance
  • HaskellWho?What?When?Where?Why? Aesthetics Pragmatics PerformanceHow?
  • HaskellWho?What?When?Where?Why? Aesthetics Pragmatics PerformanceHow?
  • Who? When? Where? September 1987
  • Who? When? Where? Portland, Oregon
  • Who? When? Where?Functional ProgrammingLanguages and ComputerArchitecture Conference
  • Who? When? Where? A Dozen Purely Functional Languages
  • Who? When? Where? All Similar
  • Who? When? Where? Committee Formed
  • Who? When? Where? Committee Formed
  • Provide faster communication of newideas.Stable foundation for real applicationdevelopment.Vehicle through which others would beencouraged to use functional languages.
  • Who? When? Where?Haskell ReportApril 1st 1990You know, Haskellactually never liked thename Haskell. Mary Curry
  • Who? When? Where? 2002Revised Haskell 98 Report
  • Who? When? Where? 2010 Haskell
  • HaskellWho? Research Wadler Hudak Peyton-JonesWhat?When? 1987 1990 2002 NowWhere? Portland Glasgow MicrosoftWhy? Aesthetics Pragmatics PerformanceHow?
  • HaskellWho? Research Wadler Hudak Peyton-JonesWhat?When? 1987 1990 2002 NowWhere? Portland Glasgow MicrosoftWhy? Aesthetics Pragmatics PerformanceHow?
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What? ProgrammingSource CodeFormal, Textural SyntaxStatic & Runtime SemanticsData, Variables, Lexical ScopeInterpreter, Compiler
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What? Functional (Not Imperative)
  • What? FunctionalImperative Statements Executed Step-by-step
  • What? FunctionalImperative Statements Executed Step-by-step Modifying State
  • What? FunctionalImperative Statements Executed Step-by-step Modifying State Turing Machine
  • What? FunctionalImperative Statements Executed Step-by-step Modifying State Von Neumann Architecture
  • What? FunctionalImperative Statements Executed Step-by-step Modifying State Von Neumann ArchitectureFunctional Expressions Recursively Simplified
  • What? FunctionalImperative Statements Executed Step-by-step Modifying State Von Neumann ArchitectureFunctional Expressions Recursively Simplified Reduced Value
  • What? FunctionalImperative Statements Executed Step-by-step Modifying State Von Neumann ArchitectureFunctional Expressions Recursively Simplified Reduced Value Lambda Calculus
  • What? FunctionalImperative Statements Executed Step-by-step Modifying State Von Neumann ArchitectureFunctional Expressions Recursively Simplified Reduced Value Lambda Calculus
  • What? FunctionalImperative Statements Executed Step-by-step Modifying State Von Neumann ArchitectureFunctional Expressions Recursively Simplified Reduced Value Lambda Calculus
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What? Pure (No Side Effects)
  • What? Pure Immutable Only
  • What? PureReferential Transparency
  • What? Pure Functions always return the same value. If v = f x, then you can always replace f x with v.
  • What? Pure Functions always return the same value. If v equals f x, then you can always replace f x with v.
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What? Non-strict Be lazy.
  • What? Non-strict Be lazy. Ignore evaluation order.
  • Wait...
  • if everything isimmutable and there are no side effectsand evaluation is lazy,
  • then how the hell do you do anything?
  • MONADS Bring your own Semicolon
  • What? Monads
  • What? Monads
  • What? Monads
  • What? Monads
  • What? Monads
  • What? MonadsHaskell is the worlds finestimperative programming language. Simon Peyton-Jones
  • What? MonadsHaskell is the only language I know withfirst-class support for imperative programming. SamB
  • What? MonadsHaskell has no preferred imperative semantics, andthe monad just lets you swap out the semanticsaccording to your needs. Jared Updike
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What?A non-strict, purelyfunctional programminglanguage with strong,static type inference.
  • What? Types Strong Static Inference
  • What? Types Strong Static Inference
  • What? Strong Types Runtime values have types.
  • What? Strong Types Runtime values have types. like Java and Ruby unlike C and Assembly (Not Weak)
  • What? Types Strong Static Inference
  • What? Types Strong Static Inference
  • What? Static Types Source code expressions have types.
  • What? Static Types Source code expressions have types. like C and Java unlike Ruby and JavaScript (Not Dynamic)
  • What? Types Strong Static Inference
  • What? Types Strong Static Inference
  • What? Type InferenceAutomatically determines types of variables.
  • What? Type InferenceAutomatically determines types of variables. like C# and Go unlike C and Java (Not Manifest)
  • You dont need to type the type!
  • SYNERGY Purity means types tell you a lot.
  • What? Type Purity No side effects mean,
  • What? Type Purity No side effe...