Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
The Next Great Functional
Programming Language
(OK, not really.)
John A. De Goes — @jdegoes
ML - 1973
Haskell - 19901
OCaml - 19962
2
Or 1987 if you count Caml.
1
Or 1985 if you count Miranda.
Haskell
Haskellz
144 quadrillion flavors.
!
Our Best FPLs Suffer from
Decades Worth of
Accretion
Individual Features were
Designed, but the FPLs
Came Into Existence
What Would a Designed
FPL Look Like Today?
?
!
[This Slide Intentionally Left Blank]
My Ideal FPL
4 Pattern Matching
4 Records
4 Modules
4 Syntax
4 Type Classes
4 Nominative Typing
4 Data
4 Recursion
! Pattern Matching
Pattern Matching
import Lens.Family.Total
import Lens.Family.Stock
total :: Either Char Int -> String -- Same as:
total = ...
! Records
Records
val book =
("author" ->> "Benjamin Pierce") ::
("title" ->> "Types and Programming Languages") ::
("id" ->> 262162...
! Modules
Modules
structure ListStack :> STACK =
struct
type t = 'a list
[...]
end
Modules
data Stack f = Stack
{ makeNew :: forall a. f a,
push :: forall a. a -> f a -> f a,
pop :: forall a. f a -> Maybe ...
Modules
data Stack f = Stack
{ makeNew :: forall a. f a,
push :: forall a. a -> f a -> f a,
pop :: forall a. f a -> Maybe ...
! Syntax
Syntax
Let's stop pretending programs are strings of ASCII
characters.
4 implicits
4 order of function parameters / applic...
! Type Classes
Type Classes
Just 'records' with compiler-enforced laws.3
3
Type classes also add an implicitly applied (a : Type) -> Type...
! Partiality
Partiality
If it's partial, it's not a &^@#% function.
! Nominative Typing
Nominative Typing
data Email = Email String
data DOMId = DOMId String
data Positive = Positive Float
data Negative = Negat...
Nominative Typing
data ??? = ??? String
data ??? = ??? String
data ??? = ??? Float
data ??? = ??? Float
data ??? = ??? Flo...
Let's Stop Pretending
Differences in Names
Actually Matter
Nominative Typing
Let's play a guessing game.
data ??? = ??? -- {v: Float | v > 0}
data ??? = ??? -- {v: Float | v < 0}
! Data
Data
Data: Bits-based description.
data Either a b = Left a | Right b
struct either {
int tag;
union {
void *left;
void *r...
Data
Newbies: addicted to pattern matching.
data List a = Nil | Cons a (List a)
doSomething :: forall a. List a -> Int
doS...
Data
Pros: addicted to folds.
fold :: forall z a. z -> (z -> a -> z) -> List a -> z
fold z _ Nil = z
fold z f (Cons a l) =...
Data
Folds: Capability-based description.
fold :: forall z a. z -> (z -> a -> z) -> List a -> z
data List a = List (forall...
Data
data List a = List (forall z. z -> (z -> a -> z) -> z)
nil = z f -> z
cons a (List as) = z f -> as (f a z) f
Array? L...
! Recursion
Recursion
Goto of functional programming.5
f x = if x / 2 > x then g (2 * x) else 42
g x = if x % 1 == 0 then f (g (x + 1)...
Recursion
Induction -> Folds.
Recursion
Coinduction -> State Machines.
type Machine s a b = (s, (s, a) -> (s, b))
6
6
Except this is too weakly typed.
My Ideal FPL
My Ideal FPL
Layered like an onion.
4 Turing incomplete for 99% of program
4 Prove / optimize more
4 Turing complete 'driv...
My Ideal FPL
Structured editor.
4 Friendly FP
4 Destroys motivation for most language 'features'
My Ideal FPL
All the things are values.
4 Math functions
4 Abolish incidental complexity
4 Abolish artificial distinctions
My Ideal FPL
Proof search.
4 Turing complete
4 Levels of proof
1. Proven true
2. Evidence for truth but not proven true
3....
My Ideal FPL
Zero cost abstraction.
4 As long as we're shooting for the moon
4 (But genuinely easier w/o recursion/data)
Inspirations
4 Unison Programming Language7
4 LiquidHaskell8
4 Morte9
9
http://www.haskellforall.com/2014/09/morte-interme...
THANK YOU
John A. De Goes — @jdegoes
Upcoming SlideShare
Loading in …5
×

The Next Great Functional Programming Language

3,587 views

Published on

A LambdaConf 2015 talk.

John has no clue what the next great functional programming language will be like, but he's more than happy to hop up on stage and rant against type classes, nominative typing, data, modules, pattern matching, recursion, and, well, basically everything else you associate with functional programming! John will argue that to make radical progress in cheaply building correct software, we need to take one step backward and two steps forward, embracing dependent-typing, total functions, Turing-complete compilers, host languages, and automated proof search. Attend this talk to question your assumptions about functional programming... or just to heckle! Either way, all are welcome.

Published in: Software, Technology
  • Nice !! Download 100 % Free Ebooks, PPts, Study Notes, Novels, etc @ https://www.ThesisScientist.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hello! Get Your Professional Job-Winning Resume Here - Check our website! https://vk.cc/818RFv
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

The Next Great Functional Programming Language

  1. 1. The Next Great Functional Programming Language (OK, not really.) John A. De Goes — @jdegoes
  2. 2. ML - 1973 Haskell - 19901 OCaml - 19962 2 Or 1987 if you count Caml. 1 Or 1985 if you count Miranda.
  3. 3. Haskell
  4. 4. Haskellz 144 quadrillion flavors. !
  5. 5. Our Best FPLs Suffer from Decades Worth of Accretion
  6. 6. Individual Features were Designed, but the FPLs Came Into Existence
  7. 7. What Would a Designed FPL Look Like Today?
  8. 8. ?
  9. 9. !
  10. 10. [This Slide Intentionally Left Blank]
  11. 11. My Ideal FPL 4 Pattern Matching 4 Records 4 Modules 4 Syntax 4 Type Classes 4 Nominative Typing 4 Data 4 Recursion
  12. 12. ! Pattern Matching
  13. 13. Pattern Matching import Lens.Family.Total import Lens.Family.Stock total :: Either Char Int -> String -- Same as: total = _case -- total = case & on _Left (c -> replicate 3 c ) -- Left c -> replicate 3 c & on _Right (n -> replicate n '!') -- Right n -> replicate n '!'
  14. 14. ! Records
  15. 15. Records val book = ("author" ->> "Benjamin Pierce") :: ("title" ->> "Types and Programming Languages") :: ("id" ->> 262162091) :: ("price" ->> 44.11) :: HNil scala> book("author") // Note result type ... res0: String = Benjamin Pierce scala> val extended = book + ("inPrint" ->> true) // Add a new field extended: ... complex type elided ... = Benjamin Pierce :: Types and Programming Languages :: 262162091 :: 46.11 :: true :: HNil scala> val noId = extended - "id" // Removed a field noId: ... complex type elided ... = Benjamin Pierce :: Types and Programming Languages :: 46.11 :: true :: HNil
  16. 16. ! Modules
  17. 17. Modules structure ListStack :> STACK = struct type t = 'a list [...] end
  18. 18. Modules data Stack f = Stack { makeNew :: forall a. f a, push :: forall a. a -> f a -> f a, pop :: forall a. f a -> Maybe (Tuple a (f a)) } doSomeStackStuff :: forall f. Stack f -> Thing
  19. 19. Modules data Stack f = Stack { makeNew :: forall a. f a, push :: forall a. a -> f a -> f a, pop :: forall a. f a -> Maybe (Tuple a (f a)) } data ReservationSystem f = ReservationSystem (forall g. Stack g -> { ... })
  20. 20. ! Syntax
  21. 21. Syntax Let's stop pretending programs are strings of ASCII characters. 4 implicits 4 order of function parameters / application 4 compiler errors 4 funky looking operators 4 scopes 4 Haskell-style (fake) modules & imports 4 name clashes 4 information elision 4 ...
  22. 22. ! Type Classes
  23. 23. Type Classes Just 'records' with compiler-enforced laws.3 3 Type classes also add an implicitly applied (a : Type) -> TypeClass a function that's piecewise- defined, but that's just syntax.
  24. 24. ! Partiality
  25. 25. Partiality If it's partial, it's not a &^@#% function.
  26. 26. ! Nominative Typing
  27. 27. Nominative Typing data Email = Email String data DOMId = DOMId String data Positive = Positive Float data Negative = Negative Float data DressSize = DressSize Float
  28. 28. Nominative Typing data ??? = ??? String data ??? = ??? String data ??? = ??? Float data ??? = ??? Float data ??? = ??? Float
  29. 29. Let's Stop Pretending Differences in Names Actually Matter
  30. 30. Nominative Typing Let's play a guessing game. data ??? = ??? -- {v: Float | v > 0} data ??? = ??? -- {v: Float | v < 0}
  31. 31. ! Data
  32. 32. Data Data: Bits-based description. data Either a b = Left a | Right b struct either { int tag; union { void *left; void *right; }; };
  33. 33. Data Newbies: addicted to pattern matching. data List a = Nil | Cons a (List a) doSomething :: forall a. List a -> Int doSomething Nil = 0 doSomething (Cons _ l) = 1 + doSomething l
  34. 34. Data Pros: addicted to folds. fold :: forall z a. z -> (z -> a -> z) -> List a -> z fold z _ Nil = z fold z f (Cons a l) = fold (f z a) l
  35. 35. Data Folds: Capability-based description. fold :: forall z a. z -> (z -> a -> z) -> List a -> z data List a = List (forall z. z -> (z -> a -> z) -> z)
  36. 36. Data data List a = List (forall z. z -> (z -> a -> z) -> z) nil = z f -> z cons a (List as) = z f -> as (f a z) f Array? Linked List? Vector? Skip List?4 4 Strictly more powerful than a data List (pros & cons).
  37. 37. ! Recursion
  38. 38. Recursion Goto of functional programming.5 f x = if x / 2 > x then g (2 * x) else 42 g x = if x % 1 == 0 then f (g (x + 1)) else h (x - 1) h x = if x % 1 == 1 then f (x * 2 + 1) else g (x + 1) 5 What's hard for a machine|human to understand is also hard for a human|machine to understand.
  39. 39. Recursion Induction -> Folds.
  40. 40. Recursion Coinduction -> State Machines. type Machine s a b = (s, (s, a) -> (s, b)) 6 6 Except this is too weakly typed.
  41. 41. My Ideal FPL
  42. 42. My Ideal FPL Layered like an onion. 4 Turing incomplete for 99% of program 4 Prove / optimize more 4 Turing complete 'driver' 4 Prove / optimize less 4 Possibly in a different language (e.g. Haskell)
  43. 43. My Ideal FPL Structured editor. 4 Friendly FP 4 Destroys motivation for most language 'features'
  44. 44. My Ideal FPL All the things are values. 4 Math functions 4 Abolish incidental complexity 4 Abolish artificial distinctions
  45. 45. My Ideal FPL Proof search. 4 Turing complete 4 Levels of proof 1. Proven true 2. Evidence for truth but not proven true 3. Proven false (in general or by counterexample) 4 Massive, persistent proof databases 4 Cross-disciplinary research 4 e.g. deep learning to accelerate proof search
  46. 46. My Ideal FPL Zero cost abstraction. 4 As long as we're shooting for the moon 4 (But genuinely easier w/o recursion/data)
  47. 47. Inspirations 4 Unison Programming Language7 4 LiquidHaskell8 4 Morte9 9 http://www.haskellforall.com/2014/09/morte-intermediate-language-for-super.html 8 http://goto.ucsd.edu/~rjhala/liquid/haskell/blog/ 7 http://unisonweb.org
  48. 48. THANK YOU John A. De Goes — @jdegoes

×