0

Imagine you have a function addTogether that can take any number of parameters, and adds them all after the last parameter. I know this could be done ridiculously easily with a List, but I'm just trying out a concept here. I think I remember being able to do so in JavaScript by accessing the arguments object (here). Would it be possible to implement an argument object monad in haskell that translates the arguments applied to a native function (syntactically, so you don't have to explicitly use >>=) into a list of arguments?

Community
  • 1
  • 1
Athan Clark
  • 3,886
  • 2
  • 21
  • 39
  • Well, because the type `a -> b -> c` means `a -> (b -> c)`, a function in Haskell actually only ever takes _one_ argument. (So for example, `f :: a -> b -> c -> d -> e` is `f :: a -> (b -> (c -> (d -> e)))`, and is a function that takes an `a` and returns (a function that takes a `b` and returns (a function that takes a `c` and returns (a function that takes a `d` and returns an `e`))).) – AndrewC Aug 05 '13 at 15:35
  • But what about a function that has it's type signature evaluated at run-time? – Athan Clark Aug 05 '13 at 15:40
  • All the types are determined at compile time. – AndrewC Aug 05 '13 at 15:40
  • 4
    FYI, `printf` [does this](http://stackoverflow.com/questions/7828072/how-does-haskell-printf-work), though not in the same way you're suggesting. – Vlad the Impala Aug 05 '13 at 16:40
  • @AndrewC What about the number of arguments in a type signature? Isn't it critically explicit and limited? Oh wait! I forgot that you can have a list of functions aswell! Or... can you? Or can you only have partially applied functions? – Athan Clark Aug 05 '13 at 18:15
  • 1
    Your question is very vague, please try to add some pseudo code that can help people to understand what exactly you want. – Ankur Aug 06 '13 at 04:26

1 Answers1

1

http://chris-taylor.github.io/blog/2013/03/01/how-haskell-printf-works/ - a good link "Polyvariadic Functions and Printf"

wit
  • 1,612
  • 10
  • 10