Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"do" no longer works when value is ignored #1339

Closed
redfish64 opened this issue Apr 27, 2021 · 1 comment
Closed

"do" no longer works when value is ignored #1339

redfish64 opened this issue Apr 27, 2021 · 1 comment

Comments

@redfish64
Copy link
Contributor

redfish64 commented Apr 27, 2021

https://gist.github.com/redfish64/c15272748a802d2bbd29b9855c655343

test : Maybe ()
test =
  do
    pure 'x'
    pure ()

doesn't compile with:

- + Errors (1)
 `-- LearnBug.idr line 16 col 4:
     While processing right hand side of test. Can't find an implementation for Applicative ?f.
     
     LearnBug.idr:16:5--16:13
      12 | 
      13 | test : Maybe ()
      14 | test =
      15 |   do
      16 |     pure 'x'
               ^^^^^^^^

This started occurring after commit: d2eeb7c
I believe part of the reason is that, Prelude/Interfaces.idr was changed as follows:

[nix-shell:~/Idris2]$ git diff d2eeb7ce867cf3bbfa49b45123e9c18964fe64ae~1 d2eeb7ce867cf3bbfa49b45123e9c18964fe64ae libs/prelude/Prelude/Interfaces.idr 
diff --git a/libs/prelude/Prelude/Interfaces.idr b/libs/prelude/Prelude/Interfaces.idr
index ea844768..62f8cf0f 100644
--- a/libs/prelude/Prelude/Interfaces.idr
+++ b/libs/prelude/Prelude/Interfaces.idr
@@ -197,7 +197,7 @@ public export
 
 ||| Sequencing of effectful composition
 public export
-(>>) : (Monad m) => m a -> m b -> m b
+(>>) : Monad m => m () -> Lazy (m b) -> m b
 a >> b = a >>= \_ => b
 
 ||| Left-to-right Kleisli composition of monads.

but there are a lot of changes in that commit, so I'm not sure how this would be fixed.

@stefan-hoeck
Copy link
Contributor

As far as I know, that was intentional (see #1095). Use ignore, to explicitly throw away the result of a computation:

do ignore $ pure 'x'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants