SOE

uncurry?

uncurry なる関数が Excercise に出てて、コリャなんだ?と疑問符が頭の中を飛び交い中。とりあえず型を問い合わせてみた。ついでに uncurry があるなら curry もあるのか?って。あった。 Prelude> :t uncurry uncurry :: (a -> b -> c) -> (a, b) -> c Pre…

($) is apply

10 章の DETAILS に "The operator ($) is …. In other words it is the ``apply'' operator" という記述を発見。なんと! ($) は apply だったのかっ!Exercise 9.4 のことをおもいだし、うわ、こんな簡単な答えになるよってんで感動。 applyEach fs v = ma…

Exercise 9.9

fix 関数の型はどんなものかってのと、 fix を使って remainder を再帰でない形に書き直しなさいって問題。 fix と remainder の定義はそれぞれ以下のとおり: fix f = f (fix f) remainder :: Integer -> Integer -> Integer remainder a b = if a < b then …

Currying

9.1 Curring, More About Higher-Order Functions, "Haskell School of Expression" から引用。 This method of applying functions to one argument at a time, yielding intermediate functions along the way, is called currying, after the logician Ha…

foldl foldl が principal type を持てないわけ

foldl の型は: foldl :: (a -> b -> a) -> a -> [b] -> aこれの第一引数を foldl で束縛しようとすると何が起きるかを考えてみる。第一引数に束縛できるはずなので foldl を (a -> b -> a) にマッチさせなければならない。 foldl の型を三つの部分に分解する…

カリー化された高階関数の型

SOE の Exercise 5.2 は、部分適用済み高階関数の型を問う問題。 map map foldl foldl map foldl公式サイトの Errata に foldl foldl は principal type がなかったごめんという訂正があったので実質二問。いずれにせよ、さらっと流せない難しい問題と感じた…