Local definitions in the class instances

Brandon S Allbery KF8NH allbery.b at gmail.com
Mon Jan 31 00:22:16 CET 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 1/30/11 05:54 , John Meacham wrote:
>> instance Num Wrapped where
>>     (+) = lift2 (+)
>>     (-) = lift2 (-)
>>     (*) = lift2 (*)
>>     abs = lift abs
>>     signum = lift signum
>>     fromInteger = Wrapped
>>  where
>>    lift2 f (Wrapped a) (Wrapped b) = Wrapped (f a b)
>>    lift f (Wrapped a) = Wrapped (f a)
> 
> so 'where' indroduces the local instance scope.

The double "where" strikes me as a bit odd.  Also, not sure how the parser
would deal with it, even given that using the second without the first is
entirely pointless; Haskell structures all follow a similar pattern WRT
where, and this confounds it in several ways.

- -- 
brandon s. allbery     [linux,solaris,freebsd,perl]      allbery at kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university      KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1F8qgACgkQIn7hlCsL25UDmQCg0iyxts0dSvbhqdDosK0WKF/w
CxkAnR5uxzTSYTmK4nvypRcIOtpxTDCm
=Z8+V
-----END PGP SIGNATURE-----



More information about the Haskell-prime mailing list