I have some types like this:
type Workshop = { Start: DateTime; End: DateTime }
type Mounting = { Start: DateTime; End: DateTime }
type FixedWorkTime = { Start: DateTime; End: DateTime }
type WorkTime =
| Workshop of Workshop
| Mounting of Mounting
type ApprovedWorkTime =
| ExistingWorkTime of WorkTime
| FixedWorkTime of FixedWorkTime
Now I want to create a function with this signature WorkTime -> ApprovedWorkTime
let FixWorkTime (workTime: WorkTime) : ApprovedWorkTime =
match workTime with
| WorkTime.Workshop workshop -> ApprovedWorkTime.ExistingWorkTime { Start = workshop.Start, End = workshop.End }
| WorkTime.Mounting mounting -> ApprovedWorkTime.FixedWorkTime { Start = mounting.Start, End = mounting.End }
The match fails to compile with this error:
This expression was expected to have type 'WorkTime' but here has type 'FixedWorkTime'
How can I fix this?