BartoszMilewski / Publications

Misc. publications, conference slides, etc. For more, go to http://BartoszMilewski.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exercise 2.1.1 in DaoFP

bvoq opened this issue · comments

Hello, great book!
I've gotten very confused with the exercise at 2.1.1:

image

Shouldn't the exercise instead be to prove?
$((g \circ f) \circ -) = (g \circ (f \circ -))$

This works too, but the idea is to prove something like, for instance, this:

import Data.Char

f :: Char -> Int
f = ord
g :: Int -> String
g = show

foo, bar :: (x -> Char) -> (x -> String)
foo = \h -> (g . f) . h
bar = (\j -> g . j) . (\h -> f . h)

test :: String -> Char
test = head . drop 1

main = do
print $ (foo test) "abc"
print $ (bar test) "abc"