Created
July 15, 2017 09:09
-
-
Save mizukmb/7457f048bf9b89f384db034c90e7795f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- data Person = Person String String Int Float String String deriving (Show) | |
-- レコード構文 | |
-- ex.) | |
-- *Main> let guy = Person "Buddy" "Finklestein" 43 184.2 "526-2928" "Chocolate" | |
-- *Main> flavor guy | |
-- "Chocolate" | |
-- *Main> :t flavor | |
-- flavor :: Person -> String | |
data Person = Person { | |
firstName :: String, | |
lastName :: String, | |
age :: Int, | |
height :: Float, | |
phoneNumber :: String, | |
flavor :: String | |
} deriving (Show) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
レコード構文でデータ型を定義すると Haskell がフィールド名の関数を作ってくれる。返す値はそこに突っ込んだ値。getterみたいな感じ