Personal tools

Implicit parameters

From HaskellWiki

Revision as of 18:41, 18 December 2012 by Dsf (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The GHC manual on implicit parameters: [1].

Working example:

{-# LANGUAGE ImplicitParams #-}

import Data.List (sortBy)

sort   :: (?cmp :: a -> a -> Ordering) => [a] -> [a]
sort    = sortBy ?cmp

main = let ?cmp = compare in putStrLn (show (sort [3,1,2]))