[Haskell-cafe] mapTuple (intersection types?)

Greg Buchholz haskell at sleepingsquirrel.org
Thu Jan 11 15:42:51 EST 2007


Udo Stenzel wrote:
> Marco T?lio Gontijo e Silva wrote:
> > is there a way to defined something as a map to use in tuples? I tried
> > this:
> > 
> > mapTuple f (a, b) = (f a, f b)
> > 
> > But the type inferred to it is not as generic as I wanted:
> > 
> > mapTuple :: (t -> t1) -> (t, t) -> (t1, t1)
> 
> What you seem to want to do is impossible.  Just want type would you
> want to assign to mapTuple?  I bet you can't even express that in
> natural language, no wonder it's impossible in Haskell.

    Maybe some of the type experts could pipe up, but couldn't you 
express that as an intersection type?  

    mapTuple :: ((a -> b) ^ (c -> d)) -> (a,c) -> (b,d)


http://www.cs.cmu.edu/~rwh/theses/pierce.pdf

Greg Buchholz



More information about the Haskell-Cafe mailing list