Personal tools

Implicit parameters

From HaskellWiki

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]))