Skip to content

Instantly share code, notes, and snippets.

@tokiwoousaka
Created April 12, 2016 10:32
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/33a279c8e9e41484c8310aa7743c1f2e to your computer and use it in GitHub Desktop.
Save tokiwoousaka/33a279c8e9e41484c8310aa7743c1f2e 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 = 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