[darcs-users] darcs patch: Add Test.Runner module to run the unit t... (and 7 more)

Jason Dagit dagit at codersbase.com
Tue May 19 21:02:16 UTC 2009


On Tue, May 19, 2009 at 1:27 PM, Reinier Lamers <tux_rocker at reinier.de> wrote:
> Hi Jason,
>
> On Tuesday 19 May 2009 19:17:56 Jason Dagit wrote:
>> >> I have not made a typeclass for test results, because that would make it
>> >> impossible to put test results of mixed origin in a list.
>>
>> I don't understand this comment.  Makes it impossible unless someone
>> writes an instance for the particular datatype?
>>
>> Lists can be created like this, Foo a => [a], so I don't really see
>> what the problem is without further investigation (see below).
>
> I don't see much below so I'll reply here. AFAIK lists always require that the
> elements have the same type. Like "data List a = Nil | Cons a (List a)". I
> suppose there can be only one instantiation for a in that GADT definition. And
> all my attempts to create mixed-type lists of Show instances fail in ghci.

Sorry, I was too terse.  I was thinking something like:
data ResultList a = Foo a => RL [a] -- untested, double check my syntax

testIt :: Foo a => [a] -> b
testIt xs = testIt' (RS xs)
  where
  testIt' :: ResultList a -> b
  testIt' ...

Now the client code just provides instances of Foo and testIt should
just be able to stick them inside the ResultList data type and
consumers of a ResultList type don't know the type of 'a', but they
can access the important bits through the interface of Foo.

I'm sort of rushing and I haven't tested it so I could be missing something.

Jason


More information about the darcs-users mailing list