Haskell
ftplugin/haskell.vim に setlocal balloonexpr=system('echo\ :t\ '.substitute(v:beval_text,'&','^^^&','g').'\ \|\ ghci\ -v0\ '.expand('%'))[0:-2] setlocal ballooneval [0:-2] で末尾の改行文字を落とす。"&" を "^^^&" にエスケープするのは Window…
そんなんできるのか、と思ってたけど分かってしまえば簡単…なのか? import Numeric (showHex) type Format a b = (String -> a) -> String -> b format :: Format String a -> a format f = f id "" q :: String -> Format a a q x = q' where q' k s = k (…
どこかまでかはかわいいのに、どこかから突然かわいくなくなっちゃう感じ。 うーん、確かにそんな感じですね。。 function iterate (f, s) { return chain([s], { next: function() { return s = f(s) } }) } function right(a, b) { return b } var last = …
f $ x = f x これは map ($ 0) xs あるいは zipWith ($) fs xs など のような高階関数を使う場面でも有用である。 つまり Prelude> zipWith ($) [(1+),(2*),sqrt] [1,2,3] [2.0,4.0,1.7320508075688772]これは便利そう。
参考: http://www.haskell.org/hawiki/MonadState newtype State s a = State { runState :: (s -> (a, s)) } instance Monad (State s) where return a = State $ \s -> (a, s) x >>= f = State $ \s -> let (v, s') = runState x s in runState (f v) s' c…