Re: [Haskell-cafe] Sneaky method for var-arg fns?

2013-07-26 Thread Brandon Allbery
On Fri, Jul 26, 2013 at 5:08 PM, Micah Cowan wrote: > I was wondering if there was a way to do it in "pure" Haskell (i.e., no > GHC pragmas required), and also the specific reason for why the above > example doesn't work without the pragma (I think it's just that in > general a -> b is not syntac

Re: [Haskell-cafe] Sneaky method for var-arg fns?

2013-07-26 Thread Mateusz Kowalczyk
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 26/07/13 22:08, Micah Cowan wrote: > So, just for fun, I came up with a way to abuse the language in > order to define a "function" whose argument is optional: > >> -- dirty-trick.hs - A sneaky way to do var args fns in Haskell >> >> {-# LANGUAGE

Re: [Haskell-cafe] Sneaky method for var-arg fns?

2013-07-26 Thread Tikhon Jelvis
Take a look at Text.Printf which takes this idea even further with its printf function, which can accept an arbitrary number of arguments. This is achieved by basically using your approach but with a recursive instance. On Jul 26, 2013 10:10 PM, "Micah Cowan" wrote: > So, just for fun, I came up

[Haskell-cafe] Sneaky method for var-arg fns?

2013-07-26 Thread Micah Cowan
So, just for fun, I came up with a way to abuse the language in order to define a "function" whose argument is optional: > -- dirty-trick.hs - A sneaky way to do var args fns in Haskell > > {-# LANGUAGE FlexibleInstances #-} > > class Hello a where > hello :: a > > instance Hello (String ->