by Sharlin · 8y ago · 0 comments
And assuming the theory is consistent(so no infinite loops etc.) this is the only instance of that function, so the cardinality is 1.
{-# LANGUAGE RankNTypes #-}
type Bottom = forall a. a -- zero inhabitants
f :: Bottom -> a
f x = x
That passes the type checker just fine.I think you are running into some weird haskellisms with your Bottom-type.
The normal way of defining that in haskell is using the "EmptyDataDecls" pragma, like this:
{-# LANGUAGE EmptyDataDecls #-}
data Empty
g :: Empty -> a
g x = x
Which doesn't pass the type checker.(From a theoretic standpoint, I would have thought your Bottom was a essentially a type-level identity function..)
Another way to look at it is as a constrained subset of the Cartesian product of domain and codomain. In this case the domain is the empty set, so the Cartesian product is empty too.
Take this Haskell code that passes the type checker:
bottom = bottom
f :: Int -> a
f _ = bottom
Here 'bottom' has the conceptual type Void/Bottom and checks successfully against the 'a'.So assuming we have this Void type in Haskell (I don't know if Haskell has it or not), this should also type check:
f :: Void -> a
f x = x
Just like bottom (of type Void) checked against the 'a' earlier, an argument of that type should also type check. f :: Void -> a
f _ = let x = x in x