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
-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
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
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 ->