# Hoodlums

Hoodlums Message Board › Homework: Lenses

# Homework: Lenses

 Peter M. Posted 1/23/13 10:57 PM Link to discussion peter_marks Group Organizer London, GBPost #: 54 At this month's session, we looked at lenses. I've posted the code here. We developed a simple lenses pairing an accessor and a modifier function, and we looked at lenses built on the Store comonad and at van Laarhoven lenses. To help us understand these alternative implementations, I thought I'd set a homework on them.The type of van Laarhoven lenses is:> type Lens s a = forall f. Functor f => (a -> f a) -> s -> f s1. Write the functions (^.), (^=) and (%=).2. Write functions to convert from our simple lenses to van Laarhoven lenses and vice-versa.Avoiding the use of Store from Control.Comonad, we can also define:> newtype Lens s a = s -> (a -> s, a)3. Write the functions (^.), (^=) and (%=), and the Category instance.4. Write functions to convert from our simple lenses to these lenses and vice-versa.The fact that we can write these functions to convert both ways shows that these types are isomorphic. Those who attended Chris Taylor's excellent talk The Algebra of Algebraic Data Types, may want to try:5. Show how each of these types are algebraically equivalent. Stephanie R. Posted 11/17/16 1:35 PM Link to reply user 216833657 London, GBPost #: 1 thanks for sharing..indeed an interesting session..and it's helped me a lot with physics paper so that I didn't have to use Online Homework Service..and that's great news to me

### London, United Kingdom

Founded Jul 21, 2010

#### People in this Meetup are also in:

• ##### PyData London Meetup

4,900 members

• ##### West London Hack Night

1,273 Hackers

• ##### London .NET User Group

1,820 Members

• ##### DataKind UK

2,848 Data Heroes

• ##### HNLondon

8,066 Hackers

• ##### LJC - London Java Community

5,940 Java Developers