No, you would not. Record syntax is an addition to, not a replacement for, the form you want to use.
On Thu, 24 Nov 2016 23:09:26 -0800
Jeffrey Brown <jeffbrown.the@gmail.com> wrote:
> You still can! Using Rahul's solution, that is.
but wouldn't i have to write
A1 {name="a1", d="2.0}
A2 {name="a2", i=2}
etc...
?
That would be ok for these simple examples, but for my actual code the field names would not be just 1 or 2 characters.
Brian
>
> On Thu, Nov 24, 2016 at 11:08 PM, <briand@aracnet.com> wrote:
>
> > On Fri, 25 Nov 2016 12:06:06 +0530
> > Rahul Muttineni <rahulmutt@gmail.com> wrote:
> >
> > > data X =
> > > A1 { name :: String, d :: Double}
> > > | A2 { name :: String, i :: Int}
> > > | A3 { name :: String, d1 :: Double, i1 :: Int}
> > >
> > > Now you can use `name` directly to get the string component of the
> > > different variants.
> > >
> > > Hope that helps!
> >
> > oops, i forgot to mention.
> >
> > i'd like to be able to write my code;
> >
> > x = [ A1 "a1" 2.0, A2 "a2" 3 ]
> >
> > etc... to save myself a lot of typing.
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners@haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> >
>
>
>
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners