Solutions to the exercises of DaoFP, Chapter 6: DaoFP Chapter 6 Exercises. Index: Map of Content.
Solution 6.3.1
proof program — Exercise 6.3.1
By distributivity, . Directly: a map out of into is a pair , ; the inverse is uncurry of the map given by the pair of elements , — this direction uses the Exponential Object, as in undist.
toSum :: (Bool, a) -> Either a a
toSum (True, a) = Left a
toSum (False, a) = Right a
fromSum :: Either a a -> (Bool, a)
fromSum (Left a) = (True, a)
fromSum (Right a) = (False, a)
-- point-free: toSum = uncurry (\b -> if b then Left else Right)Sources: DaoFP Exercise 6.3.1.