Considering: 

foldr:: (a -> b -> b) -> b -> [a] -> b
union:: [a] -> [a] -> [a]                           and
union :: ( a -> a -> Bool) -> [a] -> [a] -> [a]

Then:
        f = union . map fst        

where:

map:: (a -> b) -> [a] -> [b]
(.):: (a -> b) -> (c -> a) -> c -> b
fst :: (a,b) -> a

has type (in System CT)

---------------------------------------------------------------
        { union:: b -> [a] -> c }. [(b, d)] -> [a] -> c
---------------------------------------------------------------

which comes from the generalisation of the two possibilities: 

     [(a, d)] -> [a] -> [a]
and
     [(a -> a -> Bool), d] -> [a] -> [a] -> [a]

Here: 
     b is the generalisation of [a] and (a -> a -> Bool)
     c is the generalisation of [a] and [a] -> [a]

By the way, I would appreciate if someone could explain the type

   g :: (a -> (a -> a,b)) -> [a] -> [a] -> [a]
        *****************
   (where g = unionBy . map fst)

given by Hugs (ghc behaves differently... ).

Yours,

Carlos





Reply via email to