Haskell

862 views
826 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
862
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Haskell

  1. 1. HaskellBy Jackson Oliveira @cyber_jso
  2. 2. The First Version Is From Nineties
  3. 3. In The Beginning, It Was Just to Learn
  4. 4. But With The Principal Functional Programming Resources Curryng Partial Processing FUNCTION COMPOSITIONMonads Lambda
  5. 5. So, What is Haskell Then?• A Pure Functional Language.• It’s Static Typed.• It implement the immutableconcept.
  6. 6. Complex Things Looks Like Easy
  7. 7. It Uses a Lot of Recursion There is No Loops
  8. 8. How Can We Compile Haskell Code? • Glaskell Haskell Compiler • NHC98 • Hugs (Intepreter) • LHC
  9. 9. Lets See Some code
  10. 10. Distributing an Applicationmodule Main wheremain = putStrLn "Hello Functional Society!“In the command line:> ghc -o hello main.hs> ./hello> Hello Functional Society!
  11. 11. List Handling> 0:[1,2] > map Char.toUpper "Hello World"[0,1,2] "HELLO WORLD“ > zipWith „ (++) [“foo”, “bye”] [“bar”, “ bye”]> 5:[1,2,3,4] [“foo bar”, “bye bye”][5,1,2,3,4] > foldr (+) 0 [3,8,12,5] 28 > foldl (+) 0 [3,8,12,5] 28
  12. 12. Recursionmodule QuickSort where > quickSort [3, 1, 4]quickSort [] = [] > [1, 3, 4]quickSort [x] = [x]quickSort (x : xs) = (quickSort less) ++ (x : equal) ++ (quickSort more) where less = filter (< x) xs equal = filter (== x) xs more = filter (> x) xs
  13. 13. The Previous Recursion Wrote in Cvoid 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. 14. Let/inletExample a b = let testValue = (+) a b in (((+) testValue 1), ((-) testValue 1))
  15. 15. Curryng> max 5 4 > max 44 > [function of max] 5 5 > f(x + y/2) = 2 > 5
  16. 16. Partial Processing> add x y = x + y> addOne = add 1> addOne 23
  17. 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. 18. Advantages in Learn Haskell?• Open your mind!• Make your code cleaner• It has a community supporting• You have the control!
  19. 19. Ecosystem• Web Frameworks! • Persistence Frameworks• Test Frameworks. • Web Servers• Concurrency andSTM Frameworks
  20. 20. Disvantages• It can Looks like complex in thebeginning.• It isn’t performatic• Doesn’t implement some bstractionslike other functional languages
  21. 21. Thank You! Haskell By Jackson Oliveira @cyber_jso

×