ulysses4ever / Monads.jl

Monadic expressions and sequences for Julia
https://monads-jl.readthedocs.io/
MIT License
32 stars 12 forks source link

@mdo returns Nothing? #25

Open lyd1ng opened 4 days ago

lyd1ng commented 4 days ago

Hi, I am fairly new to julia but got quite excited when I found out that there is a Monads library. Now even with all the tests passing I am uncertain if the mdo macro works properly. I was going through the examples on https://monads-jl.readthedocs.io/en/latest/ but had to find out, that all the code snippets including the mdo macro does indeed return nothing!

ulysses4ever commented 4 days ago

Hello!

Disclaimer. This is an experimental library. It's also not under active development these days.

That said, the library has basic stuff working. In particular, (well-formed) @mdo expressions return monadic values. One particular example of a monadic value is nothing, and this value can appear as a result of an @mdo expression in the Maybe monad. The doc page you reference has such an example with nothing as a result. But the same doc page has several examples with results other than nothing. For example, the very first example returns a list (a value of type MList in this case)

julia> @mdo MList begin
         a <- MList(1:3)
         b <- MList(1:3)
         guard(a!=b)
         return (a,b)
       end
MList([(1,2), (1,3), (2,1), (2,3), (3,1), (3,2)])

What led you to believe @mdo always returns nothing? Can you provide a specific example?

ulysses4ever commented 3 days ago

I also just checked that the package correctly installs and passes tests with Julia 1.9.

ulysses4ever commented 3 days ago

I restarted and restructured the CI a bit, and as the latest run shows, https://github.com/ulysses4ever/Monads.jl/actions/runs/11108379516 the package indeed fails on Julia 1.10 with @mdo returning nothing but works properly in Julia 1.9. I'll investigate the failure on the latest Julia and report back this week.