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

refutable patterns require MonadFail #14

Open
jwaldmann opened this issue Oct 31, 2020 · 1 comment
Open

refutable patterns require MonadFail #14

jwaldmann opened this issue Oct 31, 2020 · 1 comment

Comments

@jwaldmann
Copy link
Contributor

(with ghc-9.0.1-alpha1) when compiling

model :: ExampleModel ()
model _ = exists $ \col -> do
  [x1,x2,x3,x4,x5,x6,x7,x8,x9,x10] <- colList col 10
  ...

I am seeing

examples/Olympic.hs:40:3: error:
    • Could not deduce (MonadFail m)
        arising from a do statement 
        with the failable pattern ‘[x1,  ...
      from the context: (Show (Control.CP.FD.FD.FDIntTerm s), FDSolver s,
                         Control.CP.SearchTree.MonadTree m,
                         Control.CP.SearchTree.TreeSolver m ~ FDInstance s)
...

the suggested fix seems impossible (there is no m)

      Possible fix:
        add (MonadFail m) to the context of
          the type signature for:
            model :: ExampleModel ()

But still, someone needs to get a MonadFail instance.

@jwaldmann
Copy link
Contributor Author

I will do

class (MonadFail m, Solver (TreeSolver m)) => MonadTree m 
  ...
   exists :: ...

instance Solver solver => MonadFail (Tree solver)
  fail = error

then a failed match will produce

olympic: Pattern match failure in do expression at examples/Olympic.hs:40:3-36
CallStack (from HasCallStack):
  error, called at src/Control/CP/SearchTree.hs:198:10 in monadiccp-0.7.7-inplace:Control.CP.SearchTree

jwaldmann added a commit to jwaldmann/monadiccp that referenced this issue Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant