peppidesu
peppidesu
  • 5
  • 194 237
Your code can be beautiful AND fast (Higher order functions)
Thank you all for watching! If you want to see more of this, consider subscribing!
In this video we will talk about higher-order functions - one of the main pillars of Haskell, and how they can help you write elegant and decently fast code with little effort.
Since this video covers a topic that has many strong opinions, I want to make clear that I do not appreciate flaming or irrational discussion in the comments. If you think I or someone else is wrong, be concrete and provide a source if you can.
========================================================
0:00 Introduction
0:47 Built-in functions
1:04 Hoogle
1:47 Functions as arguments
2:35 Lambda notation
2:59 Building the map function
4:35 The new perspective
5:10 zipWith
5:29 filter
5:41 Why you should care
7:32 Conclusion
========================================================
Discord server: discord.gg/pAYbVwn5hR
Twitch: twitch.tv/peppidesu
Patreon: patreon.com/user?u=55163786
Fonts used:
- Headings: Comfortaa
- Body: Lexend Deca
- Code: Maple Mono
Color scheme: Ayu Mirage
Software used:
- PowerPoint
- Premiere Pro
#haskell #functionalprogramming #programming #tutorial #code #coding #functional #functions #math
มุมมอง: 14 496

วีดีโอ

Recursion - To hone a skill, one must practice.
มุมมอง 20K11 หลายเดือนก่อน
Thank you all for watching! If you want to see more of this, consider subscribing! In this video we will talk about recursion and how Haskell forcing it upon you is an opportunity to practice working with it. We will also look into how lists work in Haskell, and how these two design choices go hand in hand. Since this video covers a topic that has many strong opinions, I want to make clear that...
Binary Representations - The Ultimate Guide (06/01/23 @ CROW ACADEMY)
มุมมอง 1.6Kปีที่แล้ว
This is a recording of a talk I did yesterday over at the CROW ACADEMY discord server, for those who missed it.
How to read Haskell code (in 7 minutes)
มุมมอง 54Kปีที่แล้ว
Hope you liked the video! This took a while to make (mostly bc of uni stuff getting in the way). In this video, I will be going over the basics of Haskell syntax. Haskell is syntactically very different from other languages, so this video should clear up a lot of confusion around Haskell code. I won't assume you understand everything covered in this video going onward, this is just to make sure...
You want to learn Haskell. This is why.
มุมมอง 105Kปีที่แล้ว
If you want to see more of this content, leave a like! This is an introduction to an upcoming tutorial series about programming in haskell. A lot of people complain about haskell being complicated and unintuitive, and although it definitely has its flaws, it forces you into thinking about code in a entirely different way. Discord server: discord.gg/pAYbVwn5hR Twitch: twitch.tv/peppidesu Patreon...

ความคิดเห็น

  • @blindshellvideos
    @blindshellvideos วันที่ผ่านมา

    haskell sucks

  • @zsuato
    @zsuato 10 วันที่ผ่านมา

    this is so cool

  • @nelsonjanusson7278
    @nelsonjanusson7278 15 วันที่ผ่านมา

    damn..... even the title is declarative.

  • @ClayShentrup
    @ClayShentrup 15 วันที่ผ่านมา

    type signatures are an anti-pattern. just use inference.

  • @IllusionDX
    @IllusionDX 21 วันที่ผ่านมา

    I can barely understand simpler code that does things step by step, I don't want to make it harder for myself

  • @3_14pie
    @3_14pie 23 วันที่ผ่านมา

    so python is just dumb haskell?

  • @1..1..1..1H
    @1..1..1..1H หลายเดือนก่อน

    No

  • @c0lligo
    @c0lligo หลายเดือนก่อน

    The sentence "Haskell doesn't even feature variables" deals immense psychic damage to most programmers

  • @donwald3436
    @donwald3436 หลายเดือนก่อน

    lol monads

  • @posfr292
    @posfr292 หลายเดือนก่อน

    Wow. That's an absolutely beautiful video. I'm starting to understand it - especially with the aid of those fantastic function / higher-order function (HOF) diagrams. One comment, however: there appears to be a minor typo in the "Wrapping up" diagram at around 07:36. I think that the output of the filter HOF should possibly have the type [a]. Having just subscribed to your channel, I'm going to watch more of your Haskell videos in my quest to understand functional programming with TypeScript (of all things - possibly with the aid of the fp-ts library). Thank you.

  • @oPatrickVico
    @oPatrickVico หลายเดือนก่อน

    Awesome video! Hope your channel blows up

  • @alexanderskusnov5119
    @alexanderskusnov5119 หลายเดือนก่อน

    2:49 foo needs a function of one argument (type a), it's not a plus function of 2 arguments (x, y).

  • @adryelbarros3250
    @adryelbarros3250 หลายเดือนก่อน

    def closest(target, points, dist): distances = ((dist(target, p), p) for p in points) _, closest_point = min(distances, key=lambda i: i[0]) return closest_point

    • @adryelbarros3250
      @adryelbarros3250 หลายเดือนก่อน

      Ok, I could've used the dist directly in the min function

  • @QuotePilgrim
    @QuotePilgrim หลายเดือนก่อน

    Bro I have been coding in Python since highschool and it took me a while to understand that example at the end of the video.

  • @GeekOverdose
    @GeekOverdose 2 หลายเดือนก่อน

    Sometimes you really wish you had some structural typing 🙂

  • @harune6594
    @harune6594 2 หลายเดือนก่อน

    oh man heartbroken you didnt continue this series

  • @harune6594
    @harune6594 2 หลายเดือนก่อน

    wow, great video

  • @rutieltercero9355
    @rutieltercero9355 2 หลายเดือนก่อน

    COME BAAAACK

  • @RoyaltyInTraining.
    @RoyaltyInTraining. 2 หลายเดือนก่อน

    I instantly fell in love with Rust after learning how to write it in a functional-like way. Now I really want to learn more.

  • @yash1152
    @yash1152 3 หลายเดือนก่อน

    4:09 > _"UTH, Haskell lists look like this"_ wait, this looks (syntax) & sound (name) like lisp lists.

  • @laughingvampire7555
    @laughingvampire7555 3 หลายเดือนก่อน

    stop saying that is a very complicated topic because it isn't

    • @IronicHavoc
      @IronicHavoc 2 หลายเดือนก่อน

      It is to some people, and they often get turned away when someone says it's simple. It's not like hes saying its impenetrable, just chill out.

  • @dycan0716
    @dycan0716 3 หลายเดือนก่อน

    Any tutorial about vizualisation in the new perspective section? looks sophisticated.

  • @0LoneTech
    @0LoneTech 3 หลายเดือนก่อน

    There is *lots* of overhead in the for loop you showed to begin with, specifically on the programmer's side! Compare: int factorial(int n) { int product=1; for (int factor=1; factor<=n; factor++) product*=factor; return product; } factorial :: Int -> Int factorial n = product [1..n] Why should the programmer repeatedly explain to the compiler how to iterate through numbers every time they want to handle any sort of sequence? It's even done with the full expectation the compiler will recognize the pattern and discard those details, in order to perform optimization like using CPU flags, unrolling, vectorization etc; which means there's another load of overhead on the compiler's side. And then you still have to elaborate for some of those, like #pragma omp reduction (* : product).

  • @user-vg4lp5ox7f
    @user-vg4lp5ox7f 3 หลายเดือนก่อน

    На питоне можно однострочные написать тоже 😂

  • @SilverStarStorm.
    @SilverStarStorm. 4 หลายเดือนก่อน

    Continuation when? :p

  • @user-tx4wj7qk4t
    @user-tx4wj7qk4t 4 หลายเดือนก่อน

    Confusing apply with map is pretty bad for learning. Map is specific to list and really shouldn't be used over fmap but I get why you're taking about it. But recursion isn't something that's ever really used outside of library implementations. You should really be teaching people things like fold because they're just going to get hung up on recursion not being efficient or something Overall tackling it from this angle makes haskell seem no different to any other language. Nothing here is special really

  • @user-tx4wj7qk4t
    @user-tx4wj7qk4t 4 หลายเดือนก่อน

    Tail call recursion is not slower

  • @adriansomor
    @adriansomor 4 หลายเดือนก่อน

    amazing series

  • @mukynas
    @mukynas 4 หลายเดือนก่อน

    Nice try Big Haskell corporate slave

  • @nuisho.studio
    @nuisho.studio 4 หลายเดือนก่อน

    Arguments and parameters are different things. The function declaration (not applying or execution) uses parameters, not arguments.

  • @crazymarxistguy
    @crazymarxistguy 4 หลายเดือนก่อน

    Wow! Just amazing. Incredible video, highly detailed and well explaining, while still remaining very short and concise. Great job!

  • @WayOfTheCode
    @WayOfTheCode 5 หลายเดือนก่อน

    Amazing videos

  • @user-zs6oh4wp1d
    @user-zs6oh4wp1d 5 หลายเดือนก่อน

    Great video :D

  • @MrSenserus
    @MrSenserus 5 หลายเดือนก่อน

    And I don't even need to memory allocate in my brain to learn this - Haskell has it built in!

  • @user-zs6oh4wp1d
    @user-zs6oh4wp1d 5 หลายเดือนก่อน

    Great video :D

  • @S3Kglitches
    @S3Kglitches 5 หลายเดือนก่อน

    Haskell is like driving a jet fighter on the road. It's cool and advanced af but its practical usage is low.

  • @TheGRoques
    @TheGRoques 5 หลายเดือนก่อน

    Thank you. I've been thinking of starting Haskell for many years, and this video series serves as a concise and accessible introduction!

  • @gregoryfenn1462
    @gregoryfenn1462 5 หลายเดือนก่อน

    Wait, isn't there a massive crashing bug in the factorial code? If i call "factorial (-1)" it will infinitely recurse and never stop. How is this an acceptable coding feature? Surely, the function domain should be limited to unsigned integers (Z+) rather than all Integers?

    • @0LoneTech
      @0LoneTech 3 หลายเดือนก่อน

      Feel free to add «factorial n | n<0 = undefined» if you'd like your failure to be faster. It wasn't going to work either way. As for limiting it to unsigned integers, that would require importing such a type, and Integer is arbitrary size too so will handle large numbers like 22! More concerning is that the form wasn't tail recursive and may take O(n) memory. foldl' and seq exist to address that. Introductory examples rarely address all possible concerns simultaneously.

  • @bravo________87372
    @bravo________87372 5 หลายเดือนก่อน

    Still just does a for loop under the hood

  • @rico_1617
    @rico_1617 5 หลายเดือนก่อน

    Nah watch this: import closestPoint from 'closest-point'; let res = closestPoint(point, target);

  • @potatomaaan1757
    @potatomaaan1757 5 หลายเดือนก่อน

    Here is a version in rust that doesnt clone anything, so should be very fast. It also accounts for the case where the list of points might be emtpy. fn closest<'a>(points: &'a [Point], target: &Point) -> Option<&'a Point> { points.into_iter().min_by_key(|p| distance(&p, target)) }

  • @ashk3734
    @ashk3734 5 หลายเดือนก่อน

    Haskell is so bad, don't learn it :(

  • @Mashen_Taterz
    @Mashen_Taterz 5 หลายเดือนก่อน

    Thanks so much. Please keep doing more ❤

  • @mtv.smorodin
    @mtv.smorodin 6 หลายเดือนก่อน

    looking forward for next episodes! thank you for your content 🎉

  • @mradult6914
    @mradult6914 6 หลายเดือนก่อน

    This video is so starkly different from the conclusions I've come to in my work experience that it was a little jarring. Great video and I can understand how one would arrive at using recursion more, but based on my work experience I try to avoid recursion at all costs. I have found that recursion tends to tie knots in my code that only get worse over time. I find iterators and their associated for loops to be much more intuitive, and even figured out how to handle trees without recursion by instead building tree-based iterators.

    • @user-tx4wj7qk4t
      @user-tx4wj7qk4t 4 หลายเดือนก่อน

      Lol what are you talking about. First of all, tail call recursion is converted into for loops. Second of all, this is low level iteration you should never be writing, neither for loops nor recursion, unless you've got some performance need. OOP has iterators and FP has HOFs and comprehensions which are 2-3 levels of abstraction above loops and recursion. It also decouples how to iterate from what you want to do as well as isn't specific to a data structure... On top of that it's also much cleaner code

  • @maurolimaok
    @maurolimaok 6 หลายเดือนก่อน

    I'm just starting my journey at Odin Project, at 56yo At the moment my focus is on the basics, but this is very interesting. Hope to see more like this. Thanks!

    • @user-tx4wj7qk4t
      @user-tx4wj7qk4t 4 หลายเดือนก่อน

      I would advise you to focus on something like PureScript instead. The book "functional programming made easier" teaches you frontend web dev from scratch and you'll learn a lot more than Odin

  • @Sk8erMorris
    @Sk8erMorris 6 หลายเดือนก่อน

    Hope all is well, wondering for the continuation of the series :)

  • @callyral
    @callyral 6 หลายเดือนก่อน

    oh, like rust iterators! haskell sounds pretty cool

    • @user-tx4wj7qk4t
      @user-tx4wj7qk4t 4 หลายเดือนก่อน

      My understanding is that Rust took a lot of design decisions from Haskell and ML. How do the iterators work compared to this? I know the word iterator to mean something that allows you to iterate through a structure

  • @callyral
    @callyral 6 หลายเดือนก่อน

    as someone who mainly uses rust and has used lisps, i recognize a lot of similarity. type variables are like rust's generics, guards are like lisp if

    • @peppidesu
      @peppidesu 6 หลายเดือนก่อน

      the likeness with rust will be even more when we start talking about typeclasses and monads, most of the "errors as values" and "make invalid states unrepresentable" philosophy stems from that.