typeclasses / haskell-phrasebook

The Haskell Phrasebook: a quick intro to Haskell via small annotated example programs
https://typeclasses.com/phrasebook
210 stars 22 forks source link

Add records with optics example #34

Closed cideM closed 5 years ago

cideM commented 5 years ago

For #9

Shows how to use set, over, and view and also has a little example for how to compose simple lenses. I think adding the % example makes sense since nested record updates aren't so rare and I think this hints at the many possibilities that lens composition offers without introducing anything too complex.

The TemplateHaskell part could be replaced by manually writing some lenses but considering how common it is to use TH here I'd keep TH.

argumatronic commented 5 years ago

Yeah, this is a great example -- brief and clear and practical. We tend to agree with you about keeping the TemplateHaskell extension. We'd like to go ahead and merge this. We license all the code in this repository under CC-BY-NC 4.0, and we'd like to add you to the contributors page, unless you prefer that we don't. If you'd like us to link to something specific, such as your blog or GitHub profile, we'd be happy to -- just let us know your preferences and if you agree to the licensing. Thank you!

cideM commented 5 years ago

@argumatronic I definitely agree to the licensing and would be happy to have my blog linked ❤️

argumatronic commented 5 years ago

Great, thank you!