[Haskell-cafe] Clean proof?

R J rj248842 at hotmail.com
Sun May 23 11:41:20 EDT 2010


Given the following definition of "either", from the prelude:
    either                      :: (a -> c, b -> c) -> Either a b -> c    either (f, g) (Left x)      =  f x    either (f, g) (Right x)     =  g x
what's a clean proof that:
    h . either (f, g) = either (h . f, g . h)?
The only proof I can think of requires the introduction of an anonymous function of z, with case analysis on z (Case 1:  z = Left x, Case 2:  z = Right y), but the use of anonymous functions and case analysis is ugly, and I'm not sure how to tie up the two cases neatly at the end.  For example here's the "Left" case:
      h . either (f, g)  =    {definition of "\"}      \z -> (h . either (f, g)) z  =    {definition of "."}      \z -> (h (either (f, g) z)
  =    {definition of "either" in case z = Left x}      \z -> (h (f x))  =    {definition of "."}      \z -> (h . f) x  =    {definition of "."}      h . f Thanks. 		 	   		  
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100523/1b250a85/attachment.html


More information about the Haskell-Cafe mailing list