The figure below calls out
- The netfilter hooks
- The order of table traversal
-- Accessors
_Show :: (Read a, Show a) => Prism' String a
only :: Eq a => a -> Prism' a ()| module ParserCombinator | |
| ( Parser | |
| , parse | |
| , satisfy | |
| , char | |
| , digit | |
| , natural | |
| , token | |
| , oneOf | |
| , listOf |
Re: http://twitter.com/hondallica/status/436117998823165952
クソコードを見たとき: "Looking at this code is pure agony!"
同僚がバグを直してくれた時: "You are an angel sent to save me!"
| import Control.Monad | |
| import Control.Monad.Trans | |
| import Control.Monad.Trans.Loop | |
| main :: IO () | |
| main = do | |
| putStrLn $ "Can you guess the number I have?" | |
| repeatLoopT $ do | |
| a <- liftIO $ readLn | |
| liftIO $ putStrLn $ "You said: " ++ show a |
| import Control.Monad | |
| while :: (Monad m) => (a -> Bool) -> m a -> m a | |
| while f m = do | |
| a <- m | |
| when (f a) $ while f m >> return () | |
| return $ a | |
| main = do | |
| putStrLn $ "Can you guess the number I have?" |
| # 役者クラス | |
| # | |
| # say: 役者は声を発する事ができる。 | |
| class Actor | |
| def say(words) | |
| puts words | |
| end | |
| end |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| newtype FizzBuzz = FizzBuzz Int deriving (Enum, Eq, Ord, Num, Real, Integral) | |
| instance Show FizzBuzz where | |
| show x = (fizz ++ buzz) `or` show asInt where | |
| fizz | ifMultipleOf 3 = "fizz" | otherwise = [] | |
| buzz | ifMultipleOf 5 = "buzz" | otherwise = [] | |
| ifMultipleOf n = x `mod` n == 0 | |
| or [] ys = ys |
| fizzbuzz :: Int -> String | |
| fizzbuzz n = fromMaybe (show n) $ | |
| (guard (n `mod` 3 == 0) >> pure "Fizz") <> | |
| (guard (n `mod` 5 == 0) >> pure "Buzz") | |
| main :: IO () | |
| main = forM_ [1..100] $ putStrLn . fizzbuzz |
| {-# LANGUAGE BangPatterns #-} | |
| import Control.Monad | |
| import Control.Monad.ST | |
| import Control.Applicative | |
| import qualified Data.Vector.Unboxed as V | |
| import Data.Vector.Unboxed ((!)) | |
| import qualified Data.Vector.Algorithms.Intro as Intro | |
| isort v = runST $ do |