Announcing HMock 0.3

Chris Smith
1 min readJun 30, 2021

I’ve just released HMock 0.3 to Hackage. See the original announcement for more details on the project.

Highlights of this release include:

  • You can now use the WholeMethodMatcher type in an expectation to write a custom predicate that looks at more than one argument at a time when deciding whether to match a method call.
  • You can now add side-effects to methods using whenever. You should prefer to avoid this and use expectations instead, since if you’re not careful side-effects can accidentally match method calls that you weren’t looking for. But occasionally this can be very useful.
  • You can now mock methods with a polymorphic return type. There must be a Typeable constraint on the return type for this to work.

This is still classified as a preview release, as I’m planning large breaking changes in order to integrate with effect systems and API layers, such as polysemy, fused-effects, servant, and haxl. You can safely use HMock as long as you add an upper bound on the second component of the version number.

--

--

Chris Smith

Software engineer, volunteer K-12 math and computer science teacher, author of the CodeWorld platform, amateur ring theorist, and Haskell enthusiast.