> data Conat = Z | S Conat
Ignoring bottoms (which we won't permit), this has all the natural numbers as inhabitants, but it also has infinity: > inf :: Conat
> inf = S inf
Note that, if I give you a conatural, all you can do with it is peel off successors; you can't distinguish infinity from "a really big number", extensionally. > -- find p returns a conatural that satisfies p, if one exists.
> -- (If one doesn't exist, it returns infinity.)
> find :: (Conat -> Bool) -> Conat
> find p = if p Z then Z else S (find (p . S))
> -- Does any conatural satisfy the predicate?
> exists :: (Conat -> Bool) -> Bool
> exists p = p (find p)
Of course, for "real" signals that you must handle synchronously, like SIGSEGV, signalfd is less useful and makes less sense (and arguably something closer to Windows's SEH might make more sense). It's an odd historical artifact of Unix that SIGCHLD and SIGSEGV use the same mechanism.