SlideShare uma empresa Scribd logo
1 de 20
Haskell講義(2)
    yingtai
3. Types and
Typeclasses
今日は皆さんに


• 型の勉強をしてもらいます
型


• いろいろあります
型

• Int, Integer
• Float, Double
• Char
• Bool
型

• [Int], [Char], ...
• [[Int]], [[Char]], ...
• (Int, String) ...
型

• 関数にも型があります
• (+) :: Int -> Int -> Int
• (+) 1 2 -- = 3
型変数


• どんな型も取りうる
型クラス


• 型の振る舞いを定義する
Eq 型クラス

• 等値性を定義できる型
• Int, Bool, ...(いろいろ)
• (==), (/=)
Ord 型クラス


• Order (順序) を定義できる型
• (<), (>), (<=), (>=)
Show 型クラス


• 文字列として表現できる型
• show とか
Read 型クラス

• Show と対をなす型クラス
• 文字列から戻せる型
• read とか
Enum 型クラス

• 値を列挙できる型
• succ, pred など
• [ a .. e ]
Bounded 型クラス


• 上限と下限を持つ型
• minBound, maxBound
Num 型クラス


• 数の型クラス
• Int, Integer, Double, Float など
Floating 型クラス


• 浮動小数点数
• Double, Float など
Integral 型クラス


• 整数
• Int, Integer など
他に


• Monadとかも型クラスです
関係

Mais conteúdo relacionado

Mais de Eita Sugimoto (9)

型推論
型推論型推論
型推論
 
電源2
電源2電源2
電源2
 
Semiotics
SemioticsSemiotics
Semiotics
 
電源
電源電源
電源
 
Lecture4
Lecture4Lecture4
Lecture4
 
Lecture1
Lecture1Lecture1
Lecture1
 
Summer seminar
Summer seminarSummer seminar
Summer seminar
 
Functional Pearl + Brainfuck
Functional Pearl + BrainfuckFunctional Pearl + Brainfuck
Functional Pearl + Brainfuck
 
ラムダ計算入門
ラムダ計算入門ラムダ計算入門
ラムダ計算入門
 

Lecture2

Notas do Editor

  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