You can't do "functional programming" without functions. In this video, you'll learn about how to declare functions in Haskell and some of the important characteristics of Haskell functions, how they work with types, currying, and point-free style.
- [Instructor] In this video,…we're going to look at functions.…So we're going to look at basic function definitions…and how Haskell works with types and functions.…Really, it's important just to know…a little bit of the vocabulary to be able to read articles…and blog posts about Haskell,…so we're going to have a little look at currying…and point-free style.…So first of all, let's open up our text editor.…Again, I'm using vim.…You can, of course, use your favorite text editor.…And here we can see the functions…that we already defined earlier.…
You can see that the greet function has a parameter who…which is then reused within the body of the function.…So let's create a function to add two numbers together.…We can call it add and it can take two arguments.…Let's call them a and b.…And the result of that will simply be a plus b.…So if we save that and open up stack ghci,…and let's load test.hs into there.…
So even though our test file has the main function…that we looked at in the previous thing,…we don't have to use that at all.…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Discovering Haskell with GHCI
- Haskell datatypes and functions
- Using higher order functions for data manipulation and code reuse
- Editing Haskell source code
- Creating a project with Stack
- Writing and conducting tests