diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-01-03 11:01:20 -0800 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-01-05 09:59:10 -0800 |
commit | 6a0d7f5c434c3564d0119befb6799fd77581050a (patch) | |
tree | f20bc998290211d2a895523417ad32e297b31af0 /ch01_01.4-ii.hs |
Diffstat (limited to 'ch01_01.4-ii.hs')
-rw-r--r-- | ch01_01.4-ii.hs | 8 |
1 files changed, 8 insertions, 0 deletions
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) |