1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-} import Prelude hiding (($)) import qualified Prelude as P class Applicable f t | f -> t where apply :: f a -> t -> a instance Applicable [] Int where apply = (!!) instance Applicable ((->) a) a where apply = (P.$) ($) :: Applicable f t => f a -> t -> a ($) = apply infixr 9 $ main = do putStrLn $ show $ [1,2,3] $ 1
1
2