[Haskell-cafe] Layer on a layer of record syntax in the type synonym?

Christopher Howard christopher.howard at frigidcode.com
Fri Dec 21 14:36:04 CET 2012


Using a simple type I gave earlier from my monadic type question...

code:
--------
data Socket3 a b c = Socket3 a b c
  deriving (Show)
--------

Is it possible somehow to layer on record syntax onto a synonym of the type?

The idea would be something like this...

code:
--------
type SpaceShip =
  Socket3 { engine :: Last Engine
          , hull :: Last Hull
          , guns :: [Guns]
          }
--------

...purely for the convenience. But this doesn't seem to work with "type"
as it assumes you are referring to already made constructors, and
evidently "newtype" only allows use of a single record. I could wrap it
in a normal "data" declaration but that would add an extra layer of
complexity I think.

-- 
frigidcode.com

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


More information about the Haskell-Cafe mailing list