I want to define what seems to require an infinite type.

Required : a function "eat" that eats all it's arguments except "3" for which it returns 3

eat 3 = 3
eat x = eat

So basically an arbitrary expression like "eat (+) foldl (Just 5) 3" evaluates to 3. But the problem here is the type of eat. What should that be?

The closest i got to a running code was :

newtype Rec = MakeRec (Int -> Rec)

eat :: Int -> Rec
eat x = MakeRec eat


instance Show Rec where
     show _ = "EAT"

This works okay for "eat 6" but not for "eat 6 7" and it doesn't work if i put (eat 3 = 3) in it's definition.

I am not sure if this is even possible in Haskell. (What argument would one use to show it's not possible ?)

UPDATE : As noted in solution below, the type-information is needed at compile time so that compiler can know if "eat foldl 3 foldl" is invalid or not. So, exact solution to this problem is not possible.

Edit
Report