SlideShare a Scribd company logo
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)
Programming haskell chapter10
Programming haskell chapter10
(OO)




       =   +
(OO)




       =   +
(OO)   (Haskell)




(OO)   (Haskell)




                   Haskell
Programming haskell chapter10
Programming haskell chapter10
(Algebraic Data Type)


(Set)
Tuple (   )
or

Bool

  True or False
Programming haskell chapter10
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
Programming haskell chapter10
(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)




       =   +
Programming haskell chapter10
Programming haskell chapter10
(       )

(   )
Haskell
Programming haskell chapter10
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

PDF
First-Class Patterns
PDF
Scala Collections : Java 8 on Steroids
PPTX
Scala Back to Basics: Type Classes
PDF
Functors, in theory and in practice
PPT
Collections Framework
PDF
Linear Types in Haskell
PDF
The Next Great Functional Programming Language
PDF
Scala Bootcamp 1
First-Class Patterns
Scala Collections : Java 8 on Steroids
Scala Back to Basics: Type Classes
Functors, in theory and in practice
Collections Framework
Linear Types in Haskell
The Next Great Functional Programming Language
Scala Bootcamp 1

What's hot (19)

PDF
Ten-page Brief Overview of Swift for Scala Developers
PPT
Java10 Collections and Information
PDF
Lecture 3
PDF
Algebraic Data Types and Origami Patterns
PDF
Lecture 2
PDF
Data Structures In Scala
PPSX
Collections - Array List
PPSX
Collections - Sorting, Comparing Basics
PDF
Scala collections
PDF
Lecture 4
PPTX
Session 15 - Collections - Array List
PPTX
Scala for curious
PDF
Java Collections Tutorials
PDF
Scala collections api expressivity and brevity upgrade from java
PPT
Chapter 3: basic sorting algorithms data structure
PPT
Scala collection
PDF
Java Collection framework
PDF
Collections In Java
ODP
Data structures in scala
Ten-page Brief Overview of Swift for Scala Developers
Java10 Collections and Information
Lecture 3
Algebraic Data Types and Origami Patterns
Lecture 2
Data Structures In Scala
Collections - Array List
Collections - Sorting, Comparing Basics
Scala collections
Lecture 4
Session 15 - Collections - Array List
Scala for curious
Java Collections Tutorials
Scala collections api expressivity and brevity upgrade from java
Chapter 3: basic sorting algorithms data structure
Scala collection
Java Collection framework
Collections In Java
Data structures in scala
Ad

Similar to Programming haskell chapter10 (20)

PDF
(How) can we benefit from adopting scala?
PDF
The Scala Programming Language
ODP
Introducing scala
PPT
Rewriting Java In Scala
PDF
Scala jargon cheatsheet
PPT
An introduction to scala
PDF
Functional Algebra: Monoids Applied
PDF
Monoids - Part 1 - with examples using Scalaz and Cats
PDF
Introduction to Scala
PPT
Scala introduction
PDF
Recursion schemes in Scala
PDF
Scala - en bedre og mere effektiv Java?
PDF
Meet scala
PDF
Introduction to Scala
PPT
C# programming
PDF
Introduction to scala
ODP
1.2 scala basics
PDF
Scala Paradigms
PDF
Power of functions in a typed world
PPT
Scala - brief intro
(How) can we benefit from adopting scala?
The Scala Programming Language
Introducing scala
Rewriting Java In Scala
Scala jargon cheatsheet
An introduction to scala
Functional Algebra: Monoids Applied
Monoids - Part 1 - with examples using Scalaz and Cats
Introduction to Scala
Scala introduction
Recursion schemes in Scala
Scala - en bedre og mere effektiv Java?
Meet scala
Introduction to Scala
C# programming
Introduction to scala
1.2 scala basics
Scala Paradigms
Power of functions in a typed world
Scala - brief intro
Ad

More from Kousuke Ruichi (7)

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

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Modernizing your data center with Dell and AMD
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Smarter Business Operations Powered by IoT Remote Monitoring
PDF
SAP855240_ALP - Defining the Global Template PUBLIC.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
PDF
Advanced IT Governance
PDF
Event Presentation Google Cloud Next Extended 2025
Understanding_Digital_Forensics_Presentation.pptx
Sensors and Actuators in IoT Systems using pdf
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Reimagining Insurance: Connected Data for Confident Decisions.pdf
cuic standard and advanced reporting.pdf
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
GamePlan Trading System Review: Professional Trader's Honest Take
Modernizing your data center with Dell and AMD
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Transforming Manufacturing operations through Intelligent Integrations
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Advanced Soft Computing BINUS July 2025.pdf
Smarter Business Operations Powered by IoT Remote Monitoring
SAP855240_ALP - Defining the Global Template PUBLIC.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
Advanced IT Governance
Event Presentation Google Cloud Next Extended 2025

Programming haskell chapter10

Editor's Notes