Curry's paradox (named after the same person as the present programming language) is a construction possible in a faulty logic that allows one to prove anything.
I know nothing about logic, but how hard can it be?
module Main where
import Data.Void
import Data.Function
data X = X (X -> Void)
x :: X
x = fix \(X f) -> X f
u :: Void
u = let (X f) = x in f x
main :: IO ()
main = u `seq` print "Done!"
It certainly does loop. (How does GHC know?!)
% ghc -XBlockArguments Z.hs && ./Z
[1 of 1] Compiling Main ( Z.hs, Z.o )
Linking Z ...
Z: <<loop>>
- Is this a faithful translation? Why?
- Can I do the same without
fix
or recursion? Why?
Void
without using fix or some kind recursion (either at the term level or at the type level). If you remove all the ways to recurse forever or cause runtime errors (likeundefined
), then the language becomes normalizing, so everyt :: T
reduces to somet' :: T
which is a normal form, "starting" with a constructor ofT
(or a lambda if that's a function type).Void
has no constructors, so that's impossible. – Slaby