Fixpoint of type exponentiation as a language

116 Views Asked by At

Haskell permits fixpoint of type addition:

data Peano = Zero | Succ Peano

Haskell also permits fixpoint of type multiplication:

data InfBoolList = InfBoolList Bool InfBoolList

Yet I was very surprised of that Haskell also permits fixpoint of type exponentiation:

newtype FixExp = FixExp {appFixExp :: FixExp -> Bool}

The most basic elements of FixExp:

example1 = FixExp (const False)
example2 = FixExp (const True)

example1 always outputs False, example2 always outputs True, regardless of what they were fed.

For another example:

example3 = FixExp (`appFixExp` example1)

example3 feeds its operand example1. appFixExp example3 example3 is appFixExp example3 example1, which is then appFixExp example1 example1, which is then False.

For an extreme example:

example4 = FixExp (`appFixExp` example4)

example4 is the identity operation. appFixExp example4 example3 is appFixExp example3 example4, which is then appFixExp example4 example1, which is then appFixExp example1 example4, which is then False. And appFixExp example4 example4 doesn't halt!

With help of other functions, some crazy examples include:

import Control.Monad

example5 = FixExp (not . `appFixExp` example5)
example6 = FixExp (join appFixExp)

So far, FixExp seems to be a mini-language. Is FixExp Turing-complete?

0

There are 0 best solutions below