Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
54 views

Here is the data structure data Fruit = Apple String Int | Banana String | .... | Orange Int Int data Baseket = BaseketA Fruit | BaseketB Fruit Int ...
Shawn Zhang's user avatar
  • 1,883
3 votes
0 answers
133 views

Consider these datatypes: data SomeNestedData = SomeNestedData { sndValue :: Int } data OtherNestedData = OtherNestedData { ondValue :: Int } data Foo = Bar SomeNestedData | Baz OtherNestedData How ...
ruben.moor's user avatar
  • 2,005
1 vote
0 answers
232 views

We are using for our frontend application store Zunstand with Immer for immutability and Zustand lens for separating slices. I noticed that, due to an error runtime in Javascript console, we used a ...
Francesco Meli's user avatar
1 vote
1 answer
122 views

I'm trying to remove an element from an Array a using the index of the element but I can't find a way to do it with Lenses. I'm also wondering why Array does not provide an instance for the At lens. ...
amaille's user avatar
  • 65
3 votes
2 answers
267 views

The traverse lens (is it a lens?) allows looking at Map key value in a value-by-value basis. For example: import Data.Map import Control.Lens simpleMap :: Map Int Char simpleMap = fromList [(1, 'a'), ...
Agnishom Chattopadhyay's user avatar
9 votes
1 answer
122 views

As I understand it, each van Laarhoven optic type can be defined by a constraint on a type constructor: type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t type ...
Katie Casamento's user avatar
0 votes
1 answer
78 views

Suppose I have a record like this: type Order = | Order type OrderBook = { PrimaryOrderID : Guid Orders : Map<Guid, Order> } I would like to do nested updates using lenses. Here ...
sdgfsdh's user avatar
  • 37.8k
1 vote
2 answers
218 views

The sample code of the documentation defines _pageNumber using List._item, but I can't seem to find an example of its use. I tried the following code but it gave an error. view (Book._pageNumber 1) ...
topica's user avatar
  • 329
2 votes
2 answers
167 views

A type Prism' s a = Prism s s a a (hackage) can be thought of as a relation between some structure s and its member a, such that you can always produce the structure from the member (a -> s), but ...
Sridhar Ratnakumar's user avatar
1 vote
0 answers
192 views

Can i access nested properties with monocle-ts in a dynamic fashion? The closest i can find directly from the library is the Optional.fromPath, combined with a dynamic path. Based on the example from ...
Simon's user avatar
  • 661
1 vote
1 answer
119 views

I am curious about Eq instance for lenses. Lenses are functions. It is hard to compare arbitrary functions, but lenses are special class of functions. I am thinking about using QuickCheck Arbitrary ...
Daniil Iaitskov's user avatar
3 votes
2 answers
208 views

When learning about Haskell lenses with the Optics package, i encountered the following example: data Person = Person { _name :: String , _age :: Int } makeLenses ''Person makePrisms 'Person ...
manews's user avatar
  • 410
3 votes
2 answers
240 views

I would like to define something like a lens, but which can fail when trying to set. See fooLens in the following example. {-# LANGUAGE RankNTypes #-} import Data.Char (toUpper) import Data.Functor....
Stephen Morgan's user avatar
1 vote
2 answers
131 views

I'm trying to get the hang of lenses. Is there a more idiomatic way to write the following? (placeholders preceded by underscores) flip (set _lens) _a . fmap _f To me, the use of flip seems to ...
Ari Fordsham's user avatar
  • 2,524
1 vote
0 answers
113 views

Suppose I have the following types interface State { parents: Parent[] } interface Parent { uniqueName: string children: Child[] // other props } interface Child { uniqueName: string ...
user1713450's user avatar
  • 1,513
1 vote
1 answer
151 views

Given a record consisting of multiple maps, how can I write a traversal (or prism, or Lens' TestLens (Maybe Interim)) that allows me to group together lookups? First off, my current attempts. data ...
PrettyPrincessKitty FS's user avatar
2 votes
1 answer
138 views

I’m using Data.Sets in deeply-nested heterogeneous data structures, and thought it would be helpful to create a Prism for set membership. Hence: membership :: (Ord a) => a -> Prism' (Set a) (Set ...
Jason Whittle's user avatar
0 votes
0 answers
157 views

I achieved to implement Getter, Setter, Lens, LensAt (aka At in monocle) and LensOpt (aka Optional in monocle), However, I failed to generalize from Lens to Traversal and from Getter to Fold by adding ...
user avatar
3 votes
1 answer
662 views

(Edit I'm using monocle-ts, but if it's not possible with monocle-ts (since the author even says it's just a partial port of the original Monocle for Scala) but if there is something in another optics ...
user1713450's user avatar
  • 1,513
4 votes
1 answer
434 views

I'm currently trying to make parts of my code more concise using lenses. In particular, I have a HTTP Request where I want to replace the value of a header with the name Private-Header. I managed to ...
l7r7's user avatar
  • 1,358
8 votes
0 answers
126 views

I've had a bit of difficulty using Lenses with Maps. I have maps that look like this Map String (Map String Int). These are multidimensional arrays, and I usually set them up with known dimensions. I ...
Pasindu Muthukuda's user avatar
0 votes
1 answer
778 views

lenses kudu sink connector version = kafka-connect-kudu-1.2.3-2.1.0 kudu table schema CREATE TABLE IF NOT EXISTS table_name( su_id bigint not null, su_tenant_id int null, su_bu_id int null, ...
Mohan Rajan K's user avatar
1 vote
1 answer
156 views

Consider a list of items [a] and a pair of functions pop :: [a] -> (Maybe a, [a]) pop = headMay &&& tailSafe push :: a -> [a] -> [a] push = (:) which just provide the list with ...
marcosh's user avatar
  • 9,038
0 votes
1 answer
106 views

Let's say I have a Node and it can have children and siblings and I have traversal lens implementations for them. How do I compose them into a single lens that traverses both children and siblings? ...
MnZrK's user avatar
  • 1,380
1 vote
1 answer
74 views

I feel like I am doing something wrong, as I am not even managing to reproduce Haskell's lens tutorial: > import Control.Lens > data Point = Point { _x :: Double, _y :: Double } deriving (Show) ...
Kiara Grouwstra's user avatar

1
2 3 4 5 6