Local definitions in the class instances

Ben Millwood haskell at benmachine.co.uk
Tue Feb 1 13:23:26 CET 2011

On Tue, Feb 1, 2011 at 9:52 AM, Max Bolingbroke
<batterseapower at hotmail.com> wrote:
> Local declarations at module scope can be emulated using pattern bindings:
> """
> (foo, bar) = (foo, bar)
>  where
>    foo = ..
>    bar = ..
>    private = ...
> """
> If instance declarations supported pattern bindings you could get the
> same effect for your instances too. This would be a minimal change
> that avoided introducing any extra syntax.

This is kind of ugly, I think, and there are proposals to make pattern
bindings monomorphic which would make this sort of thing no longer
possible in general. I think I would be in favour of a declaration
analogue to let.

More information about the Haskell-prime mailing list