Skip to content

Instantly share code, notes, and snippets.

@Nucleareal
Created April 1, 2014 09:08
Show Gist options
  • Select an option

  • Save Nucleareal/9910605 to your computer and use it in GitHub Desktop.

Select an option

Save Nucleareal/9910605 to your computer and use it in GitHub Desktop.
可変長引数のメモ
{-# LANGUAGE FlexibleInstances #-}
class Watashi a where
next :: [String] -> a
instance Watashi String where
next = unwords . reverse
instance (Watashi r) => Watashi (String -> r) where
next xs b = next $ b:xs
watashi :: (Watashi a) => a
watashi = next []
main :: IO ()
main = do
putStrLn $ watashi
putStrLn $ watashi " ( ^o^)"
putStrLn $ watashi " ( ^o^)!" " " "(^o^ )"
putStrLn $ watashi " ( ^o^) (^o^ )"
putStrLn $ watashi " ( ^o(^o^ )"
putStrLn $ watashi " ( ^o^)" "(^q^)" "(^o^ )"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment