diff options
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) |