Replies: 2 comments
-
If you're looking for a list comprehension idiom, you can create one yourself:
|
Beta Was this translation helpful? Give feedback.
-
Alternatively, if you want to stay in the pure subset of the language - without algebraic effects (similar to Unison's abilities) - you can use
The benefit of this approach is it is likely slightly more performant. The disadvantage is that the semantics are baked into the computation's description - you always get the behavior of the typical list monad. In the approach with algebraic effects you could decide to make interpret the effects such that guard fails the entire computation tree, or do backtracking search to find the first thing that doesn't fail, return a full search tree instead of a flat list, or many more strategies. |
Beta Was this translation helpful? Give feedback.
-
Howdy!
I'm checking out Koka from Scala and Haskell - what is the idiomatic way to build a list in Koka?
i.e., is there something like a
list
effect that enables something likedo
notation with the List Monad:I am aware that Unison has something like this with their
Each
ability, and that thisdo
notation is of course syntax sugar forbind / flatMap
andmap
, etc.Thank you!
Beta Was this translation helpful? Give feedback.
All reactions