News for hackers. Stuff that matters.
Re:Haskell: The Bad Parts, part 2 (2020) by a_wild_dandan on Tuesday February 09, 2021 @10:46AM (#26078790)
Ah, so partial functions aren't onto (i.e. surjective).
Re:Haskell: The Bad Parts, part 2 (2020) by wetmore on Tuesday February 09, 2021 @11:05AM (#26079082)
Not exactly, partial functions can be surjective, eg

f :: Int -> Bool

f 0 = True

f 1 = False

f n = f (n + 1)

is surjective onto Bool but also partial (doesn't return for n > 1). In Haskell we say that when a function doesn't return, the output is bottom, written as ⊥.

You could say that a function f : A -> B is partial if f^{-1}(B \ ⊥) is surjective.

Re:Haskell: The Bad Parts, part 2 (2020) by curtisf on Tuesday February 09, 2021 @10:59AM (#26078998)
No, they are not functions in the mathematical sense. It's not that they don't cover the output space, they don't cover the input space.