Correction: At 5:33 I said that the do-notation is the only way of having this sequential evaluation. This is not correct, there is a function (sequence :: [IO a] -> IO [a]) that does the same. I meant that this behavior is not possible in the notation we are used to. We will learn another way of having this effect in a later video.
The main issue with this language is that most tutorials only focus on the purity of functional programming and a lot of math stuff. If there were more tutorials like this where you show it doing semi useful things then more people would not give up learning it. Haskell is a very useful language.
Mildly convoluted, yes. Compare (desugared into braces and semicolons form): do { action1 ; var1 > action2 >>= \var1 -> let var2 = func var1 in action3 var2 >>= is the monadic bind operator, and >> simply discards a value like ">>= \ _ ->". The translation is quite direct.
Did you try multiple inputs? Recursively calling main is to allow the program not to end immediately after the first input, except if said input was "quit".
Yes it is! The "print" function can do that. print :: (Show a) => a -> IO () It will print some datatype that has an instance of Show which booleans do!
Vielen Dank für deine Mühe. Bei WEITEM das beste Tutorial auf TH-cam was Haskell angeht. Mein Buch war ganz gut aber ab IO und Monaden konnte ich das weglegen..
You can only input a string from the console. If that's what you are asking. But you can then Interpret that string as you like. For example you could input a comma separated list of numbers. Which you the appropriately split and convert
no not just that you have to wait for *2 MORE VIDEOS* to understand what a monad is but WAIT in that monad video, he only shows the applications of monads, and to REALLY learn what a monad is, you have to wait until *VIDEO #36* for his video on category theory! haskell is a beautiful language **muah**
You could learn that as a first thing, so I think your statement should be "to understand what writing 'Hello World' actually does". It's not so different from C where you can learn right away how to write an Hello World but you would miss on pointers IMHO
For printing Hello World in C you need to know about the standard library, ASCII, String Literals, Char Pointers, Null Terminated "cstrings", STDIN and String Formating. And yet you can also just write printf("Hello World") and call it a day. Haskell is exactly the same. The code in this video just works, regardless of whether you watched 15 videos or 0. But if you want to understand what you are doing you need to understand the concepts you are working with, which takes time and depends entirely on the paradigms Heck of you ever learned java you surely know what mindlessly writing "public static void main(String[] args)" on your first day feels. You get astonishingly overwhelmed by this weird, class obsessed jargon filled paradigm. Untill you eventually start getting the concepts one by one and understand that it's actually really intuitive! In general, you can copy and paste something in an instant. But understanding it takes meaningful time
Esoteric nonsense. Change because of change. Functions read the same as variables and numbers and parameters, because? We like to be different. Most of the truly wild choices serve not a single purpose but to confuse. And make it look like more than it really is.
We basically turned Haskell‘s imperative mode on
Correction: At 5:33 I said that the do-notation is the only way of having this sequential evaluation. This is not correct, there is a function (sequence :: [IO a] -> IO [a]) that does the same. I meant that this behavior is not possible in the notation we are used to. We will learn another way of having this effect in a later video.
There are many ways of doing it. For instance, the bind function >>= and >>
You should pin Errata comments so they are easy to find
Thank you so much for those video series. Best I could find on the internet!
The main issue with this language is that most tutorials only focus on the purity of functional programming and a lot of math stuff. If there were more tutorials like this where you show it doing semi useful things then more people would not give up learning it. Haskell is a very useful language.
These videos are simply amazing
Your videos are very helpful. Thank you!
5:38 "There is no other way of doing it."
Isn't the "do" notation just syntactic sugar for (a very convoluted) use of "bind"?
Mildly convoluted, yes. Compare (desugared into braces and semicolons form):
do { action1 ; var1 > action2 >>= \var1 -> let var2 = func var1 in action3 var2
>>= is the monadic bind operator, and >> simply discards a value like ">>= \ _ ->". The translation is quite direct.
Thank you for this very useful video!
why is main used within the if/then clause at 9:23 ? I excluded it and the program worked well.
Did you try multiple inputs? Recursively calling main is to allow the program not to end immediately after the first input, except if said input was "quit".
Using IO I suppose is the way to work with files, text, binary, CSV, XML, JSON, do you have any video around this?
Thank you!
How long before we print hello world
Yes.
this video is amazing ! thanks a lot !
First versions of Haskell did not have IO. Ok... let's make a Webserver in Haskell. :)))))
There's servant which is pretty cool, you write routes in type level and the handlers are type checked against it.
How to handle a IO(Maybe String) ?
is it possible to print out a boolean? like True or False
Yes it is! The "print" function can do that.
print :: (Show a) => a -> IO ()
It will print some datatype that has an instance of Show which booleans do!
Vielen Dank für deine Mühe. Bei WEITEM das beste Tutorial auf TH-cam was Haskell angeht. Mein Buch war ganz gut aber ab IO und Monaden konnte ich das weglegen..
Will having the main function call itself recursively eventually lead to stack overflow?
the compiler will turn it into a iterative c code, so no recursion, so no stack overflow. correct me if im wrong but i think that thats how it works
Interesting you mean like tail call optimization or something else?@@schwobbel
Is it possible to input a list of Doubles or Integers?
You can only input a string from the console. If that's what you are asking. But you can then Interpret that string as you like. For example you could input a comma separated list of numbers. Which you the appropriately split and convert
This conversion is what Read is for. E.g.: «xs :: [Int] = read "[1,2,3]"» or in an IO do block «xs :: [Int]
Brilliant!
perfect, thank you
oh no
oh hes
So thats a language where you need 15 videos just to learn how to write "Hello world"
And this is still an awesome language.
My thoughts exactly too much details to do something rather simple on every other language
no not just that you have to wait for *2 MORE VIDEOS* to understand what a monad is
but WAIT in that monad video, he only shows the applications of monads, and to REALLY learn what a monad is, you have to wait until *VIDEO #36* for his video on category theory!
haskell is a beautiful language **muah**
You could learn that as a first thing, so I think your statement should be "to understand what writing 'Hello World' actually does". It's not so different from C where you can learn right away how to write an Hello World but you would miss on pointers IMHO
For printing Hello World in C you need to know about the standard library, ASCII, String Literals, Char Pointers, Null Terminated "cstrings", STDIN and String Formating. And yet you can also just write printf("Hello World") and call it a day.
Haskell is exactly the same. The code in this video just works, regardless of whether you watched 15 videos or 0. But if you want to understand what you are doing you need to understand the concepts you are working with, which takes time and depends entirely on the paradigms
Heck of you ever learned java you surely know what mindlessly writing "public static void main(String[] args)" on your first day feels. You get astonishingly overwhelmed by this weird, class obsessed jargon filled paradigm. Untill you eventually start getting the concepts one by one and understand that it's actually really intuitive! In general, you can copy and paste something in an instant. But understanding it takes meaningful time
I didn't understand a word!
You do realize this is episode 15 of a series, do you?
Esoteric nonsense. Change because of change. Functions read the same as variables and numbers and parameters, because? We like to be different. Most of the truly wild choices serve not a single purpose but to confuse. And make it look like more than it really is.