Haskell Overview David Grisham 31 October 2017 Haskell Overview - - PowerPoint PPT Presentation

haskell overview
SMART_READER_LITE
LIVE PREVIEW

Haskell Overview David Grisham 31 October 2017 Haskell Overview - - PowerPoint PPT Presentation

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading Haskell Overview David Grisham 31 October 2017 Haskell Overview David Grisham Properties Ecosystem History My Haskell Projects Why care


slide-1
SLIDE 1

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Haskell – Overview

David Grisham 31 October 2017

Haskell – Overview David Grisham

slide-2
SLIDE 2

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Properties

Haskell – Overview David Grisham

slide-3
SLIDE 3

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Outline

  • Polymorphically statically typed
  • Lazy
  • Purely functional

Haskell – Overview David Grisham

slide-4
SLIDE 4

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Type System

  • Polymorphic
  • Static typing
  • Strong typing

Haskell – Overview David Grisham

slide-5
SLIDE 5

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Type System

Polymorphism

1 Parametric polymorphism

  • Unconstrained type variables
  • e.g. id :: a -> a

2 Ad-hoc polymorphism

  • Constrained type variables
  • e.g. sort :: Ord a => [a] -> [a]

Haskell – Overview David Grisham

slide-6
SLIDE 6

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Type System

Static typing

  • Type-checking happens at compile time
  • Efficient
  • No runtime type-checks
  • Known memory requirements

Haskell – Overview David Grisham

slide-7
SLIDE 7

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Type System

Strong typing

  • No implicit type conversions. . .
  • . . . but does have type inference and polymorphism

Haskell – Overview David Grisham

slide-8
SLIDE 8

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Lazy

  • Evaluation only when needed

> x = 1 `div` 0 > print x *** Exception: divide by zero

Haskell – Overview David Grisham

slide-9
SLIDE 9

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Lazy

Advantages

  • Save computation time
  • More modular and expressive

Disadvantages

  • Memory usage less predictable
  • Might slow down execution

Haskell – Overview David Grisham

slide-10
SLIDE 10

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Purely Functional

  • Pure: prohibits side effects
  • Functions operating on immutable data
  • Referential transparency
  • Lazy evaluation

Haskell – Overview David Grisham

slide-11
SLIDE 11

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Ecosystem

Haskell – Overview David Grisham

slide-12
SLIDE 12

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Tools

  • GHC
  • Stack

Haskell – Overview David Grisham

slide-13
SLIDE 13

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

GHC

  • Standard compiler for Haskell
  • Simon Peyton Jones, Simon Marlow

Haskell – Overview David Grisham

slide-14
SLIDE 14

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Stack

  • Development environment for Haskell
  • Package management, testing, . . .

Haskell – Overview David Grisham

slide-15
SLIDE 15

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

History

Haskell – Overview David Grisham

slide-16
SLIDE 16

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

From the man himself. . .

Click

Haskell – Overview David Grisham

slide-17
SLIDE 17

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

My Haskell Projects

Haskell – Overview David Grisham

slide-18
SLIDE 18

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Elements of Computing Systems

  • Compiler for Jack (Java-like language)
  • Jack → VM
  • VM → assembly language
  • Only group using Haskell
  • Python, Java, Ruby, . . .

Haskell – Overview David Grisham

slide-19
SLIDE 19

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Compiler: Benefits of Haskell

  • Parsec (‘Parser combinators’)
  • Build complex parsers from simple ones
  • Practical intro to more esoteric Haskell
  • Relatively minimal Haskell knowledge
  • Result still fairly robust

Haskell – Overview David Grisham

slide-20
SLIDE 20

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Imperative Language Interpreter

  • Direct execution (instead of compiling)
  • Expressiveness

exec (IfStmt condition stmt1 stmt2) env | condition = exec stmt1 env | otherwise = exec stmt2 env

Haskell – Overview David Grisham

slide-21
SLIDE 21

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Other Projects

  • Decoy routing
  • Game-theoretic simulation
  • Movie suggestion script
  • Filter movies based on genre/etc.
  • Spit out random movie from result
  • Todo-list manager
  • Add task, schedule task, . . .
  • taskwarrior

Haskell – Overview David Grisham

slide-22
SLIDE 22

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Why care about Haskell?

Haskell – Overview David Grisham

slide-23
SLIDE 23

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

XKCD

Haskell – Overview David Grisham

slide-24
SLIDE 24

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Motivation

  • Expressive
  • Fewer runtime bugs
  • Easier to debug
  • Easier to maintain
  • Code reuse

Haskell – Overview David Grisham

slide-25
SLIDE 25

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Worst practices should be difficult

  • Sensible defaults in Haskell
  • Maybe/Nothing over NULL/None
  • Immutability
  • Minimal IO

Haskell – Overview David Grisham

slide-26
SLIDE 26

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Programming Paradigm

  • Informs how you think about coding
  • Very useful to broaden
  • Better code in other languages

Haskell – Overview David Grisham

slide-27
SLIDE 27

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Coming Up With Haskell Projects

Challenge isn’t “what can I do in Haskell” Challenge is “how can I do X in Haskell”

Haskell – Overview David Grisham

slide-28
SLIDE 28

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Further Reading

Haskell – Overview David Grisham

slide-29
SLIDE 29

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Links (articles)

  • Beating the Averages
  • Competitive advantage in programming language choice
  • Worst practice should be hard
  • Long-term language productivity

Haskell – Overview David Grisham

slide-30
SLIDE 30

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Links (paper and talk)

  • Von Neumann vs. Functional Languages
  • First 10 pages, more if you want
  • Functional Programming Design Patterns
  • Straightforward explanations of functional advantages

Haskell – Overview David Grisham

slide-31
SLIDE 31

Properties Ecosystem History My Haskell Projects Why care about Haskell? Further Reading

Links (learning resources)

  • Real World Haskell
  • Brian O’Sullvian, et al.
  • Stanford 240h: Functional Systems in Haskell
  • David Mazieres and Brian O’Sullvian
  • All resources available (except lecture vids)
  • /r/haskell
  • Consistently worthwhile content here

Haskell – Overview David Grisham