SlideShare a Scribd company logo
1 of 58
10
     ruicc.rail@gmail.com
(Ruichi Kousuke)


@ruicc

http://d.hatena.ne.jp/ruicc
Haskell
10




     !!
Haskell Advent Calendar


                  Haskell Advent Calender
   2

 http://partake.in/events/eaea52c2-61ef-46d5-
 a855-3a2dde459e3a
Haskell Advent Calendar2011 2




      ruicc.rail@gmail.com
A   Haskell

B

A

B

A   ...
(OO)

(OO)          (Haskell)

  (Haskell)

                  10
(OO)   (Haskell)

(OO)   (Haskell)
(OO)




       =   +
(OO)




       =   +
(OO)   (Haskell)




(OO)   (Haskell)




                   Haskell
(Algebraic Data Type)


(Set)
Tuple (   )
or

Bool

  True or False
data



data IntOrSome a = MkInt Int

                 | MkA   a
data



data IntOrSome a = MkInt Int

                 | MkA       a



          (OO            )
data      type


data IntOrSome a = MkInt Int

                 | MkA   a

type IntOrStr    = IntOrSome String
(            )




add :: Int -> Int -> Int

add a b   = a + b
(OO)

class IntAndStr {
    private Int field1;
    private String field2;
    public IntAndStr (Int i, String s) {
      field1 = i; field2 = s;
    }
}
a = new IntAndStr(42, “aiueo”);
Haskell



data IntAndStr = MkIS Int String

let a = MkIS 42 “aiueo”
(OO)
Haskell


data Bool       = False    | True

data Maybe a    = Nothing | Just a

data Either a b = Left a   | Right b
(OO)
Haskell


data List a = Nil | Cons a (List a)

data Tree a = Leaf a
            | Node (Tree a) (Tree a)
(OO)   ..
FAQ



Q: Haskell     private

  A1: Python     dis

  A2: Javascript       (   )
Haskell    private(      )


     Haskell   private




 module
Haskell   private:




where

module
OOP




(OO)
:Haskell
Y
(OO)




       =   +
(       )

(   )
Haskell
FAQ


C++   Python

  Y



  Y            Haskell
Haskell      (   )


C++,Python


  C++    :

  Python : C3
FAQ




    Scala   Trait

      scalaz              Trait
Haskell
class


built-in   Eq

class Eq a where

  (==), (/=) :: a -> a -> Bool
class




class Eq a where

  (==), (/=) :: a -> a -> Bool
class             instance
                   class          instance
                                             Eq
class Eq a where
  (==), (/=) :: a -> a -> Bool

                                             MyType
instance Eq MyType where
  x == y       = ...
  --   (==) :: MyType -> MyType -> Bool
class

                              Eq


class (Eq a) => Ord a where
  (<=) :: a -> a -> Bool      Ord
  ...
class


class (Eq a, Show a) => Num a where
  (+) :: a -> a -> a
  ...
                        Show          Eq




                               Num
Read
                        Show
           instance
                                       Typeable
                  Bounded      Ix
                       Enum            Data


                      Ord               Eq
instance


                              MyType
deriving

data        deriving

data MyType a b c = A a | B b | C c

   deriving (Eq, Ord, Show, Read)
                                         Read
                              Show
                        Ord                Eq



                                MyType
deriving                     FAQ




   URL: http://www.haskell.org/ghc/docs/7.2.2/html/
users_guide/deriving.html
Haskell



Haskell
instance Eq (Maybe Int)


    :: *
instance Monad Maybe
    :: * -> *
Monad, Functor, Applicative

More Related Content

What's hot

Algebraic Data Types and Origami Patterns
Algebraic Data Types and Origami PatternsAlgebraic Data Types and Origami Patterns
Algebraic Data Types and Origami Patterns
Vasil Remeniuk
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
Binoj T E
 
Data structures in scala
Data structures in scalaData structures in scala
Data structures in scala
Meetu Maltiar
 

What's hot (19)

Ten-page Brief Overview of Swift for Scala Developers
Ten-page Brief Overview of Swift for Scala DevelopersTen-page Brief Overview of Swift for Scala Developers
Ten-page Brief Overview of Swift for Scala Developers
 
Java10 Collections and Information
Java10 Collections and InformationJava10 Collections and Information
Java10 Collections and Information
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Algebraic Data Types and Origami Patterns
Algebraic Data Types and Origami PatternsAlgebraic Data Types and Origami Patterns
Algebraic Data Types and Origami Patterns
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Data Structures In Scala
Data Structures In ScalaData Structures In Scala
Data Structures In Scala
 
Collections - Array List
Collections - Array List Collections - Array List
Collections - Array List
 
Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics
 
Scala collections
Scala collectionsScala collections
Scala collections
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Session 15 - Collections - Array List
Session 15 - Collections - Array ListSession 15 - Collections - Array List
Session 15 - Collections - Array List
 
Scala for curious
Scala for curiousScala for curious
Scala for curious
 
Java Collections Tutorials
Java Collections TutorialsJava Collections Tutorials
Java Collections Tutorials
 
Scala collections api expressivity and brevity upgrade from java
Scala collections api  expressivity and brevity upgrade from javaScala collections api  expressivity and brevity upgrade from java
Scala collections api expressivity and brevity upgrade from java
 
Chapter 3: basic sorting algorithms data structure
Chapter 3: basic sorting algorithms data structureChapter 3: basic sorting algorithms data structure
Chapter 3: basic sorting algorithms data structure
 
Scala collection
Scala collectionScala collection
Scala collection
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Data structures in scala
Data structures in scalaData structures in scala
Data structures in scala
 

Similar to Programming haskell chapter10

(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
Tomasz Wrobel
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
wpgreenway
 

Similar to Programming haskell chapter10 (20)

(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Language
 
Introducing scala
Introducing scalaIntroducing scala
Introducing scala
 
Rewriting Java In Scala
Rewriting Java In ScalaRewriting Java In Scala
Rewriting Java In Scala
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and Haskell
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Recursion schemes in Scala
Recursion schemes in ScalaRecursion schemes in Scala
Recursion schemes in Scala
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
Meet scala
Meet scalaMeet scala
Meet scala
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
C# programming
C# programming C# programming
C# programming
 
Introduction to scala
Introduction to scalaIntroduction to scala
Introduction to scala
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
 
Scala Paradigms
Scala ParadigmsScala Paradigms
Scala Paradigms
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed world
 

More from Kousuke Ruichi (7)

grpc-haskell.pdf
grpc-haskell.pdfgrpc-haskell.pdf
grpc-haskell.pdf
 
並行プログラミングと継続モナド
並行プログラミングと継続モナド並行プログラミングと継続モナド
並行プログラミングと継続モナド
 
An engineer uses monads
An engineer uses monadsAn engineer uses monads
An engineer uses monads
 
Purescript with Monad
Purescript with MonadPurescript with Monad
Purescript with Monad
 
ゆるふわなHaskell話
ゆるふわなHaskell話ゆるふわなHaskell話
ゆるふわなHaskell話
 
Haskell Day2012 - 参照透過性とは何だったのか
Haskell Day2012 - 参照透過性とは何だったのかHaskell Day2012 - 参照透過性とは何だったのか
Haskell Day2012 - 参照透過性とは何だったのか
 
Programming Haskell Chapter8
Programming Haskell Chapter8Programming Haskell Chapter8
Programming Haskell Chapter8
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Programming haskell chapter10

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n