[Haskell-beginners] implicit or shorthand class instances?

Christopher Howard christopher.howard at frigidcode.com
Thu Nov 29 22:52:38 CET 2012


There is a lot of code in my project like so:

code:
--------
data SomeThing =
  Something { center :: ...
              velocity :: ...
              ...
            }

instance Locatable SomeThing where
  center = Something.center

instance Moving SomeThing where
  velocity = Something.velocity

instance ...
--------

Is there any special extension or syntax trick that would allow me to
reduce the amount of this repetitious code? Someway to implicitly state
that the functions in the data type are equal to the functions in the
class instance, rather than having to spell it out?

-- 
frigidcode.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121129/c16caea6/attachment.pgp>


More information about the Beginners mailing list