On 22 December 2012 00:36, Christopher Howard
<christopher.how...@frigidcode.com> wrote:
> 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.

No, you can't suddenly add records in just for a type alias.  You
might be able to create lenses though for setters/getters, though if
you just want getters you can just write them yourself.

>
> --
> frigidcode.com
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
http://IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to