🗊Презентация Wearing the hair shirt. A retrospective on Haskell

Нажмите для полного просмотра!
Wearing the hair shirt. A retrospective on Haskell, слайд №1Wearing the hair shirt. A retrospective on Haskell, слайд №2Wearing the hair shirt. A retrospective on Haskell, слайд №3Wearing the hair shirt. A retrospective on Haskell, слайд №4Wearing the hair shirt. A retrospective on Haskell, слайд №5Wearing the hair shirt. A retrospective on Haskell, слайд №6Wearing the hair shirt. A retrospective on Haskell, слайд №7Wearing the hair shirt. A retrospective on Haskell, слайд №8Wearing the hair shirt. A retrospective on Haskell, слайд №9Wearing the hair shirt. A retrospective on Haskell, слайд №10Wearing the hair shirt. A retrospective on Haskell, слайд №11Wearing the hair shirt. A retrospective on Haskell, слайд №12Wearing the hair shirt. A retrospective on Haskell, слайд №13Wearing the hair shirt. A retrospective on Haskell, слайд №14Wearing the hair shirt. A retrospective on Haskell, слайд №15Wearing the hair shirt. A retrospective on Haskell, слайд №16Wearing the hair shirt. A retrospective on Haskell, слайд №17Wearing the hair shirt. A retrospective on Haskell, слайд №18Wearing the hair shirt. A retrospective on Haskell, слайд №19Wearing the hair shirt. A retrospective on Haskell, слайд №20Wearing the hair shirt. A retrospective on Haskell, слайд №21Wearing the hair shirt. A retrospective on Haskell, слайд №22Wearing the hair shirt. A retrospective on Haskell, слайд №23Wearing the hair shirt. A retrospective on Haskell, слайд №24Wearing the hair shirt. A retrospective on Haskell, слайд №25Wearing the hair shirt. A retrospective on Haskell, слайд №26Wearing the hair shirt. A retrospective on Haskell, слайд №27Wearing the hair shirt. A retrospective on Haskell, слайд №28Wearing the hair shirt. A retrospective on Haskell, слайд №29Wearing the hair shirt. A retrospective on Haskell, слайд №30Wearing the hair shirt. A retrospective on Haskell, слайд №31Wearing the hair shirt. A retrospective on Haskell, слайд №32Wearing the hair shirt. A retrospective on Haskell, слайд №33Wearing the hair shirt. A retrospective on Haskell, слайд №34Wearing the hair shirt. A retrospective on Haskell, слайд №35Wearing the hair shirt. A retrospective on Haskell, слайд №36Wearing the hair shirt. A retrospective on Haskell, слайд №37Wearing the hair shirt. A retrospective on Haskell, слайд №38Wearing the hair shirt. A retrospective on Haskell, слайд №39Wearing the hair shirt. A retrospective on Haskell, слайд №40Wearing the hair shirt. A retrospective on Haskell, слайд №41Wearing the hair shirt. A retrospective on Haskell, слайд №42Wearing the hair shirt. A retrospective on Haskell, слайд №43Wearing the hair shirt. A retrospective on Haskell, слайд №44Wearing the hair shirt. A retrospective on Haskell, слайд №45Wearing the hair shirt. A retrospective on Haskell, слайд №46Wearing the hair shirt. A retrospective on Haskell, слайд №47Wearing the hair shirt. A retrospective on Haskell, слайд №48Wearing the hair shirt. A retrospective on Haskell, слайд №49Wearing the hair shirt. A retrospective on Haskell, слайд №50Wearing the hair shirt. A retrospective on Haskell, слайд №51Wearing the hair shirt. A retrospective on Haskell, слайд №52Wearing the hair shirt. A retrospective on Haskell, слайд №53Wearing the hair shirt. A retrospective on Haskell, слайд №54Wearing the hair shirt. A retrospective on Haskell, слайд №55Wearing the hair shirt. A retrospective on Haskell, слайд №56Wearing the hair shirt. A retrospective on Haskell, слайд №57Wearing the hair shirt. A retrospective on Haskell, слайд №58Wearing the hair shirt. A retrospective on Haskell, слайд №59Wearing the hair shirt. A retrospective on Haskell, слайд №60Wearing the hair shirt. A retrospective on Haskell, слайд №61Wearing the hair shirt. A retrospective on Haskell, слайд №62Wearing the hair shirt. A retrospective on Haskell, слайд №63Wearing the hair shirt. A retrospective on Haskell, слайд №64Wearing the hair shirt. A retrospective on Haskell, слайд №65

Содержание

Вы можете ознакомиться и скачать презентацию на тему Wearing the hair shirt. A retrospective on Haskell. Доклад-сообщение содержит 65 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1





Wearing the hair shirt
A retrospective on Haskell
Simon Peyton Jones
Microsoft Research, Cambridge
Описание слайда:
Wearing the hair shirt A retrospective on Haskell Simon Peyton Jones Microsoft Research, Cambridge

Слайд 2





The primoridal soup
FPCA, Sept 1987: initial meeting. A dozen lazy functional programmers, wanting to agree on a common language.
Suitable for teaching, research, and application
Formally-described syntax and semantics
Freely available 
Embody the apparent consensus of ideas
Reduce unnecessary diversity
Led to...a succession of face-to-face meetings
		April 1990: Haskell 1.0 report released 
	(editors: Hudak, Wadler)
Описание слайда:
The primoridal soup FPCA, Sept 1987: initial meeting. A dozen lazy functional programmers, wanting to agree on a common language. Suitable for teaching, research, and application Formally-described syntax and semantics Freely available Embody the apparent consensus of ideas Reduce unnecessary diversity Led to...a succession of face-to-face meetings April 1990: Haskell 1.0 report released (editors: Hudak, Wadler)

Слайд 3





Timeline
Описание слайда:
Timeline

Слайд 4





Haskell 98
Описание слайда:
Haskell 98

Слайд 5





Reflections on the process
The idea of having a fixed standard (Haskell 98) in parallel with an evolving language, has worked really well
Formal semantics only for fragments (but see [Faxen2002])
A smallish, rather pointy-headed user-base makes Haskell nimble.  Haskell has evolved rapidly and continues to do so.
	Motto: avoid success at all costs
Описание слайда:
Reflections on the process The idea of having a fixed standard (Haskell 98) in parallel with an evolving language, has worked really well Formal semantics only for fragments (but see [Faxen2002]) A smallish, rather pointy-headed user-base makes Haskell nimble. Haskell has evolved rapidly and continues to do so. Motto: avoid success at all costs

Слайд 6





The price of usefulness
Libraries increasingly important:
1996: Separate libraries Report 
2001: Hierarchical library naming structure, increasingly populated
Foreign-function interface increasingly important
1993 onwards: a variety of experiments
2001: successful effort to standardise a FFI across implementations
Any language large enough to be useful is dauntingly complex
Описание слайда:
The price of usefulness Libraries increasingly important: 1996: Separate libraries Report 2001: Hierarchical library naming structure, increasingly populated Foreign-function interface increasingly important 1993 onwards: a variety of experiments 2001: successful effort to standardise a FFI across implementations Any language large enough to be useful is dauntingly complex

Слайд 7


Wearing the hair shirt. A retrospective on Haskell, слайд №7
Описание слайда:

Слайд 8





Syntax
Syntax is not important
Parsing is the easy bit of a compiler
Описание слайда:
Syntax Syntax is not important Parsing is the easy bit of a compiler

Слайд 9





Syntax
Syntax is not important
Syntax is the user interface of a language
Parsing is the easy bit of a compiler
The parser is often the trickiest bit of a compiler
Описание слайда:
Syntax Syntax is not important Syntax is the user interface of a language Parsing is the easy bit of a compiler The parser is often the trickiest bit of a compiler

Слайд 10





Good ideas from other languages
List comprehensions
Описание слайда:
Good ideas from other languages List comprehensions

Слайд 11





Fat vs thin
Описание слайда:
Fat vs thin

Слайд 12





“Declaration style” 
Define a function as a series of independent equations
Описание слайда:
“Declaration style” Define a function as a series of independent equations

Слайд 13





“Expression style” 
Define a function as an expression
Описание слайда:
“Expression style” Define a function as an expression

Слайд 14





Example (ICFP02 prog comp)
Описание слайда:
Example (ICFP02 prog comp)

Слайд 15





So much for syntax...
Описание слайда:
So much for syntax...

Слайд 16





What really matters?
Laziness
Type classes 
Sexy types
Описание слайда:
What really matters? Laziness Type classes Sexy types

Слайд 17





Laziness
John Hughes’s famous paper “Why functional programming matters”
Modular programming needs powerful glue
Lazy evaluation enables new forms of modularity; in particular, separating generation from selection.
Non-strict semantics means that unrestricted beta substitution is OK.
Описание слайда:
Laziness John Hughes’s famous paper “Why functional programming matters” Modular programming needs powerful glue Lazy evaluation enables new forms of modularity; in particular, separating generation from selection. Non-strict semantics means that unrestricted beta substitution is OK.

Слайд 18





But...
Laziness makes it much, much harder to reason about performance, especially space.  Tricky uses of seq for effect	seq :: a -> b -> b
Laziness has a real implementation cost
Laziness can be added to a strict language (although not as easily as you might think)
And it’s not so bad only having V instead of 
Описание слайда:
But... Laziness makes it much, much harder to reason about performance, especially space. Tricky uses of seq for effect seq :: a -> b -> b Laziness has a real implementation cost Laziness can be added to a strict language (although not as easily as you might think) And it’s not so bad only having V instead of 

Слайд 19





In favour of laziness
Laziness is jolly convenient
Описание слайда:
In favour of laziness Laziness is jolly convenient

Слайд 20





Combinator libraries
Recursive values are jolly useful
Описание слайда:
Combinator libraries Recursive values are jolly useful

Слайд 21


Wearing the hair shirt. A retrospective on Haskell, слайд №21
Описание слайда:

Слайд 22





Laziness keeps you honest
Every call-by-value language has given into the siren call of side effects 
But in Haskell
	(print “yes”) + (print “no”)
just does not make sense.  Even worse is
	[print “yes”, print “no”]
So effects (I/O, references, exceptions) are just not an option.
Result: prolonged embarrassment.  Stream-based I/O, continuation I/O... 
but NO DEALS WIH THE DEVIL
Описание слайда:
Laziness keeps you honest Every call-by-value language has given into the siren call of side effects But in Haskell (print “yes”) + (print “no”) just does not make sense. Even worse is [print “yes”, print “no”] So effects (I/O, references, exceptions) are just not an option. Result: prolonged embarrassment. Stream-based I/O, continuation I/O... but NO DEALS WIH THE DEVIL

Слайд 23





Monadic I/O
A value of type (IO t) is an “action” that, when performed, may do some input/output before delivering a result of type t.
Описание слайда:
Monadic I/O A value of type (IO t) is an “action” that, when performed, may do some input/output before delivering a result of type t.

Слайд 24





Performing I/O
A program is a single I/O action
Running the program performs the action
Can’t do I/O from pure code.
Result: clean separation of pure code from imperative code
Описание слайда:
Performing I/O A program is a single I/O action Running the program performs the action Can’t do I/O from pure code. Result: clean separation of pure code from imperative code

Слайд 25





Connecting I/O operations
Описание слайда:
Connecting I/O operations

Слайд 26





The do-notation
Syntactic sugar only
Easy translation into (>>=), return
Deliberately imperative “look and feel”
Описание слайда:
The do-notation Syntactic sugar only Easy translation into (>>=), return Deliberately imperative “look and feel”

Слайд 27





Control structures
Описание слайда:
Control structures

Слайд 28





Generalising the idea
Описание слайда:
Generalising the idea

Слайд 29





Monads
Описание слайда:
Monads

Слайд 30





Example: a type checker
Описание слайда:
Example: a type checker

Слайд 31





The IO monad
Описание слайда:
The IO monad

Слайд 32





What have we achieved?
Описание слайда:
What have we achieved?

Слайд 33





What have we achieved?
Описание слайда:
What have we achieved?

Слайд 34





What we have not achieved
Описание слайда:
What we have not achieved

Слайд 35





Open challenge 1
Описание слайда:
Open challenge 1

Слайд 36





Open challenge 2
Описание слайда:
Open challenge 2

Слайд 37





Monad summary
Monads are a beautiful example of a theory-into-practice (more the thought pattern than actual theorems)
Hidden effects are like hire-purchase: pay nothing now, but it catches up with you in the end
Enforced purity is like paying up front: painful on Day 1, but usually worth it
But we made one big mistake...
Описание слайда:
Monad summary Monads are a beautiful example of a theory-into-practice (more the thought pattern than actual theorems) Hidden effects are like hire-purchase: pay nothing now, but it catches up with you in the end Enforced purity is like paying up front: painful on Day 1, but usually worth it But we made one big mistake...

Слайд 38





Our biggest mistake
Using the scary term “monad” 
rather than 
“warm fuzzy thing”
Описание слайда:
Our biggest mistake Using the scary term “monad” rather than “warm fuzzy thing”

Слайд 39





What really matters?
Laziness
Purity and monads
Type classes 
 Sexy types
Описание слайда:
What really matters? Laziness Purity and monads Type classes Sexy types

Слайд 40





SLPJ conclusions
Purity is more important than, and quite independent of, laziness
The next ML will be pure, with effects only via monads.  The next Haskell will be strict, but still pure.
Still unclear exactly how to add laziness to a strict language.  For example, do we want a type distinction between (say) a lazy Int and a strict Int?
Описание слайда:
SLPJ conclusions Purity is more important than, and quite independent of, laziness The next ML will be pure, with effects only via monads. The next Haskell will be strict, but still pure. Still unclear exactly how to add laziness to a strict language. For example, do we want a type distinction between (say) a lazy Int and a strict Int?

Слайд 41


Wearing the hair shirt. A retrospective on Haskell, слайд №41
Описание слайда:

Слайд 42





Type classes
Initially, just a neat way to get systematic overloading of (==), read, show.
Описание слайда:
Type classes Initially, just a neat way to get systematic overloading of (==), read, show.

Слайд 43





Implementing type classes
Описание слайда:
Implementing type classes

Слайд 44





Type classes over time
Type classes are the most unusual feature of Haskell’s type system
Описание слайда:
Type classes over time Type classes are the most unusual feature of Haskell’s type system

Слайд 45





Type classes are useful
	Type classes have proved extraordinarily convenient in practice
Equality, ordering, serialisation, numerical operations, and not just the built-in ones (e.g. pretty-printing, time-varying values)
Monadic operations
Описание слайда:
Type classes are useful Type classes have proved extraordinarily convenient in practice Equality, ordering, serialisation, numerical operations, and not just the built-in ones (e.g. pretty-printing, time-varying values) Monadic operations

Слайд 46





Quickcheck
	ghci> quickCheck propRev
	OK: passed 100 tests

	ghci> quickCheck propRevApp
	OK: passed 100 tests
Quickcheck (which is just a Haskell 98 library)
 Works out how many arguments
 Generates suitable test data
 Runs tests
Описание слайда:
Quickcheck ghci> quickCheck propRev OK: passed 100 tests ghci> quickCheck propRevApp OK: passed 100 tests Quickcheck (which is just a Haskell 98 library) Works out how many arguments Generates suitable test data Runs tests

Слайд 47





Quickcheck
Описание слайда:
Quickcheck

Слайд 48





Extensiblity
Like OOP, one can add new data types “later”.  E.g. QuickCheck works for your new data types (provided you make them instances of Arby)
...but also not like OOP
Описание слайда:
Extensiblity Like OOP, one can add new data types “later”. E.g. QuickCheck works for your new data types (provided you make them instances of Arby) ...but also not like OOP

Слайд 49





Type-based dispatch
A bit like OOP, except that method suite passed separately?  
	double :: Num a => a -> a
	double x = x+x
No: type classes implement type-based dispatch, not value-based dispatch
Описание слайда:
Type-based dispatch A bit like OOP, except that method suite passed separately? double :: Num a => a -> a double x = x+x No: type classes implement type-based dispatch, not value-based dispatch

Слайд 50





Type-based dispatch
double :: Num a => a -> a
double x = 2*x
		means 
double :: Num a -> a -> a
double d x = mul d (fromInteger d 2) x
The overloaded value is returned by fromInteger, not passed to it.  It is the dictionary (and type) that are passed as argument to fromInteger
Описание слайда:
Type-based dispatch double :: Num a => a -> a double x = 2*x means double :: Num a -> a -> a double d x = mul d (fromInteger d 2) x The overloaded value is returned by fromInteger, not passed to it. It is the dictionary (and type) that are passed as argument to fromInteger

Слайд 51





Type-based dispatch
So the links to intensional polymorphism are much closer than the links to OOP.
The dictionary is like a proxy for the (interesting aspects of) the type argument of a polymorphic function.
f :: forall a. a -> Int
f t (x::t) = ...typecase t...

f :: forall a. C a => a -> Int
f x = ...(call method of C)...
Описание слайда:
Type-based dispatch So the links to intensional polymorphism are much closer than the links to OOP. The dictionary is like a proxy for the (interesting aspects of) the type argument of a polymorphic function. f :: forall a. a -> Int f t (x::t) = ...typecase t... f :: forall a. C a => a -> Int f x = ...(call method of C)...

Слайд 52





Cool generalisations
Multi-parameter type classes
Higher-kinded type variables (a.k.a. constructor classes)
Overlapping instances
Functional dependencies (Jones ESOP’00)
Type classes as logic programs (Neubauer et al POPL’02)
Описание слайда:
Cool generalisations Multi-parameter type classes Higher-kinded type variables (a.k.a. constructor classes) Overlapping instances Functional dependencies (Jones ESOP’00) Type classes as logic programs (Neubauer et al POPL’02)

Слайд 53





Qualified types
Type classes are an example of qualified types [Jones thesis].  Main features
types of form   .Q => 
qualifiers Q are witnessed by run-time evidence
Known examples
type classes (evidence = tuple of methods)
implicit parameters (evidence = value of implicit param)
extensible records (evidence = offset of field in record)
Another unifying idea: Constraint Handling Rules (Stucky/Sulzmann ICFP’02)
Описание слайда:
Qualified types Type classes are an example of qualified types [Jones thesis]. Main features types of form .Q =>  qualifiers Q are witnessed by run-time evidence Known examples type classes (evidence = tuple of methods) implicit parameters (evidence = value of implicit param) extensible records (evidence = offset of field in record) Another unifying idea: Constraint Handling Rules (Stucky/Sulzmann ICFP’02)

Слайд 54





Type classes summary
Описание слайда:
Type classes summary

Слайд 55


Wearing the hair shirt. A retrospective on Haskell, слайд №55
Описание слайда:

Слайд 56





Sexy types
	Haskell has become a laboratory and playground for advanced type hackery
Polymorphic recursion
Higher kinded type variables
data T k a = T a (k (T k a))
Polymorphic functions as constructor arguments
data T = MkT (forall a. [a] -> [a])
Polymorphic functions as arbitrary function arguments (higher ranked types)
f :: (forall a. [a]->[a]) -> ...
Existential types
data T = exists a. Show a => MkT a
Описание слайда:
Sexy types Haskell has become a laboratory and playground for advanced type hackery Polymorphic recursion Higher kinded type variables data T k a = T a (k (T k a)) Polymorphic functions as constructor arguments data T = MkT (forall a. [a] -> [a]) Polymorphic functions as arbitrary function arguments (higher ranked types) f :: (forall a. [a]->[a]) -> ... Existential types data T = exists a. Show a => MkT a

Слайд 57





Is sexy good?  Yes!
Well typed programs don’t go wrong
Less mundanely (but more allusively) sexy types let you think higher thoughts and still stay [almost] sane:
deeply higher-order functions
functors
folds and unfolds
monads and monad transformers
arrows (now finding application in real-time reactive programming)
short-cut deforestation
bootstrapped data structures
Описание слайда:
Is sexy good? Yes! Well typed programs don’t go wrong Less mundanely (but more allusively) sexy types let you think higher thoughts and still stay [almost] sane: deeply higher-order functions functors folds and unfolds monads and monad transformers arrows (now finding application in real-time reactive programming) short-cut deforestation bootstrapped data structures

Слайд 58





How sexy?
Damas-Milner is on a cusp: 
Can infer most-general types without any type annotations at all
But virtually any extension destroys this property
Adding type quite modest type annotations lets us go a LOT further (as we have already seen) without losing inference for most of the program.
Still missing from even the sexiest Haskell impls
 at the type level
Subtyping
Impredicativity
Описание слайда:
How sexy? Damas-Milner is on a cusp: Can infer most-general types without any type annotations at all But virtually any extension destroys this property Adding type quite modest type annotations lets us go a LOT further (as we have already seen) without losing inference for most of the program. Still missing from even the sexiest Haskell impls  at the type level Subtyping Impredicativity

Слайд 59





Destination = Fw<:
Open question
What is a good design for user-level type annotation that exposes the power of Fw or Fw<:, but co-exists with type inference?
Описание слайда:
Destination = Fw<: Open question What is a good design for user-level type annotation that exposes the power of Fw or Fw<:, but co-exists with type inference?

Слайд 60





Modules
Описание слайда:
Modules

Слайд 61





Modules
Описание слайда:
Modules

Слайд 62





Modules
Haskell has many features that overlap with what ML-style modules offer:
type classes
first class universals and existentials
Does Haskell need functors anyway?  No: one seldom needs to instantiate the same functor at different arguments
But Haskell lacks a way to distribute “open” libraries, where the client provides some base modules; need module signatures and type-safe linking (e.g. PLT,Knit?).   not !
Wanted: a design with better power, but good power/weight.
Описание слайда:
Modules Haskell has many features that overlap with what ML-style modules offer: type classes first class universals and existentials Does Haskell need functors anyway? No: one seldom needs to instantiate the same functor at different arguments But Haskell lacks a way to distribute “open” libraries, where the client provides some base modules; need module signatures and type-safe linking (e.g. PLT,Knit?).  not ! Wanted: a design with better power, but good power/weight.

Слайд 63





Encapsulating it all
Описание слайда:
Encapsulating it all

Слайд 64





Encapsulating it all
Описание слайда:
Encapsulating it all

Слайд 65





The Haskell committee
Описание слайда:
The Haskell committee



Похожие презентации
Mypresentation.ru
Загрузить презентацию