lenses Questions

1

Lens is a function that perform immutable record modification: it copies the record modifying part of its content. Lenses is a library that allows you to combine lenses to attain more complicated m...
Threaten asked 16/1, 2016 at 1:2

2

Solved

Suppose I have a lens like at _ that needs some Maybe a: import Data.Map as M m = M.fromList [(1,(2,3))] --set 2nd element m ^. at 1 .~ Just (4,5) --gives fromList [(1,(4,5))] m ^. at 1 .~ Nothin...
Healing asked 13/1, 2016 at 5:4

2

Solved

If you browse through Lens entry on hackage, Lens Github's repo, or even google about Lens, you will find a lot of partial references such as introductory tutorials/videos, examples, overviews and ...
Sport asked 20/4, 2015 at 8:22

2

Solved

I am struggling to figure out an issue with manipulating JSON with Aeson lenses. My task is as simple as to add a key to a nested object in JSON. I was able to change the existing keyby means of: ...
Richma asked 29/12, 2015 at 12:33

1

Solved

I have a nested case classes structure in a List for simplicity will use following as an example - case class Address(street: String, city: String, state: String, zipCode: Int) case class Perso...
Nguyen asked 9/11, 2015 at 15:31

3

Solved

Defined some nested case classes with List fields: @Lenses("_") case class Version(version: Int, content: String) @Lenses("_") case class Doc(path: String, versions: List[Version]) @Lenses("_") ca...
Bensky asked 28/10, 2015 at 11:35

3

I'm trying to perform a manipulation of a nested data structure containing lists of elements. After mucking around with various approaches I finally settled on lenses as the best way to go about do...
Thinkable asked 28/8, 2013 at 3:52

3

Solved

Some nested case classes and the field addresses is a Seq[Address]: // ... means other fields case class Street(name: String, ...) case class Address(street: Street, ...) case class Company(addres...
Monody asked 21/10, 2015 at 13:54

2

Why do we need Control.Lens.Reified? Is there some reason I can't place a Lens directly into a container? What does reify mean anyway?
Ussery asked 12/10, 2015 at 19:14

1

Solved

I am trying to read the documentation in Edward Kmett's Lens package. I am not familiar with a lot of the terms used (profunctor, isomorphism, monomorphic, contravariant, bifunctor, etc...) What w...
Evictee asked 30/9, 2015 at 22:40

3

Solved

While working on a state called AppState I want keep track of the number of, say, instances. These instances have distinct ids of type InstanceId. Therefore my state look likes this import Contro...
Gervais asked 2/9, 2015 at 12:34

3

Solved

A "lens" and a "partial lens" seem rather similar in name and in concept. How do they differ? In what circumstances do I need to use one or the other? Tagging Scala and Haskell, but I'd welcome ex...
Aslant asked 26/8, 2015 at 10:15

1

I've been reading A wreq tutorial: A lens provides a way to focus on a portion of a Haskell value. For example, the Response type has a responseStatus lens, which focuses on the status informa...

1

Solved

Can anyone explain *what is lenses` in terms of OCaml? I tried to google it, but almost all of them are in Haskell's world. Just wish some simple demonstrations for it in OCaml's world, like wha...
Beadroll asked 27/1, 2015 at 18:16

1

Is there an equivalent of makeLenses for GADTs? If I have a simple GADT like: data D a b where D :: (Ord a, Ord b) => !a -> !b -> D a b Is there a way to generate lenses automatically ...
Gaggle asked 26/1, 2015 at 5:59

2

Solved

Is there a way for me to only export specific getters xor setters from a module with a lens? For example, let's assume a data structure that has an invariant of being always >= 0, being modifi...
Cyprinid asked 14/12, 2014 at 23:9

1

Solved

I have a function that produces an updated board from an input and a board, if the move is permitted by the rules of the game: move :: Input -> Board -> Maybe Board The board is wrapped in...
Gumwood asked 16/1, 2015 at 19:23

1

Solved

I'm trying to refactor my function by giving it a lens argument (from the xml-lens package). I'm missing something about type quantifiers. What is going on here? *Main> let z name = listToMaybe...
Toadflax asked 2/12, 2014 at 10:54

3

Solved

I recently discovered the lens package on Hackage and have been trying to make use of it now in a small test project that might turn into a MUD/MUSH server one very distant day if I keep working on...
Geophysics asked 17/11, 2012 at 20:38

2

Solved

I want to convert this line of code map (^?! ix 0) [[0, 1], [4, 5], [9, 1]] to entirely use lenses, so something like [[0, 1], [4, 5], [9, 1]] & each . ix 0. However, the types don't match up. ...
Joey asked 1/11, 2014 at 6:52

2

Solved

The standard makeLenses implementation generates lenses for all the fields of a record which begin with underscore. I very much dislike the idea of having to introduce such an awkward naming conven...
Arber asked 16/6, 2013 at 10:49

2

Solved

While immutability praised by many, I found it hard to maintain in mainstream programming. In my experience, programmers sooner than later will make fields mutable again to avoid refactoring large ...
Mensa asked 24/8, 2013 at 23:3

1

Solved

Based on: import shapeless._ case class Content(field: Int) lens[Content] >> 'field I am trying to make a lens-creating method, something along: def makeLens[T <: Product](s: Symbol) ...
Volt asked 30/7, 2014 at 14:37

1

Solved

In Clojure we have the identity function. It is used as follows: user=> (filter identity [1 2 3 nil 4 false true 1234]) (1 2 3 4 true 1234) user=> (partition-by identity (sort "abcdaabccc")...
Prewitt asked 28/9, 2014 at 11:37

3

Solved

I am trying to learn about lenses by implementing it in Haskell. I have implemented the view combinator as follows: {-# LANGUAGE RankNTypes #-} import Control.Applicative import Data.Traversable ...
Soneson asked 10/9, 2014 at 19:22

© 2022 - 2024 — McMap. All rights reserved.