[ create a new paste ] login | about

Link: http://codepad.org/vkcUvLCm    [ raw code | output | fork ]

sah - Haskell, pasted on Apr 15:
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


Output:
1
2


Create a new paste based on this one


Comments: