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

Jacek Generowicz jacek.generowicz at cern.ch
Thu Oct 14 03:26:50 EDT 2010


On 2010 Oct 14, at 05:27, Brandon Moore wrote:

> If you just want instances of questions you can keep it simple. How  
> about something isomorphic to
>
> data Instance = Instance { question : String, answer : String,  
> check : String -> Bool }

At first blush, I hated all those Strings hiding the actual type  
information. Thinking about it a bit more, I think that's exactly  
right: when crossing the interface to the outside world, all data have  
type String: the user reads Strings and types back Strings.

A variety of things happens behind those strings, but at the  
interface, they're all strings.

> You could make helper functions similar to your old code, like
>
> addition : (Int , Int) -> Instance
>
> You might handle problem families by taking a random number  
> generator, or maybe using QuickCheck's Gen monad.

Oh, I love the idea of Using QuickGen's Gen for this purpose! (And it  
would finally give me the incentive to get to understand the beast  
properly.)

> easyMultiplication : Gen Instance



More information about the Haskell-Cafe mailing list