[Haskell-cafe] Client-extensible heterogeneous types (Duck-typed variadic functions?)

Jacek Generowicz jacek.generowicz at cern.ch
Thu Oct 14 06:09:40 EDT 2010

On 2010 Oct 14, at 09:58, Ketil Malde wrote:

> Jacek Generowicz <jacek.generowicz at cern.ch> writes:
>> Let's say I need an Int -> String. Both
>>    (fnA2 :: Banana -> String) . (fnA1:: Int -> Banana)
>> and
>>    (fnB2 :: Onion -> String) . (fnB1 :: Int -> Onion)
>> will do. So please allow me to store (fnA1, fnA2) and (fnB1, fnB2) in
>> the same place.
> I think you can do this fairly easy with existentials, but..

Yup, that's got through to me by now :-)

>> The program can tell that it can combine them with (.)
> ..what else do you want to be able to do with them?  (Because, if  
> this is
> all, you'd just store the combination, no?).

Yes, if the components became available at the same time. But they  

However, I think that currying caters for this separate arrival time  
problem. Hmm, except that I would like to be able to store a  
collection of incomplete combinations and say "complete the  
combination by injecting random arguments of the relevant type". (This  
probably won't make sense unless you saw the "arithmetic test"  
motivating example.) And currying can't deal with this, as the  
*incomplete* combinations will have different types.

But I suspect that Brandon's suggestion to use QuickCheck's Gen monad,  
could well help with this.

More information about the Haskell-Cafe mailing list