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/1

This is just one of the possible solution - for sake of simplicity I've 
tried to reuse existing types instead of defining my owns.

-- 
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.

Reply via email to