Arrow はステキ
下のやつを Arrow を使って書き直してみる。ばっちりポイントフリー。
kaibun :: Eq a => [a] -> Bool kaibun = id &&& reverse >>> (uncurry $ zipWith (==)) >>> and
ようやく Arrow の使いどころを見つけたか…。いや、いちいちこんなふうに書くやつがいたら頭おかしいと思いますが。
でも、パズルとしてはおもしろいね。
で、型宣言を省くと怒られる。
Prelude> :load "/Users/sho/src/haskell/kaibun.hs" [1 of 1] Compiling Main ( /Users/sho/src/haskell/kaibun.hs, interpreted ) /Users/sho/src/haskell/kaibun.hs:7:47: Ambiguous type variable `a' in the constraint: `Eq a' arising from use of `==' at /Users/sho/src/haskell/kaibun.hs:7:47-50 Possible cause: the monomorphism restriction applied to the following: kaibun :: [a] -> Bool (bound at /Users/sho/src/haskell/kaibun.hs:7:0) Probable fix: give these definition(s) an explicit type signature or use -fno-monomorphism-restriction Failed, modules loaded: none. Prelude>
Probable fix の or に注目。"-fno-monomorphism-restriction" ってなんだ。なんか昔 id:syd_syd さんがモノモルがどうこう言ってたような…。気のせい?