Personal tools

Implicit parameters

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(link to ghc manual)
 
 

Latest revision as of 18:41, 18 December 2012

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