<div dir="ltr">data X =<div> A1 { name :: String, d :: Double}</div><div>| A2 { name :: String, i :: Int}</div><div>| A3 { name :: String, d1 :: Double, i1 :: Int}</div><div><br></div><div>Now you can use `name` directly to get the string component of the different variants.</div><div><br></div><div>Hope that helps!</div><div>Rahul</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 25, 2016 at 11:16 AM, <span dir="ltr"><<a href="mailto:briand@aracnet.com" target="_blank">briand@aracnet.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here's what I'm doing:<br>
<br>
data X = A1 String Double | A2 String Int | A3 String Double Int<br>
<br>
name c =<br>
case c of<br>
A1 name _ -> name<br>
A2 name _ -> name<br>
A3 name _ _ -> name<br>
<br>
I'm sure there's a better way...<br>
______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Rahul Muttineni</div>
</div>