In lens tutorial the following law is mentioned:
view (lens1 . lens2) = (view lens2) . (view lens1)
However, I failed to prove it:
view (lh . lk) ≡ view lk . view lh:
view (lh . lk)
≡ getConst . (lh . lk) Const
≡ \s -> getConst (lh (lk Const) s)
view lk . view lh
≡ getConst . lk Const . getConst . lh Const
≡ \s -> getConst (lk Const (getConst (lh Const s)))
I don’t see how can I make the next step without knowing something about lh
and lk
.