I have the following custom data type:
type Length = Integer
type Rotation = Integer
data Colour = Colour { red, green, blue, alpha :: Int }
deriving (Show, Eq)
data Special
= L Length
| R Rotation
| Col Colour
deriving (Show, Eq)
Say that I have a tuple of the following form:
let x = ("Jump", R 90)
And I extract the second value in the tuple using:
snd x = R 90
Is there any way that I can use pattern matching to get the Rotation value 90 from R 90 so that I can use it in another area of code? When I use snd x, the type of the result is of type Special but I would just like to get the Rotation value. Any insights are appreciated.
case snd x of R n -> ...?let (R rotation) = snd x in ...