Haskells ($) ist ein magischer Operator?
Angenommen, ich habe die folgenden Funktionen:
infixr 0 <|
{-# INLINE (<|) #-}
(<|) :: (a -> b) -> a -> b
f <| x = f x
foo :: a -> (forall b. b -> b) -> a
foo x f = f x
Folgendes gibt check nicht ein:
ghci> foo 3 <| id
Couldn't match expected type `forall b. b -> b'
with actual type `a0 -> a0'
In the second argument of `(<|)', namely `id'
In the expression: f 3 <| id
In an equation for `it': it = f 3 <| id
Jedoch,foo 3 $ id
tut.
Die Definition von (<|) ist (soweit ich weiß) identisch mit der Definition von ($). Ich habe die Definition aus den Quellen der Basisbibliothek herausgerissen und jede Instanz von ($) in (<|) geändert. Compiler-Magie?