I\'m new to Haskell and would like to know whether it\'s possible to define a function that is only defined on a subset of an already existing type, without actually having
In general no. Such a thing is called a subset type, it's a hallmark of dependent types which Haskell doesn't have. Usually it's implemented by boxing a value with a proof that the value satisfies some property, but since we have no notion of proofs in Haskell, we're stuck.
Usually the way to fake it is with "smart constructors".
newtype Even = Even {unEven :: Integer} deriving (Eq, Show, Ord)
toEven :: Integer -> Maybe Even
toEven a | even a = Just $ Even a
| otherwise = Nothing
And then hide the Even
constructor.
If you really really want it, you can switch to a language that can interop with Haskell that has dependent types (Coq and Agda spring to mind).