Local definitions in the class instances
batterseapower at hotmail.com
Tue Feb 1 10:52:06 CET 2011
On 27 January 2011 17:11, Iavor Diatchki <iavor.diatchki at gmail.com> wrote:
> instance Num Wrapped where
> lift2 f (Wrapped a) (Wrapped b) = Wrapped (f a b)
> lift f (Wrapped a) = Wrapped (f a)
> (+) = lift2 (+)
> (-) = lift2 (-)
> (*) = lift2 (*)
> abs = lift abs
> signum = lift signum
Local declarations at module scope can be emulated using pattern bindings:
(foo, bar) = (foo, bar)
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.
More information about the Haskell-prime