I am trying to ensure that three arguments to a function are all not
Nothing.
Right now I have this (below), which works, but uses "withDefault." I want
to avoid this because the default values are meaningless and I want to
clearly and fundamentally avoid any possible situation where a Nothing gets
through to the "else" part
forecastProtected : Maybe Float -> Maybe Float -> Maybe Float -> (List Int)
-> List Float
forecastProtected q d b months =
if List.any (\m -> m == Nothing) [q, e, b] then []
else
forecast
(withDefault 0 q)
(withDefault 0 d)
(withDefault 0 b)
months
I am hoping to do something like this:
forecastProtected : Maybe Float -> Maybe Float -> Maybe Float -> (List Int)
-> List Float
forecastProtected q d b months =
let
params = {q = q, d = d, b = b}
in
case params of
{ Just qF, Just dF, Just bF } -> forecast qF dF bF months
{ Maybe, Maybe, Maybe } -> []
which more clearly shows what I am trying to achieve. Could someone point
me to the appropriate syntax for this? Also the 'F' in qF, dF, and bF are
"Float" to avoid masking of variables (not sure how this happens in elm);
it would be best if I could avoid this complication too.
Thanks everyone for all your help as I'm getting started!
Austin
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.