Closed callummole closed 2 years ago
There is an interesting wrinkle to optional arguments in ocaml. Optional arguments cannot be the last argument. If it is, the ocaml compiler cannot decide whether 1) the absence of an argument means it should partially apply the function and wait for a future argument, or 2) the absence means use the default value.
This gives the following warning:
let f ?(x=1) = x+x;;
Error (warning 16 [unerasable-optional-argument]): this optional argument cannot be erased.
But you can do these two things:
let f ?(x=1) y = x + y;;
f y;;
- : int = 4
let f ?(x=1) () = x + x;;
f ();;
- : int = 2
So, we can either:
1) have an optional argument but with a unit argument to end, but means that one always needs to call the function with ()
.
2) have a non-optional days
argument.
The ()
in each call sounds clunky, the kind of thing you never remember when you need to. I wouldn't be offended if it wasn't optional.
Closes #3, #4
Done:
Forecast.getTheCurrentSchedule
now looks for today+180 days.ForecastRaw.getAssignments
checks that endate is the same or after startdate, but places no upper restrictions.@mhauru perhaps
Forecast.getTheCurrentSchedule
should take adaysAhead
argument, that defaults to 180 days, instead of being hardcoded?