why haskell

101
Why Haskell? Susan Potter March 2012

Upload: susan-potter

Post on 29-Aug-2014

5.533 views

Category:

Technology


2 download

DESCRIPTION

Monads, also known as Kleisli triples in Category Theory, are an (endo-)functor together with two natural transformations, which are surprisingly useful in pure languages like Haskell, but this talk will NOT reference monads. Ever. (Well, at least not in this talk.) Instead what I intend to impress upon an audience of newcomers to Haskell is the wide array of freely available libraries most of which is liberally licensed open source software, intuitive package management, practical build tools, reasonable documentation (when you know how to read it and where to find it), interactive shell (or REPL), mature compiler, stable runtime, testing tools that will blow your mind away, and a small but collaborative and knowledgeable community of developers. Oh, and some special features of Haskell - the language - too!

TRANSCRIPT

Page 1: Why Haskell

Why Haskell?

Susan Potter

March 2012

Page 2: Why Haskell

What is Haskell?

Figure: "pure functional, lazy, polymorphic, statically and strongly typed with type inference . . . "

Page 3: Why Haskell

How can I drive this thing?

Figure: Photo from "If programming languages were cars" blog posthttp://machinegestalt.posterous.com/if-programming-languages-were-cars

Page 4: Why Haskell

Can I drive Haskell without all this?

Figure: No need to know Category Theory proofs, just some intuitions!

Page 5: Why Haskell

# finger $(whoami)

Login: susan Name: Susan PotterDirectory: /home/susan Shell: /bin/zshPracticing since 1997-09-29 21:18 (GMT) on tty1 from :0Too much unread mail on [email protected] working at Desk.com! Looking for smart developers!;)Plan:github: mbbx6spptwitter: @SusanPotter

Page 6: Why Haskell

Are we "doing it wrong"?

Figure: Maybe! ;)http://absolutelymadness.tumblr.com/post/17567574522

Page 7: Why Haskell

Overview: Choosing a language

Many considerationspolitical, human, technical

Runtimeperformance, reliability, configurability

Knowledgeculture, mindshare, resources, signal to noise ratio

Toolingdevelopment, build/release, configuration, deployment

Page 8: Why Haskell

Overview: Choosing a language

Many considerationspolitical, human, technical

Runtimeperformance, reliability, configurability

Knowledgeculture, mindshare, resources, signal to noise ratio

Toolingdevelopment, build/release, configuration, deployment

Page 9: Why Haskell

Overview: Choosing a language

Many considerationspolitical, human, technical

Runtimeperformance, reliability, configurability

Knowledgeculture, mindshare, resources, signal to noise ratio

Toolingdevelopment, build/release, configuration, deployment

Page 10: Why Haskell

Overview: Choosing a language

Many considerationspolitical, human, technical

Runtimeperformance, reliability, configurability

Knowledgeculture, mindshare, resources, signal to noise ratio

Toolingdevelopment, build/release, configuration, deployment

Page 11: Why Haskell

Overview: Agenda

My Claims / Hypotheses

Laziness, Functional, Type System

Toolkit & Runtime

Library Ecosystem

Pitfalls & Hurdles

Page 12: Why Haskell

My Claims

Performance is reasonableon par with Java and C# Mono; 2-3x CPU times of C (approx); BUT always doubt benchmarks

http://shootout.alioth.debian.org/u64q/haskell.php

Productivity with long-term benefitsafter initial steep learning curve

Haskell types offer stronger verifiabilitystrong and meaningful checks applied

Pure functional code is easier to testprobably not controversial

Page 13: Why Haskell

My Claims

Performance is reasonableon par with Java and C# Mono; 2-3x CPU times of C (approx); BUT always doubt benchmarks

http://shootout.alioth.debian.org/u64q/haskell.php

Productivity with long-term benefitsafter initial steep learning curve

Haskell types offer stronger verifiabilitystrong and meaningful checks applied

Pure functional code is easier to testprobably not controversial

Page 14: Why Haskell

My Claims

Performance is reasonableon par with Java and C# Mono; 2-3x CPU times of C (approx); BUT always doubt benchmarks

http://shootout.alioth.debian.org/u64q/haskell.php

Productivity with long-term benefitsafter initial steep learning curve

Haskell types offer stronger verifiabilitystrong and meaningful checks applied

Pure functional code is easier to testprobably not controversial

Page 15: Why Haskell

My Claims

Performance is reasonableon par with Java and C# Mono; 2-3x CPU times of C (approx); BUT always doubt benchmarks

http://shootout.alioth.debian.org/u64q/haskell.php

Productivity with long-term benefitsafter initial steep learning curve

Haskell types offer stronger verifiabilitystrong and meaningful checks applied

Pure functional code is easier to testprobably not controversial

Page 16: Why Haskell

Haskell "lazy" by default

Figure: Photo by Mark Fischerhttp://www.flickr.com/photos/tom_ruaat/4431626234/

(jarring for mainstream programmers)

Page 17: Why Haskell

Haskell "lazy" by default

Figure: Photo by Mark Fischerhttp://www.flickr.com/photos/tom_ruaat/4431626234/

(jarring for mainstream programmers)

Page 18: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value

(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 19: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value

(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 20: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value

(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 21: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value

(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 22: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value

(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 23: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value

(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 24: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 25: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 26: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 27: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name

(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 28: Why Haskell

Example: doubleSum 3 (2 + 3)

Call by value(evaluates inner-most expressions first)

doubleSum 3 (2 + 3)→ doubleSum 3 5→ 2 * (3 + 5)→ 2 * 8→ 16

Call by name(evaluates outer-most expressions first)

doubleSum 3 (2 + 3)→ (λ x -> 2 * (3 + x)) (2 + 3)

Page 29: Why Haskell

Laziness in Haskell is . . .

CallByName

+ SharingOptimization

+ PossibleMinorOverhead

Page 30: Why Haskell

Laziness: Buyer Bewarefilter (λ x → x < 6) [1..](never terminates)

takeWhile (λ x → x < 6) [1..](does terminate)

dropWhile (λ x → x >= 6) [1..](does not terminate)

Need to understand implicationsof laziness on functions

Laziness with I/O implicationslazy I/O with handles is problematic, but iteratee idiom solves most of these. There are a number of libraries

available to help with this: enumerator, pipes, . . .

Page 31: Why Haskell

Laziness: Buyer Bewarefilter (λ x → x < 6) [1..](never terminates)

takeWhile (λ x → x < 6) [1..](does terminate)

dropWhile (λ x → x >= 6) [1..](does not terminate)

Need to understand implicationsof laziness on functions

Laziness with I/O implicationslazy I/O with handles is problematic, but iteratee idiom solves most of these. There are a number of libraries

available to help with this: enumerator, pipes, . . .

Page 32: Why Haskell

Laziness: Buyer Bewarefilter (λ x → x < 6) [1..](never terminates)

takeWhile (λ x → x < 6) [1..](does terminate)

dropWhile (λ x → x >= 6) [1..](does not terminate)

Need to understand implicationsof laziness on functions

Laziness with I/O implicationslazy I/O with handles is problematic, but iteratee idiom solves most of these. There are a number of libraries

available to help with this: enumerator, pipes, . . .

Page 33: Why Haskell

Laziness: Buyer Bewarefilter (λ x → x < 6) [1..](never terminates)

takeWhile (λ x → x < 6) [1..](does terminate)

dropWhile (λ x → x >= 6) [1..](does not terminate)

Need to understand implicationsof laziness on functions

Laziness with I/O implicationslazy I/O with handles is problematic, but iteratee idiom solves most of these. There are a number of libraries

available to help with this: enumerator, pipes, . . .

Page 34: Why Haskell

Laziness: Buyer Bewarefilter (λ x → x < 6) [1..](never terminates)

takeWhile (λ x → x < 6) [1..](does terminate)

dropWhile (λ x → x >= 6) [1..](does not terminate)

Need to understand implicationsof laziness on functions

Laziness with I/O implicationslazy I/O with handles is problematic, but iteratee idiom solves most of these. There are a number of libraries

available to help with this: enumerator, pipes, . . .

Page 35: Why Haskell

Laziness: Also Pretty Suuweeeet!

Infinite sequences/listsmade possible

Recursive functionsbecome practical

Recursive typesbecome simple

Much more as well ...

Page 36: Why Haskell

Laziness: Also Pretty Suuweeeet!

Infinite sequences/listsmade possible

Recursive functionsbecome practical

Recursive typesbecome simple

Much more as well ...

Page 37: Why Haskell

Laziness: Also Pretty Suuweeeet!

Infinite sequences/listsmade possible

Recursive functionsbecome practical

Recursive typesbecome simple

Much more as well ...

Page 38: Why Haskell

Laziness: Also Pretty Suuweeeet!

Infinite sequences/listsmade possible

Recursive functionsbecome practical

Recursive typesbecome simple

Much more as well ...

Page 39: Why Haskell

Purity + Laziness=> Reasoning

Equality (referential transparency)Can replace occurrences of LHS with RHS

Higher Order Functionsencourage exploitation of higher-level patterns

Function Compositionleads to greater reuse

Page 40: Why Haskell

Purity + Laziness=> Reasoning

Equality (referential transparency)Can replace occurrences of LHS with RHS

Higher Order Functionsencourage exploitation of higher-level patterns

Function Compositionleads to greater reuse

Page 41: Why Haskell

Purity + Laziness=> Reasoning

Equality (referential transparency)Can replace occurrences of LHS with RHS

Higher Order Functionsencourage exploitation of higher-level patterns

Function Compositionleads to greater reuse

Page 42: Why Haskell

mysum :: Num a => [a] -> amysum xs = foldr (+) 0 xs

myproduct :: Num a => [a] -> amyproduct xs = foldr (*) 1 xs

myany :: (a -> Bool) -> [a] -> Boolmyany pred xs = foldr (\ x b -> b || pred x) False xs

myall :: (a -> Bool) -> [a] -> Boolmyall pred xs = foldr (\ x b -> b && pred x) True xs

Page 43: Why Haskell

mysum :: Num a => [a] -> amysum xs = foldr (+) 0 xs

myproduct :: Num a => [a] -> amyproduct xs = foldr (*) 1 xs

myany :: (a -> Bool) -> [a] -> Boolmyany pred xs = foldr (\ x b -> b || pred x) False xs

myall :: (a -> Bool) -> [a] -> Boolmyall pred xs = foldr (\ x b -> b && pred x) True xs

Page 44: Why Haskell

mysum :: Num a => [a] -> amysum xs = foldr (+) 0 xs

myproduct :: Num a => [a] -> amyproduct xs = foldr (*) 1 xs

myany :: (a -> Bool) -> [a] -> Boolmyany pred xs = foldr (\ x b -> b || pred x) False xs

myall :: (a -> Bool) -> [a] -> Boolmyall pred xs = foldr (\ x b -> b && pred x) True xs

Page 45: Why Haskell

mysum :: Num a => [a] -> amysum xs = foldr (+) 0 xs

myproduct :: Num a => [a] -> amyproduct xs = foldr (*) 1 xs

myany :: (a -> Bool) -> [a] -> Boolmyany pred xs = foldr (\ x b -> b || pred x) False xs

myall :: (a -> Bool) -> [a] -> Boolmyall pred xs = foldr (\ x b -> b && pred x) True xs

Page 46: Why Haskell

mysum :: Num a => [a] -> amysum xs = foldr (+) 0 xs

myproduct :: Num a => [a] -> amyproduct xs = foldr (*) 1 xs

myany :: (a -> Bool) -> [a] -> Boolmyany pred xs = foldr (\ x b -> b || pred x) False xs

myall :: (a -> Bool) -> [a] -> Boolmyall pred xs = foldr (\ x b -> b && pred x) True xs

Page 47: Why Haskell

mysum :: Num a => [a] -> amysum xs = foldr (+) 0 xs

myproduct :: Num a => [a] -> amyproduct xs = foldr (*) 1 xs

myany :: (a -> Bool) -> [a] -> Boolmyany pred xs = foldr (\ x b -> b || pred x) False xs

myall :: (a -> Bool) -> [a] -> Boolmyall pred xs = foldr (\ x b -> b && pred x) True xs

Page 48: Why Haskell

mysum :: Num a => [a] -> amysum xs = foldr (+) 0 xs

myproduct :: Num a => [a] -> amyproduct xs = foldr (*) 1 xs

myany :: (a -> Bool) -> [a] -> Boolmyany pred xs = foldr (\ x b -> b || pred x) False xs

myall :: (a -> Bool) -> [a] -> Boolmyall pred xs = foldr (\ x b -> b && pred x) True xs

Page 49: Why Haskell

class Monoid m wheremappend :: m -> m -> mmempty :: m

instance Num a => Monoid a wheremappend :: m -> m -> mmappend x y = (+) x ymempty :: mmempty = 0

instance Monoid Bool wheremappend :: m -> m -> mmappend True _ = Truemappend _ True = Truemappend _ _ = Falsemempty :: mmempty = False

Page 50: Why Haskell

class Monoid m wheremappend :: m -> m -> mmempty :: m

instance Num a => Monoid a wheremappend :: m -> m -> mmappend x y = (+) x ymempty :: mmempty = 0

instance Monoid Bool wheremappend :: m -> m -> mmappend True _ = Truemappend _ True = Truemappend _ _ = Falsemempty :: mmempty = False

Page 51: Why Haskell

class Monoid m wheremappend :: m -> m -> mmempty :: m

instance Num a => Monoid a wheremappend :: m -> m -> mmappend x y = (+) x ymempty :: mmempty = 0

instance Monoid Bool wheremappend :: m -> m -> mmappend True _ = Truemappend _ True = Truemappend _ _ = Falsemempty :: mmempty = False

Page 52: Why Haskell

Haskell type signatures can . . .

express side effectse.g. String -> IO Int

declare computational strategiese.g. Num a => [a] -> Sum a

impose constraintse.g. Num a => a -> a

question value availabilitye.g. String -> Maybe Int

verify client-server protocol dialogs?an exercise for reader ;)

Page 53: Why Haskell

Haskell type signatures can . . .

express side effectse.g. String -> IO Int

declare computational strategiese.g. Num a => [a] -> Sum a

impose constraintse.g. Num a => a -> a

question value availabilitye.g. String -> Maybe Int

verify client-server protocol dialogs?an exercise for reader ;)

Page 54: Why Haskell

Haskell type signatures can . . .

express side effectse.g. String -> IO Int

declare computational strategiese.g. Num a => [a] -> Sum a

impose constraintse.g. Num a => a -> a

question value availabilitye.g. String -> Maybe Int

verify client-server protocol dialogs?an exercise for reader ;)

Page 55: Why Haskell

Haskell type signatures can . . .

express side effectse.g. String -> IO Int

declare computational strategiese.g. Num a => [a] -> Sum a

impose constraintse.g. Num a => a -> a

question value availabilitye.g. String -> Maybe Int

verify client-server protocol dialogs?an exercise for reader ;)

Page 56: Why Haskell

Haskell type signatures can . . .

express side effectse.g. String -> IO Int

declare computational strategiese.g. Num a => [a] -> Sum a

impose constraintse.g. Num a => a -> a

question value availabilitye.g. String -> Maybe Int

verify client-server protocol dialogs?an exercise for reader ;)

Page 57: Why Haskell

Interfaces in OO . . .

Figure: Class definitions are married to the interfaces they implement.

Page 58: Why Haskell

Interfaces in Haskell: Typeclasses. . .

Decouple type definition from interface

Allow upstream implementations

Extend thirdparty libraries easily

Redefine implementations upstream

No meaningless "any type" functions

Very flexible

Page 59: Why Haskell

Interfaces in Haskell: Typeclasses. . .

Decouple type definition from interface

Allow upstream implementations

Extend thirdparty libraries easily

Redefine implementations upstream

No meaningless "any type" functions

Very flexible

Page 60: Why Haskell

Interfaces in Haskell: Typeclasses. . .

Decouple type definition from interface

Allow upstream implementations

Extend thirdparty libraries easily

Redefine implementations upstream

No meaningless "any type" functions

Very flexible

Page 61: Why Haskell

Interfaces in Haskell: Typeclasses. . .

Decouple type definition from interface

Allow upstream implementations

Extend thirdparty libraries easily

Redefine implementations upstream

No meaningless "any type" functions

Very flexible

Page 62: Why Haskell

Interfaces in Haskell: Typeclasses. . .

Decouple type definition from interface

Allow upstream implementations

Extend thirdparty libraries easily

Redefine implementations upstream

No meaningless "any type" functions

Very flexible

Page 63: Why Haskell

Interfaces in Haskell: Typeclasses. . .

Decouple type definition from interface

Allow upstream implementations

Extend thirdparty libraries easily

Redefine implementations upstream

No meaningless "any type" functions

Very flexible

Page 64: Why Haskell

class (Eq a) => Ord a wherecompare :: a -> a -> Orderingcompare x y | x == y = EQ

| x <= y = LT| otherwise = GT

(<), (>), (>=), (<=) :: a -> a -> Bool...max, min :: a -> a -> a...

Page 65: Why Haskell

Typically this just works . . .

data SimpleShape = Square { size :: Double }| Circle { radius :: Double }deriving (Eq, Ord, Show)

� We explicitly use the default definitions

. . . and when it doesn’t . . .

instance Ord SimpleShape where...

Page 66: Why Haskell

Are you awake?

Figure: http://absolutelymadness.tumblr.com/post/18126913457

Page 67: Why Haskell

Haskell Tooling: Libraries

Quite a few

Practical libraries

Often freely available

Permissive OSS licenses

Page 68: Why Haskell

Haskell Tooling: Libraries

Quite a few

Practical libraries

Often freely available

Permissive OSS licenses

Page 69: Why Haskell

Haskell Tooling: Libraries

Quite a few

Practical libraries

Often freely available

Permissive OSS licenses

Page 70: Why Haskell

Haskell Tooling: Libraries

Quite a few

Practical libraries

Often freely available

Permissive OSS licenses

Page 71: Why Haskell

Haskell Tooling: Runtime

Reasonably performantbetween JVM 7 and C# Mono performance

GC settings easily customized

Numerous other runtime options

Page 72: Why Haskell

Haskell Tooling: Runtime

Reasonably performantbetween JVM 7 and C# Mono performance

GC settings easily customized

Numerous other runtime options

Page 73: Why Haskell

Haskell Tooling: Runtime

Reasonably performantbetween JVM 7 and C# Mono performance

GC settings easily customized

Numerous other runtime options

Page 74: Why Haskell

Haskell Tooling: Tools

Testing toolsQuickCheck, HUnit

Documentation toolsHaddock, Hoogle (lookup documentation)

Build toolsCabal, cabal-dev, cabal-nirvana, see "next slide"

Page 75: Why Haskell

Haskell Tooling: Tools

Testing toolsQuickCheck, HUnit

Documentation toolsHaddock, Hoogle (lookup documentation)

Build toolsCabal, cabal-dev, cabal-nirvana, see "next slide"

Page 76: Why Haskell

Haskell Tooling: Tools

Testing toolsQuickCheck, HUnit

Documentation toolsHaddock, Hoogle (lookup documentation)

Build toolsCabal, cabal-dev, cabal-nirvana, see "next slide"

Page 77: Why Haskell

Haskell Tooling: DependencyManagement

Hackagedatabase of freely available Haskell libraries

Cabalgreat to get started, BUT . . .

cabal-dev & similarprovides sandboxing, list RVM with gemsets; more important for statically typed environments

cabal-nirvanathink compatible distribution snapshot of Hackage DB

Page 78: Why Haskell

Haskell Tooling: DependencyManagement

Hackagedatabase of freely available Haskell libraries

Cabalgreat to get started, BUT . . .

cabal-dev & similarprovides sandboxing, list RVM with gemsets; more important for statically typed environments

cabal-nirvanathink compatible distribution snapshot of Hackage DB

Page 79: Why Haskell

Haskell Tooling: DependencyManagement

Hackagedatabase of freely available Haskell libraries

Cabalgreat to get started, BUT . . .

cabal-dev & similarprovides sandboxing, list RVM with gemsets; more important for statically typed environments

cabal-nirvanathink compatible distribution snapshot of Hackage DB

Page 80: Why Haskell

Haskell Tooling: DependencyManagement

Hackagedatabase of freely available Haskell libraries

Cabalgreat to get started, BUT . . .

cabal-dev & similarprovides sandboxing, list RVM with gemsets; more important for statically typed environments

cabal-nirvanathink compatible distribution snapshot of Hackage DB

Page 81: Why Haskell

Haskell Tooling: Don’ts for Newbies

Use GHC (not HUGS)Hugs written for educational purposes not industrial usage

Forget what you know (imperative/OO)relearn programming in a functional-style

return is a function nameit does not mean return in the C/Java/C# way

class does not mean OO-classthink decoupled interface with optional default impelementations and a lot more power

Page 82: Why Haskell

Haskell Tooling: Don’ts for Newbies

Use GHC (not HUGS)Hugs written for educational purposes not industrial usage

Forget what you know (imperative/OO)relearn programming in a functional-style

return is a function nameit does not mean return in the C/Java/C# way

class does not mean OO-classthink decoupled interface with optional default impelementations and a lot more power

Page 83: Why Haskell

Haskell Tooling: Don’ts for Newbies

Use GHC (not HUGS)Hugs written for educational purposes not industrial usage

Forget what you know (imperative/OO)relearn programming in a functional-style

return is a function nameit does not mean return in the C/Java/C# way

class does not mean OO-classthink decoupled interface with optional default impelementations and a lot more power

Page 84: Why Haskell

Haskell Tooling: Don’ts for Newbies

Use GHC (not HUGS)Hugs written for educational purposes not industrial usage

Forget what you know (imperative/OO)relearn programming in a functional-style

return is a function nameit does not mean return in the C/Java/C# way

class does not mean OO-classthink decoupled interface with optional default impelementations and a lot more power

Page 85: Why Haskell

Haskell Tooling: Suggestions

Explicit language extensionsIntentionally and explicitly enable per module

Sandbox your buildswith cabal-dev or similar

Think in types and shapesand use Hoogle to lookup based on types and function "shapes"

Page 86: Why Haskell

Haskell Tooling: Suggestions

Explicit language extensionsIntentionally and explicitly enable per module

Sandbox your buildswith cabal-dev or similar

Think in types and shapesand use Hoogle to lookup based on types and function "shapes"

Page 87: Why Haskell

Haskell Tooling: Suggestions

Explicit language extensionsIntentionally and explicitly enable per module

Sandbox your buildswith cabal-dev or similar

Think in types and shapesand use Hoogle to lookup based on types and function "shapes"

Page 88: Why Haskell

Oh, the possibilities!Parallel / Concurrency Optionsthreads, dataflow, par, seq

"Cloud" HaskellA kind of Erlang/OTP clone in Haskell

Data Parallel HaskellGHC extensions to support nested data parallelism accounting, "Nepal"

Haskell’s Foreign Function Interface (FFI)Interface with native code from Haskell

GPU Programming in HaskellObsidian, Nikola, GpuGen, numerous papers on this too

Much more. . .Research meeting industrial application

Page 89: Why Haskell

Oh, the possibilities!Parallel / Concurrency Optionsthreads, dataflow, par, seq

"Cloud" HaskellA kind of Erlang/OTP clone in Haskell

Data Parallel HaskellGHC extensions to support nested data parallelism accounting, "Nepal"

Haskell’s Foreign Function Interface (FFI)Interface with native code from Haskell

GPU Programming in HaskellObsidian, Nikola, GpuGen, numerous papers on this too

Much more. . .Research meeting industrial application

Page 90: Why Haskell

Oh, the possibilities!Parallel / Concurrency Optionsthreads, dataflow, par, seq

"Cloud" HaskellA kind of Erlang/OTP clone in Haskell

Data Parallel HaskellGHC extensions to support nested data parallelism accounting, "Nepal"

Haskell’s Foreign Function Interface (FFI)Interface with native code from Haskell

GPU Programming in HaskellObsidian, Nikola, GpuGen, numerous papers on this too

Much more. . .Research meeting industrial application

Page 91: Why Haskell

Oh, the possibilities!Parallel / Concurrency Optionsthreads, dataflow, par, seq

"Cloud" HaskellA kind of Erlang/OTP clone in Haskell

Data Parallel HaskellGHC extensions to support nested data parallelism accounting, "Nepal"

Haskell’s Foreign Function Interface (FFI)Interface with native code from Haskell

GPU Programming in HaskellObsidian, Nikola, GpuGen, numerous papers on this too

Much more. . .Research meeting industrial application

Page 92: Why Haskell

Oh, the possibilities!Parallel / Concurrency Optionsthreads, dataflow, par, seq

"Cloud" HaskellA kind of Erlang/OTP clone in Haskell

Data Parallel HaskellGHC extensions to support nested data parallelism accounting, "Nepal"

Haskell’s Foreign Function Interface (FFI)Interface with native code from Haskell

GPU Programming in HaskellObsidian, Nikola, GpuGen, numerous papers on this too

Much more. . .Research meeting industrial application

Page 93: Why Haskell

Oh, the possibilities!Parallel / Concurrency Optionsthreads, dataflow, par, seq

"Cloud" HaskellA kind of Erlang/OTP clone in Haskell

Data Parallel HaskellGHC extensions to support nested data parallelism accounting, "Nepal"

Haskell’s Foreign Function Interface (FFI)Interface with native code from Haskell

GPU Programming in HaskellObsidian, Nikola, GpuGen, numerous papers on this too

Much more. . .Research meeting industrial application

Page 94: Why Haskell

Questions?

Figure: http://www.flickr.com/photos/42682395@N04/

@SusanPotter

Page 95: Why Haskell

Questions?

Figure: http://www.flickr.com/photos/42682395@N04/

@SusanPotter

Page 96: Why Haskell

Bonus: References / ResourcesChannel 9 Lectures (Erik Meijer)http://channel9.msdn.com/Shows/Going+Deep/

Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1

Learn You A Haskellhttp://learnyouahaskell.com

Haskell Reddithttp://www.reddit.com/r/haskell/

Haskell Cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe

Real World Haskellhttp://book.realworldhaskell.org/

Page 97: Why Haskell

Bonus: References / ResourcesChannel 9 Lectures (Erik Meijer)http://channel9.msdn.com/Shows/Going+Deep/

Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1

Learn You A Haskellhttp://learnyouahaskell.com

Haskell Reddithttp://www.reddit.com/r/haskell/

Haskell Cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe

Real World Haskellhttp://book.realworldhaskell.org/

Page 98: Why Haskell

Bonus: References / ResourcesChannel 9 Lectures (Erik Meijer)http://channel9.msdn.com/Shows/Going+Deep/

Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1

Learn You A Haskellhttp://learnyouahaskell.com

Haskell Reddithttp://www.reddit.com/r/haskell/

Haskell Cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe

Real World Haskellhttp://book.realworldhaskell.org/

Page 99: Why Haskell

Bonus: References / ResourcesChannel 9 Lectures (Erik Meijer)http://channel9.msdn.com/Shows/Going+Deep/

Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1

Learn You A Haskellhttp://learnyouahaskell.com

Haskell Reddithttp://www.reddit.com/r/haskell/

Haskell Cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe

Real World Haskellhttp://book.realworldhaskell.org/

Page 100: Why Haskell

Bonus: References / ResourcesChannel 9 Lectures (Erik Meijer)http://channel9.msdn.com/Shows/Going+Deep/

Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1

Learn You A Haskellhttp://learnyouahaskell.com

Haskell Reddithttp://www.reddit.com/r/haskell/

Haskell Cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe

Real World Haskellhttp://book.realworldhaskell.org/

Page 101: Why Haskell

Bonus: Brief QuickCheck Example

module Tests where

import Test.QuickCheck (quickCheck)

propReverseReverse :: [Char] -> BoolpropReverseReverse s = (reverse . reverse) s == s

� excuse the weird syntax form, indenting didn’t show up ;(main = do {quickCheck propReverseReverse }