[Haskell-beginners] pattern matching on a common element

briand at aracnet.com briand at aracnet.com
Fri Nov 25 05:46:13 UTC 2016


Here's what I'm doing:

data X = A1 String Double | A2 String Int | A3 String Double Int

name c =
  case c of
    A1 name _ -> name
    A2 name _ -> name
    A3 name _ _ -> name

I'm sure there's a better way...


More information about the Beginners mailing list