Real World Haskell - 第3章 Part7 Reporting errors
Real World Haskell で Haskell を継続的に勉強中。
Defining Types, Streamlining Functions
Chapter 3. Defining Types, Streamlining Functions
Reporting errors
- error :: String -> a
- error の result type は常に正しい
- error は abort する
mySecond :: [a] -> a mySecond xs = if null (tail xs) then error "list too short" else head (tail xs)