class MonadFoo m where
foo :: forall a. Typeable a => a -> m a
makeMockable ''MonadFoo
foo is considered unmockable, because matching the method is no longer enough to prove equality of the return types, so we cannot be sure that the response has the right type for the actual call. But there is a Typeable constraint, so we should be able to check this at runtime instead! That is, one should be able to write something like:
expectAny $ Foo_ (typed @Bool anything) |-> True
Unifying the return types requires a cast in the generated matchAction, but we should have the constraints that we would need to implement this.
Migrated from TODO file.
This doesn't work.
foo
is considered unmockable, because matching the method is no longer enough to prove equality of the return types, so we cannot be sure that the response has the right type for the actual call. But there is aTypeable
constraint, so we should be able to check this at runtime instead! That is, one should be able to write something like:Unifying the return types requires a
cast
in the generatedmatchAction
, but we should have the constraints that we would need to implement this.