Haskell's ($) to magiczny operator?
Powiedz, że mam następujące funkcje:
infixr 0 <|
{-# INLINE (<|) #-}
(<|) :: (a -> b) -> a -> b
f <| x = f x
foo :: a -> (forall b. b -> b) -> a
foo x f = f x
Poniższe nie wpisują czeku:
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
Jednak,foo 3 $ id
robi.
Definicja (<|) jest (o ile wiem) identyczna z definicją ($). Prawie wyrwałem definicję ze źródeł biblioteki podstawowej i zmieniłem każdą instancję ($) na (<|). Magia kompilatora?