BartoszMilewski / Publications

Misc. publications, conference slides, etc. For more, go to http://BartoszMilewski.com
1.24k stars 38 forks source link

Exercise 2.1.1 in DaoFP #15

Closed bvoq closed 1 year ago

bvoq commented 1 year ago

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 -))$

BartoszMilewski commented 1 year ago

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"