monadiccp
monadiccp copied to clipboard
refutable patterns require MonadFail
(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.
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