Implicit parameters: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{GHCUsersGuide|https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#implicit-parameters Implicit Parameters section}} | |||
Working example: | Working example: |
Revision as of 03:25, 27 October 2016
The GHC Users Guide has Implicit Parameters section.html#{{{2}}} {{{3}}}.
Working example:
{-# LANGUAGE ImplicitParams #-} import Data.List (sortBy) sortBy' :: (?cmp :: a -> a -> Ordering) => [a] -> [a] sortBy' = sortBy ?cmp
sort :: Ord a => [a] -> [a] sort = let ?cmp = compare in sortBy' main = putStrLn (show (sort [3,1,2]))