Haskell is a pure functional programming language that is statically typed and implements immutable data structures. It uses recursion extensively in place of loops. Some key features include:
- Functional programming with immutable values and functions as first-class citizens
- Static typing with type inference
- Recursion instead of loops for iteration
- List comprehensions and pattern matching
It has compilers like GHC and interpreters like Hugs. Code examples demonstrate list handling, recursion, and functional concepts like currying, partial application, and let/in bindings. Haskell has advantages for learning functional programming but also has disadvantages like initial complexity and lack of performance of other languages.
10. Distributing an Application
module Main where
main = putStrLn "Hello Functional Society!â
In the command line:
> ghc -o hello main.hs
> ./hello
> Hello Functional Society!
13. The Previous Recursion Wrote in C
void qsort(int a[], int lo, int hi)
{
int h, l, p, t;
if (lo < hi) {
l = lo;
h = hi;
p = a[hi];
do {
while ((l < h) && (a[l] <= p))
l = l+1;
while ((h > l) && (a[h] >= p))
h = h-1;
if (l < h) {
t = a[l];
a[l] = a[h];
a[h] = t;
}
} while (l < h);
a[hi] = a[l];
a[l] = p;
qsort( a, lo, l-1 );
qsort( a, l+1, hi );
}
}
14. Let/in
letExample a b =
let testValue = (+) a b
in (((+) testValue 1),
((-) testValue 1))
15. Curryng
> max 5 4 > max 4
4 > [function of max] 5
5
> f(x + y/2) = 2
>
5
17. Wild Cards
> caseExample x = > [1 .. 10]
case x of [1,2,3,4,5,6,7,8,9,10]
0 -> 1
1 -> 5 > myFunction 3 = 3
2 -> 2
_ -> -1 > myFunction _ = 0
18. Advantages in Learn Haskell?
⢠Open your mind!
⢠Make your code cleaner
⢠It has a community supporting
⢠You have the control!
19. Ecosystem
⢠Web Frameworks! ⢠Persistence
Frameworks
⢠Test Frameworks.
⢠Web Servers
⢠Concurrency and
STM Frameworks
20. Disvantages
⢠It can Looks like complex in the
beginning.
⢠It isnât performatic
⢠Doesnât implement some bstractions
like other functional languages
21. Thank You!
Haskell
By Jackson Oliveira
@cyber_jso