close
Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
0 votes
1 answer
161 views

Note that I do not agree that my question is a duplicate of the linked question, even though the title would appear to imply it is. The accepted answer to that question is to force unwrap Binding<...
Peter M's user avatar
  • 7,637
3 votes
1 answer
100 views

I am trying to understand the getOrElse() function of arrow-kt. I want to create a simple function that takes a list of strings, filters them, and returns the first matching value as an Option<...
pbuchheit's user avatar
  • 1,849
1 vote
1 answer
105 views

I'm working on migrating some existing Kotlin code from Arrow 1.x to 2.x. The old code looked something like this: fun filterStrings(incoming: List<String>): Option<String> = incoming ....
pbuchheit's user avatar
  • 1,849
0 votes
2 answers
239 views

A monad, I've been told, is a monoid of X in the category of endofunctors of X, where X is some category. Maybe is supposedly then a monoid, which means that it is: an object of a category, some ...
Erik's user avatar
  • 19
1 vote
2 answers
85 views

I am trying to combine Option.defaultValue with failWith to get exception for None values: printf "%A" (Some 1 |> Option.defaultValue (failwith "Error")) But this code raise ...
Andrey's user avatar
  • 6,659
7 votes
1 answer
108 views

I'm trying to implement a binary search tree. The parent struct, BinSearchTree, has a pointer to a root node: pub struct BinSearchTree { root: Option<Box<Node>>, size: u32, } ...
workerjoe's user avatar
  • 2,797
1 vote
1 answer
101 views

I want to add properties window with auto properties based on struct fields. I'am downcasting every field, but for Vec<> and Option<> I have to duplicate all code, how can I automatically ...
Kravtsov Hryhorii's user avatar
0 votes
2 answers
83 views

I have a map which lays down prices of commodities in different currencies val commpricemap: Map[String , Map[String, Double]] = ??? AN example of an entry for gold is as below: ("AU" -> ...
IUnknown's user avatar
  • 10k
1 vote
2 answers
101 views

I have a Option sequence of dates - from which I need to SAFELY extract the first date after a given date( or else return the given date). The below seems to be a lot of code for such a simple used ...
IUnknown's user avatar
  • 10k
1 vote
1 answer
148 views

Suppose I'm implementing the function returning an std::optional<T>. In that function, I compute some condition, and then want to return either a value, or a nullopt. I can do it like so: std::...
einpoklum's user avatar
  • 140k
0 votes
1 answer
244 views

I find myself regularly encountering the need for logic where two optional values should be "merged" where: if both are None -> give me None if only one is Some -> give me Some of ...
kmdreko's user avatar
  • 66.2k
0 votes
1 answer
119 views

My working definition for value is a special kind of expression that evaluates to itself. So 1 is a value, and 1 + 1 is valuable but not a value because it evaluates to 2. A datatype constructor like ...
qwr's user avatar
  • 11.7k
3 votes
2 answers
202 views

The way I look at MonadState, for instance, is that any type (or set of types, e.g. ReaderT r m a) that implements it, must support get+put (or alternatively just state) in order to behave like the ...
Enlico's user avatar
  • 30.8k
3 votes
1 answer
84 views

I’m working with Swift and encountered an issue when using the contains method on an array. The following code works fine: let result = ["hello", "world"].contains(Optional("...
mskim's user avatar
  • 33
1 vote
4 answers
92 views

In some test code, I have a Seq[A] that I'm filtering down to items matching a given property. There should be at most one such element in the sequence. If it has more, it means I set up something ...
M. Justin's user avatar
  • 23.7k

15 30 50 per page
1
2 3 4 5
256