I have a situation where I'm stitching three different unions into a triplet tuple for building a map/dictionary of strongly typed values keyed on a string.
One of the union cases is very large, the second has three options, and the third has only two. Right now I loop through the large with reflection, and have six yield statements to handle the combinations of the second and third unions.
My code works fine as far as I can tell so far, but I don't quite like having yield
in my code six times. How can I better represent this situation?
*If needed I can post the code for the unions too.
**Note that (RawOreName ore).Value
is just a string.
let OreDataMap =
[
for oreType in FSharpType.GetUnionCases typeof<EveOnline.OreDomain.Types.OreType> do
let ore = FSharpValue.MakeUnion (oreType, [| |]) |> unbox
yield (RawOreName ore).Value, (ore, Common, IsCompressed)
yield (RawOreName ore).Value, (ore, Uncommon, IsCompressed)
yield (RawOreName ore).Value, (ore, Rare, IsCompressed)
yield (RawOreName ore).Value, (ore, Common, IsNotCompressed)
yield (RawOreName ore).Value, (ore, Uncommon, IsNotCompressed)
yield (RawOreName ore).Value, (ore, Rare, IsNotCompressed)
]
|> Map.ofList