1

My question is related to "fixed point combinator". According to this Wikipedia page section a function fix such that

fix f = f (fix f)

is of type (or at least can be of type)

(a -> a) -> a

Can someone explain me why?

duplode
  • 33,731
  • 7
  • 79
  • 150
godot
  • 1,550
  • 16
  • 33
  • Have you read [this question](http://stackoverflow.com/questions/8099349/fixed-point-combinator-in-haskell) – Guvante May 04 '16 at 21:12
  • Thanks Guvante, I have seen it but from what I understood of it, it is not exactly what I asked... What I would like is an analytical answer or a point to a general method to solve that kind of problem... – godot May 04 '16 at 21:18
  • `fix f` is not `f`. It's `f (fix f)`. – dfeuer May 04 '16 at 22:03
  • you are right sorry, a typo when I sent the question. I corrected... – godot May 04 '16 at 22:30

1 Answers1

6

Start from the definition

fix f = f (fix f)

Since it takes an argument, fix must have a type that looks like

fix :: x -> y

It applies its argument to something, so in fact

fix :: (p -> q) -> r

It actually applies its argument to fix f, so

fix :: (r -> q) -> r

The final result is actually the result of this application, so

fix :: (r -> r) -> r
dfeuer
  • 48,079
  • 5
  • 63
  • 167