Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
10     ruicc.rail@gmail.com
(Ruichi Kousuke)@ruicchttp://d.hatena.ne.jp/ruicc
Haskell
10     !!
Haskell Advent Calendar                  Haskell Advent Calender   2 http://partake.in/events/eaea52c2-61ef-46d5- a855-3a2...
Haskell Advent Calendar2011 2      ruicc.rail@gmail.com
A   HaskellBABA   ...
(OO)(OO)          (Haskell)  (Haskell)                  10
(OO)   (Haskell)(OO)   (Haskell)
(OO)       =   +
(OO)       =   +
(OO)   (Haskell)(OO)   (Haskell)                   Haskell
(Algebraic Data Type)(Set)
Tuple (   )
orBool  True or False
datadata IntOrSome a = MkInt Int                 | MkA   a
datadata IntOrSome a = MkInt Int                 | MkA       a          (OO            )
data      typedata IntOrSome a = MkInt Int                 | MkA   atype IntOrStr    = IntOrSome String
(            )add :: Int -> Int -> Intadd a b   = a + b
(OO)class IntAndStr {    private Int field1;    private String field2;    public IntAndStr (Int i, String s) {      field1...
Haskelldata IntAndStr = MkIS Int Stringlet a = MkIS 42 “aiueo”
(OO)
Haskelldata Bool       = False    | Truedata Maybe a    = Nothing | Just adata Either a b = Left a   | Right b
(OO)
Haskelldata List a = Nil | Cons a (List a)data Tree a = Leaf a            | Node (Tree a) (Tree a)
(OO)   ..
FAQQ: Haskell     private  A1: Python     dis  A2: Javascript       (   )
Haskell    private(      )     Haskell   private module
Haskell   private:wheremodule
OOP(OO)
:Haskell
Y
(OO)       =   +
(       )(   )
Haskell
FAQC++   Python  Y  Y            Haskell
Haskell      (   )C++,Python  C++    :  Python : C3
FAQ    Scala   Trait      scalaz              TraitHaskell
classbuilt-in   Eqclass Eq a where  (==), (/=) :: a -> a -> Bool
classclass Eq a where  (==), (/=) :: a -> a -> Bool
class             instance                   class          instance                                             Eqclass E...
class                              Eqclass (Eq a) => Ord a where  (<=) :: a -> a -> Bool      Ord  ...
classclass (Eq a, Show a) => Num a where  (+) :: a -> a -> a  ...                        Show          Eq                 ...
Read                        Show           instance                                       Typeable                  Bounde...
derivingdata        derivingdata MyType a b c = A a | B b | C c   deriving (Eq, Ord, Show, Read)                          ...
deriving                     FAQ   URL: http://www.haskell.org/ghc/docs/7.2.2/html/users_guide/deriving.html
HaskellHaskell
instance Eq (Maybe Int)    :: *instance Monad Maybe    :: * -> *
Monad, Functor, Applicative
Programming haskell chapter10
Programming haskell chapter10
Programming haskell chapter10
Programming haskell chapter10
Programming haskell chapter10
Programming haskell chapter10
Programming haskell chapter10
Programming haskell chapter10
Programming haskell chapter10
Upcoming SlideShare
Loading in …5
×

Programming haskell chapter10

6,990 views

Published on

スタートHaskell 第5回資料

Published in: Technology, Education
  • Be the first to comment

Programming haskell chapter10

  1. 1. 10 ruicc.rail@gmail.com
  2. 2. (Ruichi Kousuke)@ruicchttp://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 HaskellBABA ...
  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. orBool True or False
  16. 16. datadata IntOrSome a = MkInt Int | MkA a
  17. 17. datadata IntOrSome a = MkInt Int | MkA a (OO )
  18. 18. data typedata IntOrSome a = MkInt Int | MkA atype IntOrStr = IntOrSome String
  19. 19. ( )add :: Int -> Int -> Intadd 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. Haskelldata IntAndStr = MkIS Int Stringlet a = MkIS 42 “aiueo”
  22. 22. (OO)
  23. 23. Haskelldata Bool = False | Truedata Maybe a = Nothing | Just adata Either a b = Left a | Right b
  24. 24. (OO)
  25. 25. Haskelldata List a = Nil | Cons a (List a)data Tree a = Leaf a | Node (Tree a) (Tree a)
  26. 26. (OO) ..
  27. 27. FAQQ: Haskell private A1: Python dis A2: Javascript ( )
  28. 28. Haskell private( ) Haskell private module
  29. 29. Haskell private:wheremodule
  30. 30. OOP(OO)
  31. 31. :Haskell
  32. 32. Y
  33. 33. (OO) = +
  34. 34. ( )( )
  35. 35. Haskell
  36. 36. FAQC++ Python Y Y Haskell
  37. 37. Haskell ( )C++,Python C++ : Python : C3
  38. 38. FAQ Scala Trait scalaz TraitHaskell
  39. 39. classbuilt-in Eqclass Eq a where (==), (/=) :: a -> a -> Bool
  40. 40. classclass Eq a where (==), (/=) :: a -> a -> Bool
  41. 41. class instance class instance Eqclass Eq a where (==), (/=) :: a -> a -> Bool MyTypeinstance Eq MyType where x == y = ... -- (==) :: MyType -> MyType -> Bool
  42. 42. class Eqclass (Eq a) => Ord a where (<=) :: a -> a -> Bool Ord ...
  43. 43. classclass (Eq a, Show a) => Num a where (+) :: a -> a -> a ... Show Eq Num
  44. 44. Read Show instance Typeable Bounded Ix Enum Data Ord Eqinstance MyType
  45. 45. derivingdata derivingdata 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. HaskellHaskell
  48. 48. instance Eq (Maybe Int) :: *instance Monad Maybe :: * -> *
  49. 49. Monad, Functor, Applicative

×