...to deal with the case where a negative parameter is passed in. But it
seems like what I really want is something like this:
f :: Positive Int -> Int
I.e., the "positiveness" is hard-coded into the parameter type. But how
do I do this? I was thinking it would involve some kind of "Positive
Int" type, and some kind of "constructor" function like so:
positiveNum :: Int -> Positive Int
However, then this constructor function must deal with the problem of
receiving a negative integer, and thus I have only shifted the problem.
It is still an improvement, but yet it seems like I am missing some
important concept here...
The concept is called "dependent types", where a type can depend on a value. Haskell doesn't support them natively, although there are some hacks for limited cases.
--