Re: Extracting values from several data constructors

23 Apr
2003
23 Apr
'03
7:20 p.m.
[redirected to haskell-cafe] On 24 Apr 2003, Steffen Mazanek wrote:
Hello. I am sure this question is not new. Even so, please give me the solution or point me to an old thread.
How can I implement something like:
data Test = T1 Int | T2 Int test::Test->Int test (_ x) = x
Or is this impossible? In case of yes, why? This would save a lot of case differentiations in my application. Or is there an appropriate compiler option?
It can be done, but only for labeled fields. For example: data Test = T1 { test :: Int } | T2 { test :: Int } See section 3.15 of the Haskell report. Dean
8063
Age (days ago)
8063
Last active (days ago)
0 comments
1 participants
participants (1)
-
Dean Herington