Skip to content

Instantly share code, notes, and snippets.

@fumieval
Created October 30, 2011 14:30
Show Gist options
  • Save fumieval/1325960 to your computer and use it in GitHub Desktop.
Save fumieval/1325960 to your computer and use it in GitHub Desktop.
2つ以上の引数を持つ関数の合成
f :: Int -> Bool
f x = even x
f' :: (a -> Int) -> (a -> Bool)
f' = (f.) -- (.) :: (β→γ)→(α→β)→(α→γ) αにa、βにInt、γにBoolが当てはまる。
f'' :: (b -> (a -> Int)) -> (b -> (a -> Bool))
f'' = ((f.).) -- (.) :: (β'→γ')→(α'→β')→(α'→γ') α' に b、 β' に a->Int 、 γ'に a->Bool が当てはまる。
g = length :: [d] -> Int
g' = (sum.).filter :: (Int -> Bool) -> [Int] -> Int
g'' = (((sum).).).zipWith :: (j -> k -> Int) -> [j] -> [k] -> Int
fg = f . g :: [d] -> Bool
fg' = f' . g' :: (Int -> Bool) -> [Int] -> Bool
fg'' = f'' . g'' :: (j -> k -> Int) -> [j] -> [k] -> Bool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment