[Haskell-cafe] ANN: rematch, an library for composable assertions with human readable failure messages

Petr Pudlák petr.mvd at gmail.com
Tue Apr 16 19:46:26 CEST 2013


2013/4/16 Ross Paterson <R.Paterson at city.ac.uk>

> On Tue, Apr 16, 2013 at 10:17:48AM +0100, Tom Crayford wrote:
> >  The core API is very simple:
> >
> > data Matcher a = Matcher {
> >     match :: a -> Bool
> >   -- ^ A function that returns True if the matcher should pass, False if
> it
> > should fail
> >   , description :: String
> >   -- ^ A description of the matcher (usually of its success conditions)
> >   , describeMismatch :: a -> String
> >   -- ^ A description to be shown if the match fails.
> >   }
>
> How about combining match and describeMismatch as a single function
> of type a -> Match?  Then you wouldn't need the precondition on
> describeMismatch.
>

And this way we'd get `runMatch` right away in the data type:

data Matcher a = Matcher {
    runMatch :: a -> Match
  , description :: String
  }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130416/a3470fd7/attachment.htm>


More information about the Haskell-Cafe mailing list