ghci

コマンド

:?
ヘルプ
:module
モジュールのロード
:info
演算子を調べることができる.優先順位とか
:type
型を表示する
:quit
終了

set/unset

+t
式の後に型を表示

かなり忘れてる

  • '-'(マイナス)は,単項演算子
  • /= は,!= みたいなもの
  • [,] みたいな最後にカンマは許してないよ(-> parse error)
  • .. は範囲.省略で無限まで.[1..] みたいな(> take 10 [100..])
  • ++ は,リスト結合,: は,コンス
  • putStrLn -> say

But its coverage of mathematical constants is not comprehensive, as we
can quickly see. Let us look for Euler's number, e.
Oh well. We have to define it ourselves.
Using ''ghci'''s let construct, we can make a temporary definition of
e ourselves.

こんな感じか.

すぐわかるように,数学的定数の定義の範囲は,包括的じゃない.
オイラー数 e を探してみよう.
おおっと,こいつは,自分たちで定義しなくちゃならない.
"ghci" の let 構築子を使って,私たちは,
自分自身の e の一時的な定義をすることができる.

This is an application of the exponential function, exp, and our first
example of applying a function in Haskell.
While languages like Python require parentheses around the arguments
to a function, Haskell does not.
With e defined, we can now use it in arithmetic expressions. The (^)
exponentiation operator that we introduced earlier can only raise a
number to an integer power. To use a floating point number as the
exponent, we use the (**) exponentiation operator.

これは,指数関数の適応で,exp のところがその部分.
これが(この本での) Haskell の関数適用の最初の例です.
Python のような言語は,関数への引数の周りに括弧を必要とするけど,
Haskell はそうじゃない.
e が定義されたので,私たちはそれを数式の中に使うことができる.
以前に紹介した指数演算子(^)は,数をべき乗して,整数のべき乗しか得られない.
浮動小数点数を使って指数を得るには,指数演算子(**)を使います.