[Haskell-cafe] Haskell extension/improvement
Ron de Bruijn
rondebruijn at yahoo.com
Mon Aug 16 12:01:45 EDT 2004
I was playing with QuickCheck and I just wanted to put
all of my tests in a list, but that's not possible,
because of the fact that a list can only contain
values of the same type.
So concrete I would like to write down this:
prop_RevRev xs = reverse (reverse xs) == xs
where types = xs::[Int]
--trivial test
prop_Simple = True == True
whatIwant::(Testable a)=>[a]
whatIwant = [prop_RevRev, prop_Simple]
testAll::IO ()
testAll = do sequence_ $ map quickCheck whatIwant
quickCheck can work on all Testable values, so why
can't a list (any datastructure) can't hold Testable
values?
What this gives you is, a lot more flexibility. Just
like you can define your functions on interfaces, now
you can use interfaces in your datastructures.
I can't think of any reason why it couldn't be
implemented in any Haskell compiler.
I saw this page:
http://www.haskell.org/hawiki/ExistentialTypes
but you still have to explicitly add the relation via
Obj (and that's bad).
Regards, Ron
P.S. If it already exist in this exact way, how is it
called?
_______________________________
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.
http://messenger.yahoo.com
More information about the Haskell-Cafe
mailing list