{-# LANGUAGE FlexibleInstances, RankNTypes #-} -- (0)
class VarArgs a
where prc
:: String -> a
-- (1)
instance VarArgs
String where prc
= id -- (2)
instance (Show a
, VarArgs r
) => VarArgs
(a
-> r
) where -- (3) prc acc
= \x
-> prc
$ acc
++ "/" ++ show x
magic :: VarArgs a => a
magic = (prc "seed:") :: (VarArgs a => a)
shmagic _ = (prc "shmagic:")
useMagic
:: (forall a
. VarArgs a
=> a
) -> IO () -- (4)useMagic f = do
main = do
putStrLn $ magic
1 2 "qwe" [1,2,3] 123.456 useMagic magic -- (5)
ey0jIExBTkdVQUdFICBGbGV4aWJsZUluc3RhbmNlcywgUmFua05UeXBlcyAjLX0gLS0gKDApCgpjbGFzcyBWYXJBcmdzIGEgd2hlcmUgcHJjIDo6IFN0cmluZyAtPiBhIC0tICgxKQoKaW5zdGFuY2UgVmFyQXJncyBTdHJpbmcgd2hlcmUgcHJjID0gaWQgLS0gKDIpCgppbnN0YW5jZSAgKFNob3cgYSwgVmFyQXJncyByKSA9PiBWYXJBcmdzIChhIC0+IHIpIHdoZXJlIC0tICgzKQogICAgcHJjIGFjYyA9IFx4IC0+IHByYyAkIGFjYyArKyAiLyIgKysgc2hvdyB4IAoKbWFnaWMgOjogVmFyQXJncyBhID0+IGEKbWFnaWMgPSAocHJjICJzZWVkOiIpIDo6IChWYXJBcmdzIGEgPT4gYSkKCnNobWFnaWMgXyA9IChwcmMgInNobWFnaWM6IikKCnVzZU1hZ2ljIDo6IChmb3JhbGwgYS4gVmFyQXJncyBhID0+IGEpIC0+IElPICgpIC0tICg0KQp1c2VNYWdpYyBmID0gZG8KICAgIHB1dFN0ckxuICQgZiAxIAogICAgcHV0U3RyTG4gJCBmIDEgInF3ZSIKICAgIHB1dFN0ckxuICQgZiAxICJxd2UiIFsxLCAyLCAzXQoKbWFpbiA6OiBJTyAoKQptYWluID0gZG8gCiAgICBwdXRTdHJMbiAkIG1hZ2ljIDEgMiAicXdlIiBbMSwyLDNdIDEyMy40NTYKICAgIHB1dFN0ckxuICQgbWFnaWMgMTAwNTAwCiAgICBwdXRTdHJMbiAkIG1hZ2ljCiAgICB1c2VNYWdpYyBtYWdpYyAgLS0gKDUpCgo=