Created
April 12, 2016 10:32
-
-
Save tokiwoousaka/33a279c8e9e41484c8310aa7743c1f2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Safe | |
import Control.Applicative | |
main :: IO () | |
main = do | |
print $ sample ([] :: [Int]) | |
print $ sample [1] | |
print $ sample [1,2] | |
print $ sample [1,2,3,4,5] | |
sample :: Show a => [a] -> Maybe [String] | |
sample xs = fmap (map hoge) $ zip <$> Just xs <*> tailMay xs | |
hoge :: (Show a, Show b) => (a, b) -> String | |
hoge (x, y) = "<" ++ show x ++ ", " ++ show y ++ ">" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment