From 6a0d7f5c434c3564d0119befb6799fd77581050a Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Fri, 3 Jan 2025 11:01:20 -0800 Subject: Initial --- ch01_01.4-ii.hs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 ch01_01.4-ii.hs (limited to 'ch01_01.4-ii.hs') diff --git a/ch01_01.4-ii.hs b/ch01_01.4-ii.hs new file mode 100644 index 0000000..552c1e5 --- /dev/null +++ b/ch01_01.4-ii.hs @@ -0,0 +1,8 @@ +-- Exercise 1.4-ii +-- Give a prove of the exponent law that `a^b * a^c == a^(b+c)`. +tup2Either :: (b -> a, c -> a) -> Either b c -> a +tup2Either (f, _) (Left b) = f b +tup2Either (_, g) (Right c) = g c + +either2Tup :: (Either b c -> a) -> (b -> a, c -> a) +either2Tup f = (f . Left, f . Right) -- cgit v1.2.1