Starting point:
fn :: [a] -> Int
fn = (2 *) . length
Let\'s say we only want to constrain the return value, then we could write:
You're looking for feature that many of us would like, but that Haskell doesn't have. Nor ghc. You want a kind of partial type signatures. The suggested notation for this is
fn :: [Char] -> _
fn = (2*) . length
Where the _
means "there's a type here, but I can't be bothered to write it out".
It looks like a very easy feature to implement (instantiate _
with unification variables in the signature), but nobody has bothered to work out the semantic details and the interaction with other features.