Unit () and integer are different types, therefore, a function that takes >
either Int or Unit< isn't compatible with elm type system (I think it's actually a property of System F -
https://en.wikipedia.org/wiki/System_F but don't quote me on that).
However, you can construct either type like `Either () Int`. In elm there is `Result a b` which in essence Either type. Anyway since Unit / () has exactly one type constructor this one is unnecessary to be specified - We already have types which has this exact behavior -
Maybe. So `Maybe Int` is an essential part of a correct solution in my opinion.
However, we still need to solve return type which can be for instance either an intermediate result of final one (Either Int Int).
Now we can just put all of this together. This is what is the best solution in my opinion:
https://ellie-app.com/g3Z6VS9YCa1/1This is just one of the possible solution - for sake of simplicity I've tried to reuse existing types instead of defining my owns.