I created a nested discriminated union:
type hsAlgorithm = HS256 | HS384 | HS512
type rsAlgorithm = RS256 | RS384 | RS512
type esAlgorithm = ES256 | ES384 | ES512
type Algorithm =
| HMAC of hsAlgorithm
| RSA of rsAlgorithm
| ECDsa of esAlgorithm
I create an Algorithm variable:
> let a = HMAC HS256;;
val a: Algorithm = HMAC HS256
Is there a property to directly access HS256?
I wrote a function which matches the algorithm and returns the value but I wonder whether I can access the value directly. Below is my function to match the value:
let extractAlgorithm (algorithm: Algorithm) =
match algorithm with
| HMAC x -> x.ToString()
| RSA x -> x.ToString()
| ECDsa x -> x.ToString()