[Haskell-beginners] Re: Enforcing Monad Laws

Daniel Fischer daniel.is.fischer at web.de
Sun Jul 4 11:16:21 EDT 2010


On Sunday 04 July 2010 16:05:48, Jorden M wrote:
> > Now that I've had a really short look at Axioms, I think the Haskell
> > equivalent would be QuickCheck properties. After all, Axioms are not
> > enforced by the compiler, their only effect is documentation. Granted,
> > they
>
> Really? I thought they were.
>

I think that's not even possible in general.
Generally, you can't decide the equality of functions [okay, we're dealing 
with finite domains in a computer, so in principle one could check all 
possible inputs, but even for a small type like uint64_t, that's 
impractical].

> > are part of the source code, but frankly, I don't see how this has
> > more effect than stating invariants as QuickCheck properties or
> > writing them down in a comment.
>
> Would it make sense to try to formalize things like the monad laws
> using QuickCheck?.

To a certain extent. You'd have a good chance to catch gross violations of 
the monad laws with QuickCheck. But for subtle violations, the odds are 
minuscule.



More information about the Beginners mailing list