What
>>22 is
trying to say is that this is pointless to even try in Haskell. The type system forces you to either write a special monad specifically for the purpose of calling
cycle[/cycle], or fuck around with the IO monad so at least you can intersperse it with IO calls.
Oh, and all the arguments have to be of the same type....Actually, it's even worse than that. Since you need a way to compare argument lists to each other, the type signature should say [code](Eq a) => stuff or
(Ord a) => stuff, which means that
a can't be a function type, which means you can't even use a list like
[print 4, print 2]. So basically this (toy) function is more useless than ever in Haskell.
There is a way around this, but it means using separate functions for setting and getting the argument list (and still using a special monad). If you have
setArgs :: [a] -> State [a] () and
getArg :: State [a] a, the implementation is trivial. The catch is that you can only access the last arglist you set with
setArgs, and if you've got different types of arglists you want to use, you have to actually thread them through different instances of
State [a].