[[ : MkFoo :: forall a. a -> (a -> Bool) -> Foo Nil :: Foo
Notice that the type variable a in the type of MkFoo does not appear in the data type itself, which is plain Foo. For example, the following expression is fine:
[MkFoo 3 even, MkFoo 'c' isUpper] :: [Foo]
Here, (MkFoo 3 even) packages an integer with a function even that maps an integer to Bool; and MkFoo 'c' isUpper packages a character with a compatible function. These two things are each of type Foo and can be put in a list.
:
]]
--
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#EXISTENTIAL-QUANTIFICATION
At 15:20 04/06/03 +0200, Ketil Z. Malde wrote:
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) => [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 => [a->b] -> [a] -> [[[a]]] classify cs xs = ...
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)]
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¹.
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
¹ I guess I can convert Bool to Int (True->1, False->0), but it's not very appealing, IMHO. -- If I haven't seen further, it is by standing in the footprints of giants _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
------------------- Graham Klyne <[EMAIL PROTECTED]> PGP: 0FAA 69FF C083 000B A2E9 A131 01B9 1C7A DBCA CB5E
_______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell