ekmett/lens

Slides for Introduction

Opened this issue · 4 comments

This might not be the right place (feel free to close). But I am just learning about Lens, and the laws on the first slide of introductory slides were quite confusing (i.e. types don't match for the first law) . I ended up looking around and noticing this blog which corrects the first law.

Screen Shot 2021-06-15 at 9 00 02 PM

If I am not mistaken, this could be a huge turn-off for beginners, especially if Lenses are known to be difficult.

EDIT: third -> first

the slides have

set :: Lens s a -> s -> a -> s

my post has both,btw.

set l v' (set l v s) ≡ set l v' s -- without type of set stated, but probably set :: Lens s a -> a -> s -> s
set (set s a) a' ≡ set s a' -- using set :: Lens s a -> s -> a -> s

I guess I mean the first law here then. The slides have:

set l (view l s) s = s

This doesn't quite make sense to me. Shouldn't it be:

set l s (view l s) = s

since (view l s) returns the element a.

@joshcho you are right, the set in first one has flipped arguments. I wonder if @ekmett still has editable slides somewhere.

I'll hunt around for them.