7 ms·
Let’s just say that if you wanted to understand lenses, this is not where you should start; and if you wanted to move to more advanced scenarios, I wouldn’t sta
by moomin 1y ago
Let’s just say that if you wanted to understand lenses, this is not where you should start; and if you wanted to move to more advanced scenarios, I wouldn’t start here either.
- xtoilette 1y agowhere would you start?
- neanderzander 1y agoI found this accessible: https://academy.fpblock.com/haskell/tutorial/lens/ https://academy.fpblock.com/haskell/tutorial/lens/
- deleted 1y ago[deleted]
- wk_end 1y agoAssuming you've got experience with Javascript, read the "Motivation" section on the monocle-ts website: https://gcanti.github.io/monocle-ts/ https://gcanti.github.io/monocle-ts/
- raluk 1y agohttps://blog.jle.im/entry/lenses-products-prisms-sums.html https://blog.jle.im/entry/lenses-products-prisms-sums.html
- cosmic_quanta 1y agoWhat a great read! I had never encountered or thought about prisms before, but now it I see how useful they could be. Thank you for sharing
- KPGv2 1y agoOptics by Example by Chris Penner is good. https://leanpub.com/optics-by-example/ https://leanpub.com/optics-by-example/
- raluk 1y agoGreat exercise driven course is: https://github.com/system-f/lets-lens https://github.com/system-f/lets-lens
- ohdeargodno 1y agoA first good step is getting rid of Haskell's obscure and impenetrable syntax, and checking implementations that would be more readable. Kotlin's Arrow library hits a good middle ground between FP wizardry and readability, and their documentation on lenses are understandable for the average person: https://arrow-kt.io/learn/immutable-data/lens/ https://arrow-kt.io/learn/immutable-data/lens/ / https://arrow-kt.io/learn/immutable-data/intro/ https://arrow-kt.io/learn/immutable-data/intro/
- epgui 1y ago> Haskell's obscure and impenetrable syntax Uhhh... Haskell syntax is simpler than python's or javascript's. It's neither obscure nor impenetrable, but it sounds like it's different than what you're used to.
- HappMacDonald 1y agoHaskell has enough punctuation to make Larry Wall blush
- epgui 1y agoThey’re just regular functions, but infix.
- HappMacDonald 1y ago```Haskell -- | Flipped version of '<$>'. infixl 1 <&> (<&>) :: Functor f => f a -> (a -> b) -> f b as <&> f = f <$> as ``` "infix", "Functor", and "as" are the only words in this code. Everything else is single letters (thanks math traditions..) and punctuation. What's a <&>? <$>? ::? We've got two different kinds of arrows, => and ->. -- is obviously enough a line comment. At least I know what = means.. give or take it's constant ambiguous meaning between languages of assignment and/or equality testing. And this isn't even delving into the black arts of defining types, where the really ugly punctuation toolkits get opened. I don't care whether or not they represent regular functions nor what their calling syntax is. What I care is that the base language has many many dozens of them to remember and then to parse in the wild, and then that authors are encouraged to continue proliferating more of them: ```Haskell -- What does this 'mouse operator' mean? :thinking_suicide: (~@@^>) :: Functor f => (a -> b) -> (a -> c -> d) -> (b -> f c) -> a -> f d ``` Credit: Kowainik's Haskell Style Guide https://kowainik.github.io/posts/2019-02-06-style-guide https://kowainik.github.io/posts/2019-02-06-style-guide
- smegma2 1y agoAgreed, I think this tutorial is good: https://hackage.haskell.org/package/lens-tutorial-1.0.5/docs/Control-Lens-Tutorial.html https://hackage.haskell.org/package/lens-tutorial-1.0.5/docs...