Fireship · @fireship

Haskell in 100 Seconds

Uploaded November 29, 2021 · Length 2:30

Haskell in 100 Seconds

Summary

haskell tutorial for beginners, covering its functional programming paradigm, lambda calculus, and immutable data

  • haskell programming language
  • functional programming
  • lambda calculus
  • immutable data
  • haskell tutorial

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    haskell a statically typed

  2. 0:01

    general-purpose language made famous for

  3. 0:03

    expanding the minds of developers into

  4. 0:05

    the functional programming paradigm you

  5. 0:07

    see haskell is a purely functional

  6. 0:09

    language based on lambda calculus which

  7. 0:11

    means a function always produces the

  8. 0:13

    same output given the same input unlike

  9. 0:15

    an imperative language your code can't

  10. 0:17

    modify the inputs or produce side

  11. 0:19

    effects that would otherwise change the

  12. 0:20

    behavior of the application it was first

  13. 0:22

    developed in 1987 and named after

  14. 0:25

    logician haskell curry whose work had a

  15. 0:27

    massive influence on the functional

  16. 0:29

    programming world it's been used to

  17. 0:30

    build a wide variety of server-side

  18. 0:32

    applications like the hasura api

  19. 0:34

    platform spam filtering at facebook and

  20. 0:37

    compilers for other languages like elm

  21. 0:39

    and purescript and it's responsible for

  22. 0:41

    a countless number of blog posts about

  23. 0:42

    monads in haskell you write declarative

  24. 0:45

    code where the program is a single

  25. 0:46

    expression that is executed by

  26. 0:48

    evaluating that expression it also uses

  27. 0:50

    lazy evaluation which means an

  28. 0:52

    expression is not evaluated until it's

  29. 0:55

    actually used by a function this can

  30. 0:56

    result in big performance gains but

  31. 0:58

    unpredictable memory use at runtime all

  32. 1:00

    data in a haskell program is immutable

  33. 1:02

    which produces a lot of memory garbage

  34. 1:04

    so it contains a garbage collector to

  35. 1:06

    clean things up to get started install

  36. 1:08

    the glasgow haskell compiler then create

  37. 1:10

    a file ending in dot hs we don't work

  38. 1:12

    with statements here only expressions

  39. 1:14

    which is code that will always evaluate

  40. 1:16

    to a value create a string with double

  41. 1:18

    quotes then give it a name with the

  42. 1:20

    equal sign the value is immutable and

  43. 1:22

    can never be changed the type will

  44. 1:24

    automatically be inferred or we can

  45. 1:25

    strongly type it with a double colon as

  46. 1:27

    a list of characters now to define a

  47. 1:30

    function start with a name followed by

  48. 1:31

    the arguments that you want to pass to

  49. 1:33

    it on the right side define the logic of

  50. 1:35

    the function and it will automatically

  51. 1:36

    return a value based on the result of

  52. 1:38

    the expression we can also statically

  53. 1:40

    type it using an arrow to separate the

  54. 1:42

    argument and return value we can call

  55. 1:44

    the function by referencing its name

  56. 1:46

    with the arguments all values including

  57. 1:48

    functions are first class which means

  58. 1:50

    they can be passed as arguments to other

  59. 1:52

    functions if we try to print the result

  60. 1:53

    to the standard output we get an error

  61. 1:55

    that's because working with io creates a

  62. 1:57

    side effect to write a program that

  63. 1:59

    actually does something we write a main