forall quantifier
Ketil Z. Malde
ketil@ii.uib.no
04 Jun 2003 15:20:20 +0200
Hi,
This is one of those topics everybody else seems to be familiar with,
but which I don't quite understand, and can't seem to find any good
information about.
I have a function declared as:
anova2 :: (Fractional c, Ord b)
=3D> [a->b] -> (a->c) -> [a] -> [Anova1 c]
where the first parameter is a list of classifiers. I could simplify
it, I guess, to something like
classify :: Eq b =3D> [a->b] -> [a] -> [[[a]]]
classify cs xs =3D ...
where for each classifying function in cs, I would get the xs
partitioned accordingly. E.g.
classify [fst,snd] [(1,0), (1,2), (2,0)]=20
would yield
[ [(1,0), (1,2)], [(2,0)] -- classified by `fst`
, [(1,0), (2,0)], [(1,2)]] -- classified by `snd`
Now, obviously, the problem is that fst and snd, being passed in a
list, needs to be of the same type; this complicates classifying a
list of type [(Int,Bool)], for instance=B9.
I have a vague notion this is solvable using quantifiers (since I
ever only use Eq operations on the type), but I'm not sure exactly
how, I can't seem to find a good tutorial, and my Monte-Carlo
programming approach doesn't seem to be leading anywhere :-)
Can somebody suggest a solution, or a place to look?
-kzm
=B9 I guess I can convert Bool to Int (True->1, False->0), but it's not
very appealing, IMHO.
--=20
If I haven't seen further, it is by standing in the footprints of giants