Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Variadic-function/Haskell/variadic-function-1.hs
Normal file
17
Task/Variadic-function/Haskell/variadic-function-1.hs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class PrintAllType t where
|
||||
process :: [String] -> t
|
||||
|
||||
instance PrintAllType (IO a) where
|
||||
process args = do mapM_ putStrLn args
|
||||
return undefined
|
||||
|
||||
instance (Show a, PrintAllType r) => PrintAllType (a -> r) where
|
||||
process args = \a -> process (args ++ [show a])
|
||||
|
||||
printAll :: (PrintAllType t) => t
|
||||
printAll = process []
|
||||
|
||||
main :: IO ()
|
||||
main = do printAll 5 "Mary" "had" "a" "little" "lamb"
|
||||
printAll 4 3 5
|
||||
printAll "Rosetta" "Code" "Is" "Awesome!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue