Skip to content

Instantly share code, notes, and snippets.

@tokiwoousaka
Created April 12, 2016 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tokiwoousaka/8592132308b065a4e1065c0cafbd2c24 to your computer and use it in GitHub Desktop.
Save tokiwoousaka/8592132308b065a4e1065c0cafbd2c24 to your computer and use it in GitHub Desktop.
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 = zipWith hoge <$> 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