[Haskell-cafe] Abstraction in data types

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Fri Mar 19 00:36:56 EDT 2010


Only one small nit here:

On Mar 18, 2010, at 09:58 , Tillmann Rendel wrote:
> And we express Point as a GADT using Spherical and Cartesian as  
> follows.
>
>  data Point i
>    = Cartesian :: Cartesian_coord -> Cartesian_coord -> Point  
> Cartesian
>    | Spherical :: Latitude -> Longitude -> Point Spherical

The actual syntax for this is

 > data Point i where
 >   Cartesian :: Cartesian_coord -> Cartesian_coord -> Point Cartesian
 >   Spherical :: Latitude -> Longitude -> Point Spherical

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100319/645be1e4/PGP.bin


More information about the Haskell-Cafe mailing list