Re: [Haskell-cafe] Is it possible to represent such polymorphism?

2 Oct
2011
2 Oct
'11
4:22 p.m.
Assuming that z :: Int, you can declare an algebraic datatype
data TwoOrThree a b = Three (a, b, Int)
| Two (a, b)
deriving(Show, Eq) -- so you can experiment
And then define expand as
expand :: TwoOrThree a b -> (a, b, Int)
expand (Three tuple) = tuple
expand (Two (a, b)) = (a, b, 1)
Tom (amindfv)
On Oct 2, 2011 6:04 AM, "Du Xi"
4980
Age (days ago)
4980
Last active (days ago)
0 comments
1 participants
participants (1)
-
Tom Murphy