13
Kyu96
6y

Any Haskell programmers here?
I started to learn this language for fun two days ago and so far I find it absolutely amazing and really different to OOP languages. Most of the time the solutions make so much sense, but actually coding them requires really abstract thinking of the problem. How fast did you learn Haskell? How long it took you do code it comfortably? Any advises you can give me? I work mainly through a uni exercise sheet from a friend from a different uni, and the rest is hoogle and google :P

Comments
  • 4
    📍
  • 1
    Last week I was checking out Haskell too. All I can say is that I'm missing my curly braces.
  • 0
    99% of problems can be solved by well-thought out types
  • 3
    Getting to a point where I could do stuff on my own in Haskell took me about two years. Yes, it's easy enough to learn how to make trivial programs, but real stuff (say, a compiler or something), that takes time. You really need time to absorb the monadic and function-composition way of thinking.

    Check this out for a great, practical learning path https://github.com/bitemyapp/...

    Functional Pearls and Lambda the Ultimate are a series of articles/papers on how to get stuff done with functional programming, super useful.

    Code Wars has challenges to keep your skills sharp, I learnt a fair amount from seeing how other Haskellers solve problems.

    If you really want to go deep, read Simon Peyton Jones' papers on Haskell (especially for parallel and concurrent Haskell) and Edward Kmett and Bartosz Milewski's (this one is easier, he also has a YouTube course on it, super awesome) blogs on category theory and CT applied to Haskell.
  • 1
    Book: Learn You a Haskell For Great Good!

    I don’t know Haskell, but the book was instrumental in getting my mind around certain concepts like monads etc.

    I’m still a *long* way from proper comprehension, but it’s a great set of tools, and it does carry over into my approach to imperative programming too.
  • 0
    @RememberMe Interesting! You just got me even more hyped to learn Haskell :D But for now I feel like an ape sitting in front of a computer haha. I have so much trouble solving the simplest problems, which I'd solve in an OOP language in 30 seconds but in Haskell it takes me hours. For example, check out this: I am trying to write a function that checks if a list contains a given element, and returns either true or false. I know there are functions to do that, but I am supposed to solve this using only pattern matching and list comprehension to get used to this. Any ideas whats wrong :D ?
  • 1
    @Kyu96 Currently, your elementInList function only checks whether the list is empty, or if it is not, whether the first element of the list matches the given value

    Hint: you're breaking apart the list using (x:xs) pattern matching, and then seeing if x equals the given n
    x is the head of the list, xs is the tail (i.e. the rest of the list). Search in the tail too.

    Hint 2: recursion.
  • 0
    @RememberMe Yeah I tried that but the compiler is not happy with the single element check.

    parse error on input ‘=’

    Perhaps you need a 'let' in a 'do' block?

    e.g. 'let x = 5' instead of 'x = 5'

    elementInList n [x] = n == x = True

    Wow, I am abusing Devrant like SO rn lol
  • 1
    @Kyu96 wait what no
    I didn't mean that you needs single element checks.

    Okay I'll solve this for you, sort of
    You have two cases

    Either the list is empty so you return false

    Or the list isn't, so you see if the head is the element you're looking for, return true if so. Otherwise, you apply your function to the tail.

    (Yes you can use something like an if-else, look it up)
  • 0
    @RememberMe Ay, thanks! I got it ! :D
Add Comment