Successfully reported this slideshow.
Your SlideShare is downloading. ×

Programming haskell chapter10

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
First-Class Patterns
First-Class Patterns
Loading in …3
×

Check these out next

1 of 58 Ad

More Related Content

Slideshows for you (19)

Similar to Programming haskell chapter10 (20)

Advertisement

Recently uploaded (20)

Advertisement

Programming haskell chapter10

  1. 1. 10 ruicc.rail@gmail.com
  2. 2. (Ruichi Kousuke) @ruicc http://d.hatena.ne.jp/ruicc
  3. 3. Haskell
  4. 4. 10 !!
  5. 5. Haskell Advent Calendar Haskell Advent Calender 2 http://partake.in/events/eaea52c2-61ef-46d5- a855-3a2dde459e3a
  6. 6. Haskell Advent Calendar2011 2 ruicc.rail@gmail.com
  7. 7. A Haskell B A B A ...
  8. 8. (OO) (OO) (Haskell) (Haskell) 10
  9. 9. (OO) (Haskell) (OO) (Haskell)
  10. 10. (OO) = +
  11. 11. (OO) = +
  12. 12. (OO) (Haskell) (OO) (Haskell) Haskell
  13. 13. (Algebraic Data Type) (Set)
  14. 14. Tuple ( )
  15. 15. or Bool True or False
  16. 16. data data IntOrSome a = MkInt Int | MkA a
  17. 17. data data IntOrSome a = MkInt Int | MkA a (OO )
  18. 18. data type data IntOrSome a = MkInt Int | MkA a type IntOrStr = IntOrSome String
  19. 19. ( ) add :: Int -> Int -> Int add a b = a + b
  20. 20. (OO) class IntAndStr { private Int field1; private String field2; public IntAndStr (Int i, String s) { field1 = i; field2 = s; } } a = new IntAndStr(42, “aiueo”);
  21. 21. Haskell data IntAndStr = MkIS Int String let a = MkIS 42 “aiueo”
  22. 22. (OO)
  23. 23. Haskell data Bool = False | True data Maybe a = Nothing | Just a data Either a b = Left a | Right b
  24. 24. (OO)
  25. 25. Haskell data List a = Nil | Cons a (List a) data Tree a = Leaf a | Node (Tree a) (Tree a)
  26. 26. (OO) ..
  27. 27. FAQ Q: Haskell private A1: Python dis A2: Javascript ( )
  28. 28. Haskell private( ) Haskell private module
  29. 29. Haskell private: where module
  30. 30. OOP (OO)
  31. 31. :Haskell
  32. 32. Y
  33. 33. (OO) = +
  34. 34. ( ) ( )
  35. 35. Haskell
  36. 36. FAQ C++ Python Y Y Haskell
  37. 37. Haskell ( ) C++,Python C++ : Python : C3
  38. 38. FAQ Scala Trait scalaz Trait Haskell
  39. 39. class built-in Eq class Eq a where (==), (/=) :: a -> a -> Bool
  40. 40. class class Eq a where (==), (/=) :: a -> a -> Bool
  41. 41. class instance class instance Eq class Eq a where (==), (/=) :: a -> a -> Bool MyType instance Eq MyType where x == y = ... -- (==) :: MyType -> MyType -> Bool
  42. 42. class Eq class (Eq a) => Ord a where (<=) :: a -> a -> Bool Ord ...
  43. 43. class class (Eq a, Show a) => Num a where (+) :: a -> a -> a ... Show Eq Num
  44. 44. Read Show instance Typeable Bounded Ix Enum Data Ord Eq instance MyType
  45. 45. deriving data deriving data MyType a b c = A a | B b | C c deriving (Eq, Ord, Show, Read) Read Show Ord Eq MyType
  46. 46. deriving FAQ URL: http://www.haskell.org/ghc/docs/7.2.2/html/ users_guide/deriving.html
  47. 47. Haskell Haskell
  48. 48. instance Eq (Maybe Int) :: * instance Monad Maybe :: * -> *
  49. 49. Monad, Functor, Applicative

Editor's Notes

  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

×