dotty-cps-async icon indicating copy to clipboard operation
dotty-cps-async copied to clipboard

write a small but interesting self-contained example with simple monad

Open rssh opened this issue 5 years ago • 5 comments
trafficstars

use as monad Try[List[_]] (or just List) and implement some exploring space algorithms, such as 8 eight queens puzzle, or knight tour in the monad, to have an example, which will not compile, but will eventually be compiled after we will add more construct. This will make the game of enumerating all possible scala syntax trees not such boring ;)

Now - all language construct are implemented, so. task can be reformulated as: define CpsAsyncMonad for Try[List[_]] (or use existing CpsMonad for List). to write some space exploration algorithm in direct style.

rssh avatar Jan 23 '20 17:01 rssh

Even a nice example just showing its use to some remote APIs would be nice!

aappddeevv avatar Apr 14 '20 19:04 aappddeevv

first nontrivial example is in scala-gopher:https://github.com/rssh/scala-gopher/blob/master/shared/src/test/scala/gopher/monads/Queens.scala

rssh avatar May 09 '21 13:05 rssh

I am interesting in this project please assign me task

latifbhatti avatar Mar 04 '23 04:03 latifbhatti

hey @rssh , I wanted to give you an update on the task you assigned during our last meeting. As you suggested, I used the Try[List[_]] monad to implement some space exploration algorithms such as the Subset Sum problem. The code is available at this link: https://github.com/samadpls/scala-gopher/blob/patch-1/shared/src/test/scala/gopher/monads/Subset_Sum.

The code works by recursively exploring all possible subsets of a given set and checking if any of them add up to a given sum. If a subset is found that adds up to the sum, the function returns Success with the subset as a List[List[Int]]. If no subset is found, the function returns Success with an empty List[List[Int]]. If there is an error, the function returns Failure with an error message.

samadpls avatar Mar 09 '23 14:03 samadpls

@samadpls But how is this related to the dotty-cps-async project? The idea of this task is to receive a nice example of the applicability of the direct style (i.e. using async/await) for some non-usual monad.

rssh avatar Mar 09 '23 18:03 rssh