Tasks (Polyglot)¶
In [ ]:
//// test
open testing
task_name¶
In [ ]:
nominal task_name = string
manual_scheduling¶
In [ ]:
union manual_scheduling =
| WithSuggestion
| WithoutSuggestion
recurrency_offset¶
In [ ]:
union recurrency_offset =
| Days : i32
| Weeks : i32
| Months : i32
day_of_week¶
In [ ]:
union day_of_week =
| Sunday
| Monday
| Tuesday
| Wednesday
| Thursday
| Friday
| Saturday
month¶
In [ ]:
union month =
| January
| February
| March
| April
| May
| June
| July
| August
| September
| October
| November
| December
day¶
In [ ]:
nominal day = i32
year¶
In [ ]:
nominal year = i32
fixed_recurrency¶
In [ ]:
union fixed_recurrency =
| Weekly : day_of_week
| Monthly : day
| Yearly : day * month
recurrency¶
In [ ]:
union recurrency =
| Offset : recurrency_offset
| Fixed : list fixed_recurrency
scheduling¶
In [ ]:
union scheduling =
| Manual : manual_scheduling
| Recurrent : recurrency
task¶
In [ ]:
type task =
{
name : task_name
scheduling : scheduling
}
date¶
In [ ]:
type date =
{
year : year
month : month
day : day
}
status¶
In [ ]:
union status =
| Postponed : option ()
event¶
In [ ]:
type event =
{
date : date
status : status
}
task_template¶
In [ ]:
type task_template =
{
task : task
events : list event
}
get_tasks (test)¶
In [ ]:
//// test
inl get_tasks () : list task_template =
[
{
task =
{
name = task_name "01"
scheduling = Manual WithSuggestion
}
events = []
}
{
task =
{
name = task_name "02"
scheduling = Manual WithSuggestion
}
events = []
}
{
task =
{
name = task_name "03"
scheduling = Manual WithSuggestion
}
events = []
}
]
In [ ]:
//// test
///! fsharp
///! cuda
///! rust
///! typescript
///! python
get_tasks ()
|> sm'.format_debug
|> _assert sm'.contains "01"
.py output (Cuda): __assert / actual: 01 / expected: UH2_1(v0='01', v1=US1_0(v0=US0_0()), v2=UH1_0(), v3=UH2_1(v0='02', v1=US1_0(v0=US0_0()), v2=UH1_0(), v3=UH2_1(v0='03', v1=US1_0(v0=US0_0()), v2=UH1_0(), v3=UH2_0()))) .rs output: __assert / actual: "01" / expected: "UH2_1("01", US1_0(US0_0), UH1_0, UH2_1("02", US1_0(US0_0), UH1_0, UH2_1("03", US1_0(US0_0), UH1_0, UH2_0)))" .ts output: __assert / actual: 01 / expected: UH2_1 (01, US1_0 US0_0, UH1_0, UH2_1 (02, US1_0 US0_0, UH1_0, UH2_1 (03, US1_0 US0_0, UH1_0, UH2_0))) .py output: __assert / actual: 01 / expected: UH2_1 ("01", US1_0 US0_0, UH1_0, UH2_1 ("02", US1_0 US0_0, UH1_0, UH2_1 ("03", US1_0 US0_0, UH1_0, UH2_0)))
.fsx output: __assert / actual: "01" / expected: "UH2_1 ("01", US1_0 US0_0, UH1_0, UH2_1 ("02", US1_0 US0_0, UH1_0, UH2_1 ("03", US1_0 US0_0, UH1_0, UH2_0)))"
In [ ]:
//// test
///! fsharp
///! cuda
///! rust
///! typescript
///! python
get_tasks ()
|> listm'.try_item 0i32
|> fun (Some task) => task.task.name
|> _assert_eq (task_name "01")
.py output (Cuda): __assert_eq / actual: 01 / expected: 01 .rs output: __assert_eq / actual: "01" / expected: "01" .ts output: __assert_eq / actual: 01 / expected: 01 .py output: __assert_eq / actual: 01 / expected: 01
.fsx output: __assert_eq / actual: "01" / expected: "01"