LoginSignup
15
14

More than 5 years have passed since last update.

GHCI で関数の型宣言をする

Last updated at Posted at 2012-07-30

先日から Learn You a Haskell for Great Good! の書籍で Haskell を勉強し始めました。

まだよくわかりませんが、GHCI では let をつけないと関数を宣言できないなどいろいろ制約があるようです。Types and Typeclasses で明示的な関数の型宣言が出てきましたが、GHCI にそのまま打つとエラーになってしまいます。

addThree :: Int -> Int -> Int -> Int
addThree x y z = x + y + z

単に頭に let をつけてもダメ。セミコロンで一行にするとうまく行くようです。

let addThree :: Int -> Int -> Int -> Int; addThree x y z = x + y + z

参考: Haskell: Explicit type declarations in GHCI at Mark Needham

15
14
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
14